Skip to content

FIX-2344: Cursor runs work in deep checkouts - #4227

Merged
jhoffner merged 5 commits into
mainfrom
claude/project-thread-gtseuf
Oct 30, 2026
Merged

jhoffner merged 5 commits into
mainfrom
claude/project-thread-gtseuf

Conversation

@jhoffner

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

Fixes FIX-2344 (closes #4220). Bug route, no spec.

Problem

A Cursor coding run under harness-manager's normal runs folder (e.g. the Teammates lab's labs/teammates/.fsdev/teammates-runs/) failed with ENAMETOOLONG before doing any work.

Root cause (read from the installed @cursor/sdk@1.0.40): the SDK keeps per-workspace state in ~/.cursor/projects/<cwd with every run of non-alphanumerics turned into "-">, with no truncation, and also writes transcripts, MCP descriptors and so on under that folder. A harness-manager checkout is ~242 characters before its root, so the flattened name passes the 255-byte filename limit.

Fix

In @flow-state-dev/cursor, not harness-manager (the quirk is Cursor's; Codex and Claude Code run fine at that depth, and changing harness-manager's path derivation would move every existing run's checkout, branch and record):

  • src/workspace-alias.ts: when the SDK's name for cwd would pass 255 bytes, hand the SDK a short link <tmpdir>/fsd-cursor/<sha256(path)[:16]> → the real directory (a junction on Windows). The link is a function of the path, so a resumed agent gets the same link and finds its earlier state. A directory that fits is passed unchanged, so existing agents' state is untouched.
  • openAgent routes the resolved cwd through it before create/resume (covers the child-process runtime too, since that takes the same options).
  • README paragraph + a patch changeset for @flow-state-dev/cursor.

Evidence

  • Regression test with a control that fails on main (test/agent.spec.ts, "too deep"): with src/agent.ts reverted to main it fails with expected 285 to be less than or equal to 255; with the fix it passes, and resume gets the same link.
  • Real SDK test (test/installed-sdk.spec.ts): runs the installed SDK's Agent.create in a child with a temp HOME and a key the SDK refuses locally (no network). The deep path gets ENAMETOOLONG (the premise); the link gets past it to the API-key refusal, and the state folder the SDK made has exactly the name cursorProjectName predicts, so the copied naming rule is pinned to the SDK.
  • Live run (throwaway, not committed): cursorAgent with composer-2.5 and a real key, in a 268-character git checkout shaped like a harness-manager one: run completed and committed hello in the real checkout.
  • @flow-state-dev/cursor: 176/176 tests, typecheck and eslint clean.

Not done here: a Teammates-lab Cursor run on Jake's machine under the default runs folder, which is the issue's "done when".


Generated by Claude Code

Cursor's SDK keeps each workspace's state in ~/.cursor/projects/<the whole
cwd flattened into one name>, with no truncation. A harness-manager
checkout under an ordinary runs folder flattens past the 255-byte name
limit, so the run failed with ENAMETOOLONG before doing anything.

The cursor block now hands the SDK a short, deterministic link
(<tmpdir>/fsd-cursor/<digest>) to such a directory. Directories that fit
are passed unchanged, so existing agents' state stays where it was, and a
resumed agent gets the same link its first turn did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD2NbgJTWT3D3ABjSA
@jhoffner jhoffner self-assigned this Oct 30, 2026
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 30, 2026 1:00am UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 30, 2026 1:00am UTC
flow-state-dev-ui Ignored Ignored Preview Oct 30, 2026 1:00am UTC

Request Review

@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

FIX-2344

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T00:37:55.609964Z 6c0ded2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Collaborator Author

Second look + architecture pass

Verdict: the approach is right; no better shape found. Fixing it in @flow-state-dev/cursor (not in harness-manager's path derivation) is the correct altitude: the quirk is Cursor's, and moving harness-manager paths would orphan existing checkouts, branches and records. A path-derived short link keeps resume stable and leaves directories that already fit untouched. Alternatives I considered and rejected: truncating or hashing the checkout name in harness-manager (breaks existing runs), and redirecting HOME / the SDK data dir per run (loses the user's Cursor auth and settings, and doesn't address the name length). The change is small (one new file, one call site) and the single call site is the only way cwd reaches the SDK, since agent.local.cwd is already refused (agent.ts:370). No architecture refactor is warranted here; nothing in the neighbouring code is made worse.

Small items for the implementing agent to weigh (none blocking):

  1. Measure the resolved path, not the raw one (workspace-alias.ts). cursorProjectName(cwd) runs on the caller's string, while the link target uses resolve(cwd). A relative cwd flattens differently from its absolute form, so the length check can disagree with what the SDK sees. Resolving once up front and using that for both the check and the link removes the gap. The same applies to returning cwd unchanged: pass the resolved path, or keep it, but be deliberate.
  2. cwd unset isn't covered. When no cwd resolver is configured, the SDK falls back to process.cwd(), which can be just as deep, and openAgent skips the alias (workingDirectory === undefined). If that's intentionally out of scope, a one-line note in the header comment is enough.
  3. Repoint race. The EEXIST branch does readlink then unlink + symlink. Two concurrent runs hitting a wrong-target link (only possible after a hash collision or a foreign file at that name) can fail with ENOENT/EEXIST. The common case, same path to same link, is fine. Cheap to harden by tolerating ENOENT on readlink/unlink and retrying once, or by treating a non-symlink at that name (EINVAL from readlink) as a clear error rather than a raw one.
  4. The link lives in tmpdir(). If the OS reaps it (macOS and systemd-tmpfiles do), a resume recreates the same-named link, so state is still found. Worth one sentence in the README so nobody is surprised that the link is disposable, and that state lives under ~/.cursor/projects, not in the link.
  5. Copied naming rule is the fragile part. cursorProjectName mirrors an unexported SDK rule and is only pinned by installed-sdk.spec.ts at TESTED_SDK_VERSION. That test is good. It is worth noting at cursorProjectName that a bump of the pinned SDK version has to rerun it, and worth filing the unbounded name upstream with Cursor so this shim can eventually go away.
  6. Test nit: the agent.spec.ts regression test builds its path from tmpdir(); on macOS realpath differs from tmpdir() (/var vs /private/var). The test already compares through realpath, so it holds, but the 255-byte premise assertion depends on the tmpdir length. The margin (260 chars of segments) is ample.

Evidence quality is good: the control that fails on main, the real-SDK child-process test, and the live run together cover the claim. The issue's "done when" (a Teammates-lab Cursor run on Jake's machine under the default runs folder) remains open, as the PR already says.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48264ad0e3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cursor/src/workspace-alias.ts Resolved
A shared /tmp/fsd-cursor made by one account refused every other
account's links, and let its owner repoint them. The link root is now
<tmpdir>/fsd-cursor-<uid>, created 0700, and refused if it isn't a
private directory this user owns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD2NbgJTWT3D3ABjSA

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce46c46f3a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The spec chmodded the real per-user link folder, which other specs'
runs share; it now works under its own TMPDIR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD2NbgJTWT3D3ABjSA
#4198's merge dropped the README's inventory block (markers and all),
which turns the lab's inventory test red on main and every PR.
Regenerated with node scripts/inventory.mjs --write; identical to the
table before that merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD2NbgJTWT3D3ABjSA

jhoffner commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

Test (3/3) fails in @flow-state-dev/claude-code-style (test/inventory.test.ts, "README.md's inventory is out of date"). This isn't caused by this PR: main (dd353e2) fails the same way. #4198 removed the lab README's inventory table, and that removal was on purpose, since README stats tables are being dropped. #4127 fixes main by dropping the lab's table check, and it's waiting to be merged. I briefly restored the table here and then reverted that (dbdfbd5), so this PR doesn't touch the lab. Expect this one check to stay red until #4127 lands; the cursor change itself is green.


Generated by Claude Code

README stats tables are being removed on purpose; #4127 fixes main's
red inventory check by dropping the table check instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD2NbgJTWT3D3ABjSA
@jhoffner
jhoffner merged commit 9cae06b into main Oct 30, 2026
17 of 19 checks passed
@jhoffner
jhoffner deleted the claude/project-thread-gtseuf branch October 30, 2026 01:27
@jhoffner

Copy link
Copy Markdown
Collaborator Author

We are solving this for cursor but isn't this likely an issue with all harnesses and task work trees?

jhoffner added a commit that referenced this pull request Nov 2, 2026
…T_MS; fix the config header (#4368)

* FIX-2392: Teammates lab reads TEAMMATES_RUNS and TEAMMATES_RUN_TIMEOUT_MS; fix the config header

The config header said claude-code was the default harness and listed only
codex; the host defaults to cursor and takes all three. The runs folder and
the run budget could only be changed by editing the config; both are now
environment settings, and a run budget that isn't a positive whole number
stops the lab at start. The README's ENAMETOOLONG note is dropped: FIX-2344
(#4227) fixed Cursor runs in deep checkouts, so no short-path default is needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiF234bZVCmfw6uKVf1

* FIX-2392: check the run budget with harness-manager's assertPositiveInt

Reuses the package's guard, so a value past the largest timer delay also
fails at start instead of on a claimed run. Passes the budget straight
through; the host already falls back to its default on undefined.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiF234bZVCmfw6uKVf1

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

Cursor runs fail with ENAMETOOLONG under a normal harness-manager runs folder

2 participants