Repository navigation
fix: keep agent temp dirs short so mcp server sockets fit - #33378
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: every item is the fix or the docs and tests that have to follow it. The label still reaches one debug log line, so nothing is lost. Notes
What this change shipsInventory (5 items) — 4 justifiedIntent: let a socket-binding MCP server (MATLAB) start inside chats on a default data home. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 9115913 Description read[DESCRIPTION-READ] e83df097a48836dcc12fa8caf6c67d28b1b2f8da9db0ead1b310789c88389294 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. Naming each scratch directory by its random token alone fixes the socket-length overflow at its cause. The sweep and diagnostics readers don't parse the name, so they keep working. Notes
[DESIGN-REVIEWED] 9115913 Description read[DESCRIPTION-READ] 2d7f2d0534bcfc02aeabb9559e040db11fc5db36d61426c2088551f52b8ae9dd 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 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: |
|
[operator: bolichen97] Author's reasoning for the sensitive path this head touches. Sensitive change review
|
|
[operator: bolichen97] The red |
cddf741 to
217d781
Compare
|
Rebased: main moved in docs/architecture/context-management.md, docs/system-specs/modules/acp-client.md, docs/system-specs/modules/learn-cron-dashboard.md, src/kiro_crew/docs/troubleshooting.md, src/kiro_crew/sandbox_leaves.py since this head went green (2caa69b -> d2c6817); CI re-running. The new base carries #33383, which fixes the main red ( [operator: bolichen97] |
|
[operator: bolichen97] Author's reasoning for the sensitive path this head touches. Sensitive change review
|
buluoray
left a comment
There was a problem hiding this comment.
Approving. Scratch dirs are named <token8> instead of <label>-<token8>, so MCP servers that bind a Unix socket under TMPDIR (MATLAB) fit the 105-byte limit (agent_scratch.py:544, test/test_agent_scratch.py:70-79, scripts/check_acp_frame_host_data.py:52). No code reads the label back from a name, and a mutation turns the guarding test red. Static Ratchet and macOS tests are main drift.
In a chat the agent starts its MCP servers itself and they inherit the agent's scratch directory as their temp dir. That directory was named <label>-<token8>, and the label (the session key, up to 40 characters, or "runtime") pushed a server's socket path past the 105-byte limit the MATLAB MCP server enforces: always in a dedicated session, and on Windows for any username over 6 characters. Name each scratch directory by its random token alone and write the label to a debug log line instead. The token already made each name unique and each sweep single-owner, and the sweep reads owner markers, not names, so reclaiming is unchanged. The troubleshooting doc, the specs that spelled the layout and the fixture host-data check follow the new name. Part of #30271
217d781 to
9115913
Compare
|
Rebased: main moved in docs/architecture/context-management.md, docs/system-specs/modules/acp-client.md, docs/system-specs/modules/learn-cron-dashboard.md, src/kiro_crew/agent_scratch.py, src/kiro_crew/docs/troubleshooting.md, src/kiro_crew/sandbox_leaves.py since this head went green (d2c6817 -> fd5d9ef); CI re-running. The new base carries #33695, which fixes the main red ( [operator: bolichen97] |
|
[operator: bolichen97] Author's reasoning for the sensitive path this head touches. Sensitive change review
|
Problem / Motivation
Goal: An MCP server that binds a Unix socket under its temp directory starts in a chat on a default Linux or Windows data home, in a dedicated session as well as in the shared runtime.
In a chat the agent starts its MCP servers itself, and they inherit the agent's temp directory,
<data home>/scratch/<label>-<token8>. The MATLAB MCP server creates its socket up to 54 bytes below that directory and refuses a socket path over 105 bytes, so it fails withsocket path is too long: in every dedicated session (the label is the session key, up to 40 characters), and in the shared runtime on Windows for any username longer than 6 characters.Why it matters
Anyone who adds a socket-binding MCP server (MATLAB is the reported one) cannot use it in chats: Connect works through the gateway, then the same server fails in the chat. The only workaround is a Windows-only environment override or a per-server temp directory, and neither fits a shared server definition.
Not a goal
What changed (motivation → approach → change)
MCP servers that bind a Unix socket under their temp directory, such as MATLAB's, now start in chats on a default Linux or Windows data home, in dedicated sessions too. Those servers inherit the agent's scratch directory as their temp directory, and its name carried a label (the session key, up to 40 characters, or
runtime) that pushed the socket path past MATLAB's 105-byte limit.Each scratch directory is now named by its random token alone,
<data home>/scratch/<token8>, and the label goes to one debug log line at allocation. The token already made each name unique and each sweep single-owner, and the sweep reads owner markers and idle time, never names, so reclaiming is unchanged.Room left for a 54-byte socket name under MATLAB's 105-byte limit, by username length
u:/home/<u>/.kiro/crewC:\Users\<u>\.kiro\crewThe scratch troubleshooting doc now tells the shared runtime's tree apart by age, size and a live
.ownerinstead of aruntime-*name, the specs and comments that spelled the old layout (agent_scratch,sandbox_leaves.py, context management, cron temp dirs, the private-state allocation) name<token8>, and the fixture host-data check still catches a recorded scratch path in the new shape.Backwards compatibility
Compatible: directories made before the change keep their names and are swept exactly as before, and nothing reads a label back out of a name.
The name no longer carries the label. Its readers:
Reader: src/kiro_crew/agent_scratch.py:sweep_dead_scratch -- chat -- reads owner pids and idle time, never the name; TestLivenessSweep in test_agent_scratch.py
Reader: src/kiro_crew/diagnostics.py:_scratch_log_dir_name -- release -- bundle members become
kiro-chat/<token8>.log; the log text still shows which process wrote it; test_diagnostics_kiro_log_layout.pyReader: src/kiro_crew/docs/troubleshooting.md:scratch -- release -- finds the shared runtime's tree by age, size and a live
.owner(updated here)Reader: src/kiro_crew/cron_script_child_env.py:_allocate_cron_scratch -- cron -- still a fresh per-run dir under the scratch root; test_cron_run_scratch.py
Reader: src/kiro_crew/acp/harness/deepseek.py:resolve_spawn -- chat -- the probe window is found by the path its wrap received; test_a_successful_read_back_removes_its_own_probe_window
Reader: scripts/check_acp_frame_host_data.py:PATTERNS -- release -- its scratch run id pattern also matches
scratch/<token8>; test_a_scratch_dir_named_by_its_token_alone_is_caughtA person browsing
~/.kiro/crew/scratchor.quarantinecan no longer tell from the name which session made a directory. At the defaultWARNINGlog level the label is recorded nowhere; the.ownerpids and the files inside are what remain.Tests
test_name_leaves_room_for_a_unix_socket(shared runtime label, 40-character session key): the allocated directory plus the MATLAB socket name fits 105 bytes on a default Linux and Windows home. Red before: 106 bytes on Windows forruntime, 136 on Linux for a session key.test_a_scratch_dir_named_by_its_token_alone_is_caught: the fixture host-data check flags a recordedscratch/<token8>path.Proof: PROVEN test/test_acp_frame_host_data.py::test_a_scratch_dir_named_by_its_token_alone_is_caught, test/test_agent_scratch.py::TestAllocate::test_name_leaves_room_for_a_unix_socket[runtime], test/test_agent_scratch.py::TestAllocate::test_name_leaves_room_for_a_unix_socket[agent:main:dashboard:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] (head 9115913)
Determinism: the 10 added or changed test ids ran 20 times at
-n0and 10 times at-n 4 --dist loadgroupbesidetest_overload_home_fence.pyandtest_diagnostics_kiro_log_layout.py, all green, plus one shuffled order (seed 17459), green.Manual verification
N/A — the change is a path name, and the test measures the path the allocator really creates; no socket-binding MCP server runs in CI.
Related Issues
Part of #30271
Builds on #30443.
Sibling sweep
Swept: git grep -nE ""TMPDIR"" -- src/
Sibling: src/kiro_crew/mcp_gateway/backend_tmp.py:158 -- tracked in #30271
Sibling: src/kiro_crew/dashboard/handlers/office_slides.py:673 -- not affected -- a document converter's work dir, it starts no MCP server
Sibling: src/kiro_crew/dashboard_verify.py:933 -- not affected -- a browser profile dir for the verifier, it starts no MCP server
Pattern harvest
Not generalizable: the only budget at stake is what a third-party server appends below a temp dir we hand it, and the two places that hand an MCP server one (agent scratch, the gateway's managed temp) are both covered by a length test.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)