Skip to content

fix(hooks): fire SessionLaneChanged when a new chat inherits a lane - #36132

Merged
bolichen97 merged 1 commit into
mainfrom
fix/31614-folder-status-lane-event
Nov 20, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/31614-folder-status-lane-event

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A new session filed into a folder whose tags include a board lane fires SessionLaneChanged, so a hook keyed on entering that lane sees it.

SessionLaneChanged fires from the two dashboard tag routes, PUT /api/chat/slots/{slot}/tags and POST /api/chat/slots/{slot}/drop. A new chat created inside a folder copies that folder's tags, and when one of them is a status tag the session lands in that lane with no event. The owning spec records it as a known gap.

Why it matters

Anyone who files new chats into a folder that carries a lane (a "Triage" folder whose chats start in a Triage lane) never sees their hook run for those chats. A hook keyed on entering the lane silently misses every session that started there, so an automation built on the event has to keep polling the board anyway.

Not a goal

  • The channel filing path (surface_channel_session): it has no dashboard caller, so what authorizes a fire there is still undecided.
  • Fork emission, or moving the emit to a single choke point.
  • Any change to which callers may fire the event, or to the payload.

What changed (motivation → approach → change)

A new session in a lane-tagged folder entered that lane without the event, because the create route copies the folder's tags itself and never reached the dispatcher the tag routes call.

The create route now calls that same dispatcher, dispatch_session_lane_changed_bulk, with the tags the session held before the copy and after it. The dispatcher already fires only for a change in status tags and already refuses a caller that is not the dashboard user, so a label-only folder, an already-open session addressed by name (which inherits nothing) and an agent's create stay silent with no new check.

It fires at the same point the tag routes do: after the create has passed its last refusal and its save has confirmed. When the create inherited a tag, its save takes the tag routes' confirming mode (_persisted_tag_write), so a save that failed fires no hook at all; the periodic flush still retries the save. The owning spec and the hook events table in steering-and-hooks.md list the create as the third emit site.

Backwards compatibility

Compatible: a create that inherits no status tag behaves exactly as before; one that does now also fires the hook a person registered for that lane.

Removes nothing: the diff only adds a dispatch call and switches one save to its confirming mode, which keeps the same retry on failure.

Tests

test/test_session_lane_changed_emitter.py drives POST /api/chat/slots with the vocabulary built by the real tag route:

  • a new session in a folder tagged with a lane and a plain label fires once, with only the lane id in added;
  • a label-only folder, an already-open session, and a save that failed underneath (the slot is left dirty for the flush) fire nothing.

Determinism: the new class passed 20 runs at -n0 and 10 at -n 4 --dist loadgroup --max-worker-restart=2 beside test_session_lane_changed_event.py and test_chat_slot_create_folder.py, and the whole module passed in a shuffled order (seed 9539, 19 ids).

Proof: PROVEN test/test_session_lane_changed_emitter.py::TestANewSessionInheritingAFolderLane::test_inheriting_a_folder_lane_fires_once (head fcff8bc)

Manual verification

On Ubuntu 24.04.5 LTS, an isolated gateway (a throwaway KIROCREW_HOME, a loopback port) driven over HTTP as the dashboard user, with one enabled SessionLaneChanged hook that appends its payload to a file:

Step main this PR
POST /api/chat/slots into a folder carrying a lane and a plain tag 200, hook did not run 200, hook ran once
POST /api/chat/slots into a folder carrying only the plain tag not run hook did not run
PUT /api/chat/slots/<slot>/tags with the lane (control) hook ran hook ran

The payload the fixed build delivered for the first row:

{"hook_event_name": "SessionLaneChanged", "slot": "inlane-fixed", "added": ["435ca0250731"], "removed": [], "session_key": "dashboard:inlane-fixed"}

Related Issues

Closes #31614

Sibling sweep

