Repository navigation
fix(chat): persist a cleared project instead of retaining the old one - #11701
Conversation
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
1 similar comment
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- PR description:1 -- promised |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 6b9f19a |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The description declares a 7-file change including a rename; the GitHub-computed diff ships 2 files — five described files and the rename don't exist here. Not justified as shipped
What this change shipsInventory (3 items) — 2 justifiedIntent: a project cleared before a session's first message must stay cleared after restart — a FIX.
[FIRST-PRINCIPLES-REVIEWED] 6b9f19a |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
06fa444 to
c2b1957
Compare
c2b1957 to
30f8147
Compare
30f8147 to
b01d2ec
Compare
543316e to
ca3bec1
Compare
fbcfd64 to
f7b4789
Compare
f7b4789 to
27f9162
Compare
27f9162 to
d1a9a45
Compare
The metadata merge is an upsert that cannot delete a key, so writing `project` only when non-empty left the cleared directory on disk for the next restore to rebind.
d1a9a45 to
6b9f19a
Compare
…kirodotdev#11701) The metadata merge is an upsert that cannot delete a key, so writing `project` only when non-empty left the cleared directory on disk for the next restore to rebind.
Carved from #7161 under an authorised split. That PR is +12601 across 89 files; this is one
reviewable behaviour from it, cut off the current
maintip.Rescoped at
c2b19577. The previous revision also added aproject_clearedmarker,claim_cwd,CWD_CLEARED,resolved_cwdanddefault_workspace_dir. First Principles Reviewblocked it, and the finding was correct on inspection: that chain was inert in both directions —
every
project_cleared = Truewas a restore-from-disk site, so nothing ever originated themarker, and
claim_cwdhad no production reader (theruntime.pycomment assertingchat_runner: cwd=slot.claim_cwdwas false;chat_runner.pynever referenced it). All of it isremoved here. What remains is the one change that fixes a real defect, plus the rename it needs.
The five files that carried only the removed chain are now byte-identical to
main(
paths.py,state.py,chat_fork.py,channel_slots.py,spec_builder/backend/runtime.py),verified by hash rather than by diff shape.
Problem / Motivation
A forced save of a message-less slot has no transcript window to write, so it reaches disk
through
update_metadata_if— an upsert, which can add or overwrite a key but cannot deleteone.
projectwas written only when non-empty:So clearing a project left the previous directory on the metadata line, and the next restore read
it back as though the user had never cleared it.
Why it matters
This is the newborn path, not a corner case.
session_createpersistsfolder_idat birth, so anempty tab already has a metadata line, and a project set and then cleared before the first
message is persisted only by this merge. The user clears the project, restarts, and the session
rebinds the directory they removed — with relative writes landing in the former tree and nothing
to signal it.
The same function already states the invariant this violated:
projectwas simply not in that family. Its siblingmemory_storeis, and carries an equivalentcomment explaining why.
What changed
fields["project"]is now written unconditionally, joining the clearable family the merge alreadyenumerates (folder / tags / pin / title / mode / memory_store).
The full-save
meta_linepath deliberately keeps itsif slot.project:guard. That path writes acomplete replacement line, where an omitted key is already falsy-as-cleared; only the merge path
needs the explicit empty value. The asymmetry is the point, not an oversight.
loader._session_work_diris renamed tosession_default_cwd, with its call sites incli_server.pyandslack/gateway.pyupdated. The name was already imported across modulesdespite the leading underscore, which advertised a privacy it did not have. The
_session_work_dirmethods on
AcpClientandAcpRuntimeare unrelated and untouched.test/test_cleared_project_not_resurrected.pytest/test_cli_server_more_coverage.pysrc/kiro_crew/config/loader.pysrc/kiro_crew/slack/gateway.pysrc/kiro_crew/dashboard/chat_persistence.pysrc/kiro_crew/cli_server.pydocs/system-specs/modules/config.mdThe behavioural change is 2 lines of
chat_persistence.py; everything else is the rename, its docreference and tests.
Tests
test/test_cleared_project_not_resurrected.py(new) drives the real merge branch — a message-lessslot whose metadata line already names a directory, then cleared and force-saved:
if slot.project:guard fails this test with the stale directory still on disk
(
project='.../scoped'), so it detects the defect rather than merely passing.write from being a blanket blanking. Still passes under the reverted guard, so it isolates the
defect to the cleared case.
Reaching the fixed branch needs a genuinely message-less slot:
windowisslot.messages, and asave with any window takes the full-save path instead. A first attempt at this test appended a
message and silently exercised the wrong branch —
update_metadata_iffired zero times. Thecommitted version asserts
not slot.messagesas a precondition so that cannot regress unnoticed.test/test_cli_server_more_coverage.pyasserts the task runner binds the per-session default underthe taskrunner's own key, which is what makes the rename load-bearing rather than cosmetic.
Manual verification
N/A — unit coverage is sufficient.
Every failure in the local gate is pre-existing in this environment. The 12 files that failed give
87 failed / 7 errors on this branch and 87 failed / 7 errors on a pristine
upstream/mainworktree at the same tip — identical, and none of the 12 is in a module this PR touches. The cause
is environmental: a global Conventional-Commits
commit-msghook rejecting the temp-repogit commit -m 'init'fixtures those suites build.The related set for the changed modules is green: 708 passed across the persistence, fork,
spec-builder, slot-project and channel-slot suites, plus 220 across the taskrunner and
project-alias suites.
black --checkis clean on the new file — checked directly, because therepo's black gate is baselined and a newly added file is outside its scope.
check_agent_sdk_boundary,check_subprocess_encodingandcheck_sync_io_in_asyncpass. The per-file coverage gate needs afull coverage report and was not reproduced locally; that remains CI's.
Pattern harvest
Rule candidate: semgrep
Pattern: clearable field written under a truthiness guard into an upsert merge
Concretely
if <slot>.<attr>: fields["<attr>"] = <slot>.<attr>inside_fresh_fields. The mergeis an upsert, so a guarded write cannot express a clear and the stale value survives silently. The
function already documents the invariant in prose and already has a correct sibling
(
memory_store), which is precisely why a mechanical check is worth more than the comment: thisfield was added to the enumeration without anyone noticing it needed the unguarded form. A cheaper
variant of the same rule is a test-level assertion that every key in the full-save
meta_lineenumeration which is clearable also appears unguarded in
_fresh_fields.Related Issues
Carved from #7161.