Repository navigation
feat(threads): record a Slack thread's anchor on every dispatch - #15410
chenmingwei23 wants to merge 2 commits into
Conversation
First Principles Review (Opus 5.5) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK The Slack anchor is write-only: nothing outside its own writer reads Not justified as shipped
What this change shipsInventory (5 items) — 2 justifiedIntent: let a Slack thread say which message it hangs off (ADDITION).
Blockers
[FIRST-PRINCIPLES-REVIEWED] fd2d575 Description read[DESCRIPTION-READ] b195f5ac55df8dc62f5a32a62a34b5eb40b77f5329a3b9c460923c85526cf0bd That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — 🔴 changes requested (blocking)GPT 6.1 found at least one blocking issue that must be resolved before merging This comment is updated in place on each push. BLOCKING -- [BLOCK-MERGE] fd2d575 Adjudication (Opus 5.5) — is blocking on each finding proportionate?I checked the one fenced finding against the code and marked it FLAG. It keeps blocking the merge either way. FLAG only adds a pre-written rationale in case a repository writer decides to override it with F1 (unbounded harm: the deleted messages cannot be recovered)
🏷️ Fenced finding(s) machine-flagged as likely edge caseThe security fence keeps these findings blocking regardless of adjudication; the only clearance path is a human override. The annotate-only pass judged the condition combination each one requires extreme, and pre-drafted the override rationale below. A repository writer must independently verify a rationale before posting it — it is machine-authored, and a wrong override on a security-class finding ships exactly the class the fence exists to stop.
False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. FINDING — src/kiro_crew/dashboard/thread_projection.py:960 — the fold stops only after [OPUS-REVIEWED] fd2d575 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
73b9518 to
5661946
Compare
|
Rebased onto the current GPT 5.6 blocking finding (restricted-mode persistence) — fixed. Both
An Opus 5 findings ( First Principles (CONCERNS) is advisory and non-blocking. Local gate green on the rebased tree: |
Sensitive Change ReviewSensitive files changed:
A human reviewer with write access must approve the CURRENT head and |
5661946 to
a9395ce
Compare
a9395ce to
46a2b5c
Compare
A reply thread on a crewmate's chat was a bounded reply list: replies in a
sidecar, every reply in a throwaway `thread:<slot>:<mid>` session that could
never resume, a forced read-only tool posture, no memory, the whole envelope
re-seeded each turn, and a one-reply-in-flight lock. It lived only on the
Crewmates page, only behind the `dashboard.crewmate_threads` flag, and only on
a message whose turn had already finished.
A thread is now an ordinary chat session plus an anchor to one message.
Anchor is (surface, conversation, message id): (dashboard, parent slot, mid) and
(slack, channel id, thread_ts). It is stored on the thread session's own metadata
and in a per-parent index -- the old reply sidecar, at version 2. Version 1 files
are read in place and render as a read-only fold, because their replies came from
a cold read-only session with no memory and replaying them as a full session's
transcript would assert a history that session never had.
Opening never touches the running turn: no semaphore, no `_handle_busy` branch,
no `messaging.queue_mode` value. It reads a non-consuming snapshot of the parent's
partial text, so every messaging invariant holds. A streaming row has no mid, so
the anchor resolves to the user message that started the turn, which is already
persisted.
Two openers, one coroutine: `POST /api/chat/threads/{mid}/open` for a person
clicking a message, and MCP `thread_open` for an agent opening one on the message
it is answering. `open_thread` calls `create_session` directly and lets its
refusals through verbatim rather than adding a bypass.
Slack already keyed one session per thread_ts and never recorded it; that session
is now recorded as anchored, with nothing re-keyed and the 1:1 DM fold and the
dashboard mirror binding untouched.
`thread/opened` and `thread/closed` join `session/opened` in the crew log, so the
ledger is the existing one. `dashboard.crewmate_threads` is removed, not defaulted
on. Retired with it: `thread_session_key`, the `thread:` stateless prefix,
`_run_thread_turn`, `build_thread_message` and its envelope constants, the
read-only spec posture, the per-reply byte caps, and `409 not_crewmate_chat`.
Specs updated alongside: history.md (new Surfaces section), session.md,
slack-gateway.md, crew-mode.md, docs/feature-map/README.md.
Stacks on the Crew Bot Threads epic. A Slack thread has no parent transcript to hang an anchor index off, so it keeps its own `_thread_anchor` metadata line, and this is the recorder that writes it. Both dispatch paths call it at the same point, immediately after the `is_new` `set_channel` gate, off the loop because it reads and rewrites a metadata line. It is called on EVERY dispatch rather than only a new session: the write can fail transiently and the recorder swallows that by contract, so a call gated on `is_new` would leave the anchor missing for the life of the process, `is_new` being false for every later message in the same thread. The recorder is idempotent -- a session already carrying an anchor is returned untouched and writes no second `thread/opened` -- so the steady-state cost is one metadata read. It answers None, not an error, for a folded 1:1 DM, a dashboard-linked route, or a channel id it does not recognise: those are ordinary shapes, not faults. Split from the epic because the review lanes cap a diff at 1 MB and the epic sat over it. The boundary is two one-name imports, so nothing else moves.
46a2b5c to
fd2d575
Compare
|
Both GPT 6.1 blockers are fixed in code on the epic (#14928, now head
Slice-local: the |
|
Closing this after an audit. This is additive plumbing (recording a Slack thread's anchor on every dispatch) for the unshipped thread feature in #14928. With #14928 closed, this has no standalone value — it only feeds a feature that isn't landing in its current form. The branch ( |
Stacks on #14928; the Slack anchor recorder for Crew Bot Threads (CREW-18694 part 2)
Problem / Motivation
Goal: a Slack thread records which message it hangs off, so the thread's own
history can name its anchor.
A Slack thread has no parent transcript to hang an anchor index off, the way the
dashboard does. It keeps that statement on its own
_thread_anchormetadata lineinstead. Nothing writes that line yet.
Why it matters
Without the recorder a Slack thread is a session with no record of what it is a
thread of, so nothing downstream can resolve its anchor.
Not a goal
Slack's native threading, which main already has. This adds the anchor record and
nothing about how Slack threads are created or rendered.
What changed (motivation -> approach -> change)
Both dispatch paths call
record_anchorat the same point, immediately after theis_newset_channelgate, off the loop because it reads and rewrites a metadataline.
It runs on EVERY dispatch rather than only a new session. The write can fail
transiently and the recorder swallows that by contract, so a call gated on
is_newwould leave the anchor missing for the life of the process --
is_newis false forevery later message in the same thread. The recorder is idempotent: a session
already carrying an anchor is returned untouched and writes no second
thread/opened, so the steady state is one metadata read.set_channelstaysgated, because that one is not idempotent.
It answers None rather than an error for a folded 1:1 DM, a dashboard-linked route,
or a channel id it does not recognise. Those are ordinary shapes, not faults.
Backwards compatibility
Additive. A session with no anchor behaves as it does today. This slice adds only
the Slack anchor recorder (5 files, +648).
Because this PR stacks on #14928, its diff against
mainalso carries thatepic's removals, so PR Hygiene's take-away check names them here too. Each removed
public def is from the epic's deletion of the old crewmate side-chat reply path,
and each had exactly one reader, all inside that removed path or its route
registration -- the same reader list the epic's own
## Backwards compatibilitycarries:
Reader: src/kiro_crew/dashboard/routes/chat.py:configure_chat_routes -- chat -- the only reader of api_chat_thread_reply was the POST /api/chat/threads/{mid}/reply registration; the epic drops that line and registers the new /open and /close routes instead, so no route resolves the removed handler
Reader: src/kiro_crew/dashboard/chat_threads.py:api_chat_thread_reply -- chat -- thread_session_key, build_thread_message and threads_enabled were called only from api_chat_thread_reply and its helpers in this same file, all removed together in the epic's rewrite, so no caller survives
Reader: src/kiro_crew/session.py:_THREAD_PREFIX -- chat -- the one reference to build_thread_message outside chat_threads.py was a code comment beside the _THREAD_PREFIX session-prefix constant; the comment is updated and nothing imports the removed symbol
Reader: src/kiro_crew/dashboard/chat_threads.py:broadcast_thread_reply -- chat -- broadcast_thread_reply (in ws.py) was imported and called only by the removed reply path in chat_threads.py; the new path broadcasts the chat.thread_anchor frame instead, so the removed def has no reader
Tests
test/test_slack_thread_anchor.py-- 8 tests covering both dispatch paths, theidempotency guard, and each None case.
Manual verification
Covered by the epic's own verification; this slice has no surface of its own.
Why no screenshot: This slice is backend-only -- the Slack anchor recorder (
slack/handler.py,slack/threads.py,slack/transport_dispatch.py), a docs page and a test, with no frontend surface. The frontend files the diff shows againstmainbelong to the stacked epic #14928, which carries its own screenshot evidence; this PR adds no visual delta of its own.Related Issues
CREW-18694 part 2. Stacks on #14928.
Other notes
Split out of #14928 because the AI review lanes fail closed on a diff over 1 MB and
the epic measured 1,006,837 bytes. The boundary is two one-name imports of
record_anchor, so nothing else moved with it. Draft until #14928 merges: againstmainthis PR's diff shows the epic as well, and it is reviewable on its own onlyonce the epic has landed.