Swept: git grep -n "slot.tags.append|.tags = list(" -- src/kiro_crew/dashboard/
Sibling: src/kiro_crew/dashboard/channel_slots.py -- not affected -- channel first-filing (surface_channel_session) and folder backfill (backfill_channel_folder) are deliberately silent: no dashboard caller, so the permit gate has no answer yet (RFC closing order step 2)
Sibling: src/kiro_crew/dashboard/session_directive_apply_slot.py:551 -- not affected -- an agent's own tag directive, and an agent's move fires nothing by contract
Sibling: src/kiro_crew/dashboard/chat_fork.py:649 -- not affected -- fork emission is an open question in the RFC, not a recorded emit site

Pattern harvest

Not generalizable: a single writer of slot.tags that predates the event; the RFC's choke point is the structural fix for the class.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 12, 2026 22:04
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

  • No sensitive path changed; nothing to check.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 88ef828e9f1c5bc6dd3c2dc3ee0df10903388575 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 88ef828e9f1c5bc6dd3c2dc3ee0df10903388575 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix calls the existing dispatcher, permit gate and confirming save (chat_tags.py:77,92, hooks), adds no new surface, and closes the gap the base spec already recorded as "A KNOWN GAP, not a deferral by design" (#31614).

What this change ships

Inventory (5 items) — 5 justified

Intent: when a person starts a chat inside a folder whose tags include a board lane, their SessionLaneChanged hook should run for it. This is a FIX.

  1. A new chat filed into a lane-tagged folder now fires SessionLaneChanged once, carrying only the lane id — justified
  2. When a create inherits folder tags, its save now waits to confirm the write, and a failed save fires no hook (the flush still retries it) — justified
  3. The hook events table in steering-and-hooks.md names starting a chat in a lane folder as a trigger — justified
  4. The owning spec now lists three emit sites and drops the known-gap paragraph — justified
  5. chat_handlers.py re-exports _persisted_tag_write and _tag_vocabulary for the create route's import seam — justified

[FIRST-PRINCIPLES-REVIEWED] 88ef828

Description read

[DESCRIPTION-READ] d310458754687b88a4033cd5905cf868be1511e9a1c1c129123190ca3699e8ab

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 88ef828e9f1c5bc6dd3c2dc3ee0df10903388575 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the create route now calls the tag routes' existing dispatcher, permit gate and confirming save, so it adds no new mechanism.

Notes

  • If _unhide_folder declines the folder move after the tags were copied, the session falls back to its previous folder but keeps the copied tags, and the lane event still fires. The lane entry is real, so firing is correct. The question is whether a create that loses its folder should keep that folder's tags at all. That behaviour existed before this PR and is a separate follow-up.

[DESIGN-REVIEWED] 88ef828

Description read

[DESCRIPTION-READ] 7fd2cbe4dc7b90a1d621c253c307e0fcdab3eaa05b82aa9f9f7b7cd55668b6ff

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@bolichen97
bolichen97 enabled auto-merge (squash) November 12, 2026 22:20
@KiroCrewCaptain

KiroCrewCaptain commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

The create route now records (prior_tags, new_tags) under tags_write_lock only when inherited folder tags were actually appended to a new slot. When they were, it saves through the tag routes' confirming _persisted_tag_write, and after the create block's last refusal it dispatches through the existing dispatch_session_lane_changed_bulk. The dispatcher's existing gate (_lane_dispatch_is_permitted) lets only the dashboard user fire it, so agent, app and member creates stay silent, and it fires only when status tags change, so label-only folders stay silent too. The save behaves the same as before: with best_effort=True a failure is swallowed and the slot marked dirty; in confirming mode _persisted_tag_write catches the error and marks it dirty itself, so the periodic flush still retries. The only new effect is that a failed save holds the hook back. The new tests go through the real create route: a lane folder fires once with the lane in added; a label-only folder, an already-open session and a failed save fire nothing, and the failed save leaves the slot dirty. The spec and the hooks events table were updated to match.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 47c8e670fd · 139 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 12, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 88ef828e9f1c5bc6dd3c2dc3ee0df10903388575 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 88ef828

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 88ef828e9f1c5bc6dd3c2dc3ee0df10903388575 false-positive: <reason, 20 to 500 characters>

@bolichen97
bolichen97 force-pushed the fix/31614-folder-status-lane-event branch from 756662f to f3470e6 Compare November 13, 2026 01:23
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 88ef828e9f1c5bc6dd3c2dc3ee0df10903388575 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 88ef828

Verdict parsed from the review's SHA-scoped output markers for commit 88ef828e9f1c5bc6dd3c2dc3ee0df10903388575.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 88ef828e9f1c5bc6dd3c2dc3ee0df10903388575 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97
bolichen97 force-pushed the fix/31614-folder-status-lane-event branch from f3470e6 to 62208c5 Compare November 13, 2026 06:18
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/dashboard/chat_api/slot_create.py, src/kiro_crew/dashboard/chat_tags.py and test/test_reply_format_once.py since this head went green (2f7e9f2 -> fb49a0c); CI re-running.

Backend Tests shard 8 (Linux and Windows) was red only on test/test_reply_format_once.py::TestEveryMessageWhereTheBlockCannotBeTakenOut::test_the_table_names_every_selectable_harness, which was red on main too and is fixed there by #36290. The patch itself is unchanged.
[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=ced2e74a5585 Dispatch can announce a lane addition absent from the confirmed write

Rebutted: not a defect this PR adds; the create route keeps the ordering the two tag routes already have, and both proposed remedies are worse than the anomaly.
Ordering: api_chat_slot_tags and api_chat_slot_drop also dispatch after leaving _tags_write_lock (chat_tags.py:374-375, 1047-1048), so no route orders its lane event against a later writer; a PUT that removes the lane fires its own removed event either way.
Revision check: dropping the create's event when a later write superseded it leaves the hook a removed with no matching added, which trades one stale sequence for another and fixes no ordering.
Holding the lock: keeping tags_write_lock across _birth_default_project and agent resolution (slot_create.py:891 to 1209) stalls every tag writer, because all tag CRUD shares that one lock.
Harm: the event is informational and cannot veto (hook_dispatch.py:430), no subscriber ships (early return at :445), the window needs a second tab to retag a chat that is still being created, and no state is lost or corrupted.
The Opus adjudication on this head reached the same ruling (DOWNGRADE F1, disproportionate-remedy); the GPT lane is green.
[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 13, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The two red checks on this head are main's, not this PR's. Backend Lint & Type Check (3.12) fails on mypy at src/kiro_crew/cli_commands_memory.py:335 (declared assigned a bool where an earlier line in the same function made it a list[str]), a file this PR does not touch; it went red on main when #36114 and #36212 landed together. Coverage Gate fails closed only because lint failed, so the test shards never started.

The fix is #36457 (tracked in #36458). This PR waits for it: once it merges, the branch is re-synced onto it and CI runs again. No code change here.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97
bolichen97 force-pushed the fix/31614-folder-status-lane-event branch from 62208c5 to 47c8e67 Compare November 13, 2026 11:04
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/dashboard/chat_api/slot_create.py, docs/system-specs/modules/memory-skills-hooks.md since this head went green (fb49a0c -> 9807bdd); CI re-running.

The new base carries #36457, the fix for the mypy red on main that held this head.

[operator: bolichen97]

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 13, 2026
@bolichen97
bolichen97 force-pushed the fix/31614-folder-status-lane-event branch from 47c8e67 to 732e909 Compare November 17, 2026 23:12
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased onto current main to resolve the merge conflict in src/kiro_crew/dashboard/chat_api/slot_create.py.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 17, 2026
@bolichen97
bolichen97 force-pushed the fix/31614-folder-status-lane-event branch from 732e909 to fcff8bc Compare November 19, 2026 13:47
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased onto current main; it applied cleanly and the change itself is the same diff as before.

The red checks on the previous head were Analyze (actions) and Dependency License Gate, and both stopped on GitHub's API rate limit before they checked anything, so PR Readiness folded them in as red. Nothing in this diff caused them, so there was no code to fix: this push re-runs every check on the new head.

On the new head the related tests (473 across the hook, slot-create and folder-tag modules) and the formatting, lint and type checks pass locally, and the new test still fails with the fix reverted.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 19, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The red Backend Tests (3.12, 1) and Backend Tests (Windows) (4) on this head, and the Coverage Gate and PR Readiness that follow from them, are main's, not this PR's. Both fail one test, test/test_process_cache_floor_ratchet.py::test_every_new_module_level_cache_has_a_per_test_reset, on src/kiro_crew/subagent_persistence.py::_NOT_DUE_MEMO: #38992 added that cache, and this PR does not touch the file. Main's own push run fails the same test in the same two shards: https://github.com/kirodotdev/KiroCrew/actions/runs/44543577290

The fix is #39479 (for #39478). This PR waits for it with no push, and its failed jobs re-run once that fix lands.

@bolichen97
bolichen97 force-pushed the fix/31614-folder-status-lane-event branch from fcff8bc to f1cc4a7 Compare November 19, 2026 19:48
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/memory-skills-hooks.md and src/kiro_crew/docs/steering-and-hooks.md since this head went green (3b4e971 -> 3688176); CI re-running.

The new base carries #39479, the fix for the test/test_process_cache_floor_ratchet.py::test_every_new_module_level_cache_has_a_per_test_reset red the previous head showed on Backend Tests (3.12, 1) and Backend Tests (Windows) (4). The change itself is the same diff as before.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 19, 2026
A new chat filed into a folder copies the folder's tags. When one of
them is a status tag the session lands in that board lane, but the
create route never reached the dispatcher the two tag routes call, so
a hook keyed on entering the lane never ran for it.

The create route now dispatches the inherited change through
dispatch_session_lane_changed_bulk, after its last refusal and only
once its save has confirmed, the same placement the tag routes use.
The dispatcher's status-only diff and permit gate decide the rest.

Closes #31614
@bolichen97
bolichen97 force-pushed the fix/31614-folder-status-lane-event branch from f1cc4a7 to 88ef828 Compare November 19, 2026 23:29
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in .github/workflows/codeql.yml, .github/actions/gh-rate-limit and src/kiro_crew/dashboard/chat_api/slot_create.py since this head was pushed (3688176 -> ed4b40c); CI re-running.

The only reds on the previous head were both CodeQL Analyze jobs failing to upload results on the shared API rate limit (and PR Readiness folding them). Main has since made that upload wait for the rate-limit reset, so this rebase picks that fix up. The change itself is unchanged (identical patch); the related backend tests pass locally on the rebased head (535 passed), with black, isort, flake8 and mypy clean on the touched files.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 19, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed head 88ef828 on its merits. The create route now calls the same lane dispatcher, permit gate and confirming save that the two tag routes use. It fires only for a brand-new session that actually inherited a folder tag, and only after the create has passed its last refusal and its save has committed. The related tests pass on this head: the emitter module, the folder-create, folder-tag and tag-route suites, and the facade mirror guards. The new tests are meaningful: removing the dispatch fails the fire-once test, and removing the confirmed-save guard fails the save-failure case. The remaining ordering window against a concurrent retag is the same one the existing tag routes already have, and the event is informational, so nothing blocks.

@bolichen97
bolichen97 merged commit 26cd12d into main Nov 20, 2026
99 checks passed
@bolichen97
bolichen97 deleted the fix/31614-folder-status-lane-event branch November 20, 2026 00:56
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 20, 2026
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.

feat(hooks): fire SessionLaneChanged when a new session inherits a folder status tag

2 participants