Repository navigation
feat(crew-log): session tree folded from every session log, nested on the System page - #11929
Conversation
|
Intent: Give the |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the [DESIGN-REVIEWED] aa60e5a |
UX Review (Fable 5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS The new Sessions footer hint fails its one job: after reading it, the blind reader still could not say which rows count toward which number. Watch
Suggestions
[UX-REVIEWED] aa60e5a |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the measured scan cost (376 ms cold / 90–120 ms warm at 4,096 units) — it is the number that licenses folding every crew log on each 5-second poll. What this change shipsInventory (10 items) — 9 justifiedIntent: show which session opened which by nesting created sessions under their creators on the Sessions tab — the reader for the
Provenance is derived, not inherited: the base [FIRST-PRINCIPLES-REVIEWED] aa60e5a |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 4.8 Review — ✅ no blocking findingsReviewed Review detailsI have thoroughly reviewed the diff. The discovery pass produced no candidates, and my own Step 2 examination of the core logic — No findings. [OPUS-REVIEWED] aa60e5a Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
cb33c96 to
2677a28
Compare
|
Disposition: fixed
|
|
Disposition: rebutted
|
|
Disposition: fixed
|
|
Disposition: fixed
|
|
Disposition: fixed
|
|
Disposition: fixed
|
|
Disposition: fixed
|
|
CI note on cb33c96: the two macOS reds are main-owned and untouched by this diff.
Neither file is in this PR. The Comment History Gate red (a "no longer" in a docstring) and the Fast Gate / Coverage Gate cascade it caused are fixed in 2677a28. |
2677a28 to
999bdcd
Compare
|
Disposition: fixed
|
|
Disposition: fixed
|
|
Backend Tests (Windows) (6) on 077d796 went red on test/test_member_memory_publication.py::test_cancelled_dashboard_request_drains_worker_before_deciding_retirement[provision-opt_in] ("request did not reach the worker"), a file this PR does not touch; the test passes locally on this head. A timing flake on the Windows shard, like the decisions-gate one two heads ago; the new head re-runs it. |
|
Disposition: fixed
|
|
Disposition: fixed
|
|
Disposition: rebutted
|
|
Disposition: rebutted
|
|
Retrospective addendum (round 16). A second span reached three rounds: d4a7deef048c, the GPT lane's tree.py docstring finding (rounds 2, 8, 16), each time a docstring restating the spec's admission semantics and drifting from it. Mechanism: prose in tree.py that restates section 6. Verdict: smaller replacement, made in the head this comment precedes: one statement in the SessionTree class docstring, pointers from records() and from the two sampler comments, no restatement elsewhere. Round-10 verdicts on every other mechanism stand (all KEEP); nothing subtracted. With this head every whole-design lane is PASS for the first time; UX's two suggestions are dispositioned above (one taken, one left to the human reviewer), and Design's "verify the real gateway once" cannot be done on this host (the pod's kiro-cli child fails on systemd-run; documented in the body), so it is left for a reviewer with a booting pod. |
|
Disposition: fixed
|
|
Disposition: rebutted
|
|
CI on 0a09bda: two Windows reds, neither from this diff. Backend Tests (Windows) (6): test/test_member_memory_publication.py::test_cancelled_dashboard_request_drains_worker_before_deciding_retirement ("request did not reach the worker"), the same timing flake as on 077d796, now red on 2 of the last 3 heads; the test passes locally and this PR does not touch that area, so it looks like a repository flake worth a look outside this PR. Build Windows Installer (x64): "Installed gateway became ready in 14.75 seconds" and then exit code 1 with no message from the ceiling step; the job was green on the two previous heads with identical packaging, and this head changed only comments, catalogs, the capture harness and one test string. The new head re-runs both. |
|
Disposition: fixed
|
|
Disposition: fixed
|
|
Disposition: rebutted
|
|
Disposition: rebutted
|
|
Disposition: rebutted
|
|
Rebased: main moved in docs/system-specs/modules/session.md, src/kiro_crew/dashboard/chat_runner.py, src/kiro_crew/dashboard/chat_utils.py (#12007) and test/test_work_ledger.py (#12008), neighbours of files this PR touches; one commit, targeted tests green on the rebased tree (312, including test_work_ledger.py); CI re-running. On a7bd77b the on-demand macOS suite went red on two tests this PR does not touch (test_theme_install.py::TestCopyInstalledTheme::test_dest_case_variant_ancestor_rejected_on_case_insensitive_fs and test_platform_log_append.py::test_concurrent_short_writers_serialize), which reads as the runner gaps #11943 tracks rather than this diff. This push also carries the round-18 dispositions above. |
|
Disposition: fixed
|
|
Disposition: fixed
|
|
Disposition: rebutted
|
|
Disposition: rebutted
|
|
Disposition: rebutted
|
|
CI on 9bc98ac: Backend Tests (3.12, 6) shows "The operation was canceled" at 12:57:17 after ten minutes of green progress dots (no failing test, no pytest timeout; the job's own limit is 60 min), and Coverage Gate failed downstream of it; nothing in this PR cancels runs on its own head, so this reads as the runner being withdrawn. The new head re-runs it. |
buluoray
left a comment
There was a problem hiding this comment.
Approving at head 5c3b0a1d. No blocking findings. The conflict needs a rebase, but it does not need a re-implementation — that distinction is the main thing I want on the record here.
The conflict is MECHANICAL and docs-only
git merge-tree --write-tree origin/main pr11929 gives exactly one content conflict. All code auto-merges — including src/kiro_crew/session_allocation.py — as do all 13 locale JSONs and the other three spec docs.
The one conflict is in docs/system-specs/modules/learn-cron-dashboard.md, where both sides edited the same giant one-line paragraph (**Sessions**: GET /api/sessions ...) around line 2349: main inserted a clause into the /api/sessions/usage sub-description, this PR inserted the parent field into /api/sessions/memory and added lineage_over_cap / lineage_cap to totals. Two independent sentence insertions into unrelated sub-clauses. Resolution is keep-both, about two minutes by hand, zero code risk.
So the CONFLICTING/DIRTY state and the 86-vs-87+ check count are fully explained by a stale docs paragraph, not by code divergence. I checked this specifically because a conflicted PR on this repo cannot have a merge ref built, which means its green checks can be pre-conflict evidence — worth distrusting by default. Here the code side is genuinely unaffected: no symbol, model or code path this PR builds on was rewritten by main.
The fold is bounded, and it does not re-read on every page load
TREE_UNIT_CAP = 4096 cuts every loop: records() uses islice(preferred, cap) for named live units and unit_dirs(..., limit=cap-len(named)) stops one candidate past the limit (if len(kept) >= max(0, limit): return kept, True). A store of a million units costs cap+1 stats rather than a walk. The SessionTree head cache is owned by the sampler for the gateway's life and validated by (segment, st_dev, st_ino, size-floor), so an untouched log costs one stat; the scan itself runs in _blocking_sample, off the event loop. Overflow is reported as a fact via over_cap → lineage_over_cap / lineage_cap, so nothing pays to count the population it declined to read.
Malformed input degrades to the pre-PR state
opened_record() returns None — a refusal — for an unreadable or non-session header, an id that does not fold back to its own directory, or any retained string past MAX_ACP_SESSION_ID_LEN / MAX_SHORT_STRING. read_head() separates torn-mid-append (unterminated and unparseable → transient, re-read) from interior damage (terminated and unparseable → final, cached once, so a planted bad line costs one read rather than one per scan). And SessionTree.snapshot() wraps fold_tree in a bare except that logs and returns {}, so a store fault degrades to "no creator known" — exactly the state before this PR. A bad log affects its own row and nothing else.
Cycle handling is fail-closed, which is the interesting case for a tree folded from untrusted-ish files: fold_tree follows an edge only when the parent has a log of its own (parent_slot in has_log), _cycle_members colours the edge graph and marks every node on a cycle so the consumer nests none of them while a hanger-on keeps its edge, and parent_payload nulls the nesting key on node.cycle or a self-citation. A forged or damaged cyclic citation cannot produce infinite nesting.
Mutations for the two load-bearing tests
test_a_cycle_marks_every_member_and_a_hanger_on_keeps_its_edge reds if you delete on_cycle |= _cycle_members(edge) in fold_tree (or make _cycle_members return set()): the A↔B cycle folds with cycle=False and assert nodes["A"].cycle is True fails. Nicely isolated — the self-cite case survives on the separate if parent_slot == slot branch, so this mutation tests only the multi-node detector.
test_units_past_the_cap_are_neither_read_nor_cached_and_the_overflow_is_reported reds if store.unit_dirs's overflow return becomes return kept, False (over_cap stays False), and reds differently if the early return is removed entirely (all three units get read, so len(reads) == 2 fails). It asserts the real read count and head-cache membership, not a call.
Both assert effects rather than call existence.
Verified clean
No new route or auth surface — this extends the existing owner-gated /api/sessions/memory payload and adds no endpoint. The whole reader sits behind KIROCREW_CREW_LOG, imported lazily in _lineage and returning ({}, False, 0) when off, and the session log lives under the OS-fenced crew-log root rather than the tool-gate-only transcript root — which is the correct side of this repo's forgeability line. session_allocation.py:_bounded_session_id carries an oversize or empty backend id as None rather than truncating, since a truncated id would name a different unit. i18n is key-symmetric across all 13 locales (the 11–14 line differences are CLDR plural categories: ja/ko/zh-CN other-only, en one/other, ru one/few/many/other) with en-XA regenerated. No literal colors in the added lines of SessionsTab.tsx or sessionRows.ts.
Not verified: the Python and Vitest suites were not executed — this was a read-only review, so the findings come from source at 5c3b0a1d plus git merge-tree, not from a test run.
One practical note: this approval will be voided by the rebase under require_last_push_approval, so re-request review after resolving that one paragraph and I will re-approve without re-reading the code, since the merge preview shows nothing else moves.
Not merging; that is the maintainer's call.
… the System page A session opened through session_create records its creator on its own session/opened entry (#11472). This adds the reader. crew_log/tree.py folds the first entry of every session log into slot -> parent edges: an orphan and a cycle degrade to root, any opened entry carrying a parent wins and one without never retracts it, the oldest log's word stands. A cached scanner reads one bounded head per log and re-reads only a replaced or removed segment. /api/sessions/memory carries `parent` per session row (slot, sid, the creator's live key, whether the sid resolves to a log), and the System page Sessions table nests a created session under its running creator the way it nests a task, to any depth. Closes #11484
|
Rebased onto main One conflict, in Verified locally on the rebased head: 887 backend tests across 13 files (tree, sampler, session memory, crew-log store, retention, projection, the crew-log MCP server, routes, session cleanup); black on the touched files with the baseline prunes intact; isort, flake8, mypy; comment-history, agent-SDK boundary, sync-io, loop-locks, feature-map and docs-lint gates; all 12 added i18n keys present in the 13 catalogs plus en-XA; |
Problem / Motivation
A session opened by another session through
session_createwrites who opened it into its own crew log (#11472). Nothing reads that record. The System page's Sessions tab lists every live session as a flat row, so a conductor and the worker it opened look like strangers. Only subagent tasks nest today.Why it matters
A person reading the Sessions tab wants "what runs under this session" in one glance. Without the edge, one crew's memory, credits and turns are scattered over unrelated rows. The
parentfield #11472 ships also has no consumer; this is the reader #11484 promised.What changed (motivation → approach → change)
A created session now sits under its creator in the Sessions tab, to any depth. A created session whose creator is not running stays a top-level row and says who opened it in visible text.
crew_log/tree.pyOSErrorafter thestat) is no verdict on the bytes:read_headraises it and the scan caches nothing for that unit, so the next scan reads it again or finds it gone. A scan admits at mostTREE_UNIT_CAP(4096) units, and the cap cuts every loop, not only what is retained: the live sessions' logs are probed first (the sampler names them by ACP session id;store.unit_dir_for, onestateach, throughislice(preferred, cap)so absent ids cost no more than the cap in probes), thenstore.unit_dirsfills the rest of the cap from the directory's own order, skipping what is already admitted, and stops one candidate past the cap. Nothing past the cap is walked, read, cached or counted; that something lies past it isSessionTree.over_cap, a fact rather than a count. Every retained string is bounded at admission (MAX_ACP_SESSION_ID_LEN,MAX_SHORT_STRING), an oversize or forged head is refused whole, and the refusal is cached. Since the live logs go first, what goes unread is closed sessions' logs, which no row on screen nests on./api/sessions/memory(session_memory.py)parent: {slot, key}: the cited creator slot, and the creator's live row key or null when it is not running. The join tries the row key, its bare slot key and the channel-bound aliasspend_slot_by_sessionsupplies, so a Slack- or cron-bound creator is found under itslinked_session_keyrow.totals.lineage_over_capsays whether the store held more session logs than the scan admits, besidetotals.lineage_cap, on every payload. The sampler hands the tree the live rows' ACP session ids, whichruntime_pidsinsession_allocation.pynow carries assid(bounded where it is retained byMAX_ACP_SESSION_ID_LEN: an oversize or empty id isNone, never truncated), so every row on screen has its log read. Typed inwebsite/src/api/client.ts.sessionRows.tsbuildTreenests a created session underparent.keythe way it nests a task, and a task under whichever session spawned it (walking the parent chain itself, so the wire carries no depth), and marks the row it placed (nested), so the table never reads placement off the row tree, where under Group by a top-level row's parent is a synthetic group row.SessionsTab.tsxscales the indent with depth and draws one guide line per ancestor level under that ancestor's expander (sorting orders each parent's children by the sorted column, so a shallow row can sit below a deeper one; the lines say what a row hangs from), labels an expander that hides sessions as such, marks task rows with a muted "task" before the name (indent alone no longer says the kind once sessions nest too), counts the rows a folded session hides beside its name, unit and memory included ("964.3MB in 4 hidden rows": sessions and tasks, where the footer's "nested" counts sessions only, and their memory summed, since the parent's own figure otherwise reads as the family's total), shows "Created by {creator} (not running, so shown top-level)" as visible text on a created row that could not be nested (under every grouping), on a second full-width line under the name that wraps rather than truncates, since a citation with its tail cut off names nobody, the parenthetical stating the consequence, not only the state; reconciles the footer's "Sessions" count with the rows on screen once any session nests ("5 (3 top-level, 2 nested)", the nested count in the value itself so "Task sessions" beside it is not read as the other half of the sum), and shows a footer stat "Stored session logs 4,096+" whilelineage_over_capis true, as an ordinary stat rather than in the warn colour (it changes nothing on the page), labelled by what it counts on disk since the strip already carries three other "session" counts, with a hint that names the cap it explains ("more than 4,096 exist", interpolated fromlineage_cap) and leads with what it means (old session logs are piling up), says every session stays listed and names the one row it can cost (a session restarted since it was opened may show as top-level: its parent lives only in its older, closed log), gives the command that lets old logs expire, prefixed with where it is typed ("in a terminal run:kirocrew config set session.archive_retention_days 30"), and says what it removes (closed sessions' logs and old saved transcripts under Archive older than the days set) and keeps (running sessions, anything newer); the Storage sweep is not named, since it moves transcripts and replay logs to the Trash and never a crew log. The Memory column's "?" says each row is its own runtime's memory, a parent's figure does not include the rows nested under it, and a group's header row under Group by is the one row that totals; the Sessions footer hint says outright that the N task sessions are a separate count, not part of this one, and that a task row is a session run as a task. Footer hints open above the strip, clear of the value they explain. The frames below come fromwebsite/scripts/capture-session-tree.mjs, one more of the repository'scapture-*.mjsharnesses (built SPA over the stubbed API).Why a fold across logs and not one more per-log projection: the edge lives on the child, because the child knows its creator at its first turn and the creator never learns the child's id, so no single log holds the tree. dsh does the same with a
parentSessionheader field on the child and a read-sideflattenLineage. The five projections still read only their own log (FR-4); the tree is a different reader and the spec says so.Why the tree reads
parent.slotand notparent.sid: a slot outlives its ACP session, and the live row a child nests under is the slot's. The sid stays in the log as an audit citation for a reader of the logs themselves; the wire does not carry it.Why a cap that says "over" and not a count: a store past the cap is a store retention is not cleaning, and the page is where someone looks when sessions are the question, so the fact is on every payload and on the page; but counting what lies past the cap would mean walking the whole population on every poll, which is the cost the cap exists to refuse, so the scan stops one candidate past it and the page says "4,096+". Why the live logs go first: the rows on screen are what the tree is folded for, so past the cap it is closed sessions' logs that go unread, not a live row's (while the live rows themselves fit in the cap; the preferred set is bounded too), and no row needs to say its creator is unknown (the per-row flag an earlier revision carried is gone).
Why visible text and not a tooltip: a keyboard or touch reader never sees a native
title, and on the top-level row of a creator that is gone that text is the only place the citation can be read. A nested row needs none: its place is the citation.The scan runs on the executor, only when
KIROCREW_CREW_LOGis on (a flag-off launch never imports the storage package); at the cap on a local disk, a cold scan of 4,096 units took 376 ms and a warm one 90-120 ms, against a 5 s poll.docs/system-specs/modules/crew-log-projection.mdgains section 6,crew-log-core.mdpoints at the reader, thedocs/feature-mapsystemrow names the Sessions plane, its files, handler and endpoint..github/black-baseline.txtdropssession_memory.py,test/test_session_memory.pyandtest/test_session_more_coverage.py, now black-clean. Eleven new strings (created_by,hidden_rowswith its plural forms, registered inpluralKeys.json,hidden_rows_memory,task_marker,expand_sessions,collapse_sessions,footer_lineage_over_capand its hint,memory_hint,footer_sessions_nestedand its hint) in everywebsite/src/i18n/localescatalog, the product name through{{productName}}; the/api/sessions/memoryrow list inlearn-cron-dashboard.mdnamesparent,totals.lineage_over_capandtotals.lineage_cap.Backwards compatibility
Compatible: one new nullable field per session row, one new boolean and one new integer in
totals, and asidonruntime_pidsrows (bounded at retention byMAX_ACP_SESSION_ID_LEN,Nonewhen oversize or absent), all on existing payloads. No entry type, header or route changes shape. With the crew log off every row readsparent: null,lineage_over_capis false, and the table is what it was.Tests
test/test_crew_log_tree.py(36): fold rules (orphan and self-cite to root, a cycle marked; the parent chain along a chain; any-with-parent and no retraction across a restart; oldest log wins; input order does not matter); scanner (an unchanged log costs no read, a replaced inode is re-read, a shorter file under the same name and inode is re-read, a torn first entry is not cached and is read once it lands, a read that fails is not cached and the next scan reads the log, a removed unit leaves the cache, a directory carrying another unit's id is refused and the refusal is cached, a damaged first entry is refused once, a retention-truncated log yields the slot with no parent, a header-only log is read again once its entry lands, a retained string past its bound refuses the whole record while an oversizeparent.sidchanges nothing because it is not read); the cap (units past it are neither read nor cached and the overflow is reported as a fact; a unit that falls past the cap is evicted so the cache never exceeds it; live units named by the caller are admitted first so past the cap only closed logs go unread, and the preferred set is itself bounded by the cap; the invariant measured: ten times the cap in absent ids costs exactly the cap in probes, a store three times the cap is examined for cap + 1 candidates, the cache never exceeds the cap); the store helpers (read_headraises on a file it cannot open;unit_dir_foranswers for a directory, not for an absent one or a linked entry;unit_dirsstops one candidate past its limit, neither lists nor counts an excluded name, and at a zero limit still says whether anything exists);parent_payloadnever nests a cycle or a row under itself.test/test_session_memory.py(+6): a child row names its live creator; a channel-bound creator is found through its slot alias; an absent creator leaveskey: null; a store past the cap setstotals.lineage_over_capbesidelineage_capwhile both live rows still fold (the closed session's log is what goes unread); no crew-log root givesnulleverywhere; flag off builds no scanner and reports false with cap 0.test/test_session_more_coverage.py(+1): aruntime_pidsrow carries the backend session id only withinMAX_ACP_SESSION_ID_LEN; an oversize, empty or absent one isNone.website/src/test/sessionRows.test.ts(+7): nesting under a creator, tasks under the nested child, arbitrary depth, an orphan stays top-level with its citation, an unknown key is ignored, cycle members become roots while a hanger-on keeps its edge, a plain session hasparent: null; the placed row carriesnested: true, its creator and a root do not.website/src/test/SessionsTab.test.tsx(+9): the orphan row shows "Created by {slot} (not running, so shown top-level)" as text and no name cell carries a "Created by" title; the orphan keeps that text under Group by, where its parent row is a group row; a nested row does not repeat its creator; a session nobody created says nothing; a folded session says "M MB in N hidden rows" beside its name as visible text; a row carries one guide line per ancestor level and a top-level row none; the session-logs stat appears only whilelineage_over_capis true, reads "4,096+", is not warn-coloured, and carries its hint; the Memory header's hint says a parent's figure does not include its nested rows; the Sessions value says how many are top-level only once one nests, with its hint.Manual verification
Real path on this host:
session_createfrom one session openedlineage-probe; its log'ssession/openedcarriesparent {slot: chat-1531-1789617025, sid: 7eefead2-...}, and the sid's own log header saysslot: chat-1531-1789617025. The frames below are the built SPA over the shared stub (website/scripts/capture-session-tree.mjs), payload shaped as the fold produces it: a conductor, the worker it opened, that worker's own worker and task, a created session whose conductor is gone, a Slack session; a third frame per theme feeds a payload whose store is past the scan's cap, since the footer stat is hidden otherwise, and a fourth opens that stat's hint. The pod could not boot on this host (its kiro-cli child fails onsystemd-run), so the frames are from the harness, not a pod.Screenshots / video
Light theme
Related Issues
Two issues opened from earlier review rounds of this PR are fixed here: the admission order past the cap (live sessions' logs are read first) and the per-poll walk of the whole store (the listing stops one candidate past the cap).
Closes #11484
Closes #11937
Closes #11956
Follow-up to #11472.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)