Skip to content

fix(server): isolate Cursor metadata generation - #9914

Open
saphid wants to merge 1 commit into
pingdotgg:mainfrom
saphid:fix/v2-cursor-metadata-permissions-20260905
Open

saphid wants to merge 1 commit into
pingdotgg:mainfrom
saphid:fix/v2-cursor-metadata-permissions-20260905

Conversation

@saphid

@saphid saphid commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Cursor generates titles, branch names, commit messages, and PR text from a prompt that already contains everything it needs. Starting those ACP requests in the real project directory exposes them to project files and instructions they do not need.

Each Cursor metadata request now starts in an empty temporary workspace, and the prompt tells Cursor to use only the supplied input. This follows #4169, which did the same for Claude. Relative configured binary paths still resolve from the original project. Endpoint, environment, and model settings are unchanged. The workspace is removed after the ACP child closes, on success, failure, or cancellation. Cleanup errors are logged and ignored so they don't discard generated output. This is also why the code uses an explicit acquireRelease instead of makeTempDirectoryScoped, whose finalizer calls orDie.

This isolates the workspace; it is not an OS sandbox. Only the Cursor implementation, its tests, and the mock ACP agent's prompt-started receipt change.

Verification

Rebased onto main at 4d06156dd; no conflicts.

  • vp test run src/textGeneration/CursorTextGeneration.test.ts: 6 passed. Covers temp-workspace cwd, relative binary resolution, cleanup on success, failure, and cancellation, and output surviving a failed cleanup.
  • tsc --noEmit for apps/server: passed.
  • vp lint on the three touched files: passed.

Tests use the repo's mock ACP agent. No live Cursor run was done.

Coordination trace: T3 thread a837405b-3eae-403f-882c-f585e66419e5

Rebased and verified by Claude Opus 5 in Claude Code (via T3 Code).

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 5, 2026
Comment thread apps/server/src/textGeneration/CursorTextGeneration.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 72afcbf1b8561fb4609b6de49c8f067bb03957d7. Configure here.

Comment thread apps/server/src/textGeneration/CursorTextGeneration.ts
@macroscopeapp

macroscopeapp Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — The PR changes existing Cursor ACP behavior across four metadata-generation operations by introducing temporary workspaces, relative-binary resolution, prompt restrictions, and scoped cleanup. It also adds a line-level static-analysis suppression in the test suite, so the runtime changes and diagnostic override warrant human verification.

No code changes detected at 04bfcb7. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch 2 times, most recently from b82facd to 2ac9bfe Compare September 5, 2026 04:56
@macroscopeapp

macroscopeapp Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Macroscope has since reviewed this pull request. An earlier review was skipped by a cost limit; a review has now completed, so that notice no longer applies.

@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Sep 5, 2026
@saphid
saphid force-pushed the fix/v2-cursor-metadata-permissions-20260905 branch from a7c97c9 to fd2851c Compare September 5, 2026 05:05
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels Sep 5, 2026
Comment thread apps/server/src/textGeneration/CursorTextGeneration.ts Outdated
Comment thread apps/server/src/textGeneration/CursorTextGeneration.ts Outdated
@saphid saphid changed the title fix(server): isolate Cursor V2 metadata generation fix(server): isolate Cursor metadata generation Sep 5, 2026
@saphid
saphid changed the base branch from t3code/codex-turn-mapping to main September 5, 2026 05:19
@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

This PR is too large for Bugbot to review. It changes 99,173 lines and 4,020,811 characters. Split the change into smaller pull requests to get a review.

@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). size:M 30-99 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). size:XXL 1,000+ changed lines (additions + deletions). labels Sep 5, 2026
@saphid
saphid force-pushed the fix/v2-cursor-metadata-permissions-20260905 branch from 04bfcb7 to de8aa56 Compare September 7, 2026 07:07
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 909d0378-ce6d-4ef2-8004-f9ce50801ece

📥 Commits

Reviewing files that changed from the base of the PR and between 08c715e and de8aa56.

📒 Files selected for processing (3)
  • apps/server/scripts/acp-mock-agent.ts
  • apps/server/src/textGeneration/CursorTextGeneration.test.ts
  • apps/server/src/textGeneration/CursorTextGeneration.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Cursor ACP generation now runs in isolated temporary metadata workspaces, resolves relative binaries from the source directory, uses stricter JSON prompts, and validates cleanup during cancellation and cleanup failures.

Changes

Cursor metadata isolation

Layer / File(s) Summary
Metadata workspace lifecycle
apps/server/src/textGeneration/CursorTextGeneration.ts
runCursorJson creates and releases a temporary metadata workspace. Relative Cursor binaries resolve against the source directory. All generation call sites use sourceCwd.
Prompt contract and workspace assertions
apps/server/src/textGeneration/CursorTextGeneration.ts, apps/server/src/textGeneration/CursorTextGeneration.test.ts
The prompt requires input-only processing and JSON-only output. Tests verify the isolated cwd, relative binary handling, ACP options, and prompt ordering.
Cancellation and cleanup validation
apps/server/scripts/acp-mock-agent.ts, apps/server/src/textGeneration/CursorTextGeneration.test.ts
The mock agent atomically records prompt start. Tests verify workspace removal after cancellation and metadata preservation when cleanup fails.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TextGeneration
  participant FileSystem
  participant CursorACP
  TextGeneration->>FileSystem: Create metadata workspace
  TextGeneration->>CursorACP: Start with isolated cwd and JSON prompt
  CursorACP-->>TextGeneration: Return generated metadata
  TextGeneration->>FileSystem: Remove workspace on release
Loading

Suggested reviewers: juliusmarminge, t3dotgg

Merge Risk: ⚪ Minimal · up to de8aa

Cursor metadata generation now uses an isolated temporary workspace while preserving source-relative binary configuration and cleaning up after completion, failure, or cancellation. No concrete merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: isolating Cursor metadata generation.
Description check ✅ Passed The description explains what changed, why the change is needed, implementation details, scope limits, verification results, and the absence of UI changes. It does not use every template heading or in…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@saphid

saphid commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Independent automated first-pass review (Amp/Astra agent mode) of head de8aa56 against upstream/main: no findings. Correctness, invariants, edge cases, Effect conventions, and performance all checked; temp-workspace scoping, relative binary-path resolution, and cleanup-on-failure semantics verified sound against the source. Nothing to address, no commits pushed.

@saphid

saphid commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Friendly review nudge @juliusmarminge @maria-rcks — this is mergeable and hasn't had a maintainer pass yet. Independent bot/agent reviews have run with findings triaged in-commit (see receipts in earlier comments). Full queue context and status: #10688.

@saphid
saphid force-pushed the fix/v2-cursor-metadata-permissions-20260905 branch from de8aa56 to 4c68cf2 Compare September 11, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant