Skip to content

Conversation

@pepicrft
Copy link
Contributor

@pepicrft pepicrft commented Aug 12, 2025

While working on a Tuist feature that allows keeping the sources of the targets that have been replaced by binaries, I realized the Target.prune attribute was tied to a Tuist's specific use case.

I believe XcodeGraph should be generic, like middlewares like Plug are to web servers, and that we should design XcodeGraph models to be as generic as possible. Therefore, I'm marking it as deprecated. Instead, I'm going to use Target.metadata, which can play the role of holding context in memory, in the same way conn assigns do in Elixir. For example, we can use the tag tuist:prunable, to mark a target to be prunable in a way that doesn't couple the design of XcodeGraph.Target to a specific use case.

Summary by CodeRabbit

  • New Features

    • Allow run actions to specify and opt into a custom working directory for launches.
  • Refactor

    • Deprecated a target configuration flag with guidance to migrate to metadata-driven context.
    • Made target metadata editable after initialization for greater configuration flexibility.
  • Chores

    • Updated filesystem and Xcode project dependencies to newer patch/minor releases for improved compatibility.

@pepicrft pepicrft requested a review from a team August 12, 2025 16:51
@pepicrft pepicrft self-assigned this Aug 12, 2025
@pepicrft pepicrft requested review from cschmatzler and fortmarek and removed request for a team August 12, 2025 16:51
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 12, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 12, 2025

Walkthrough

Updated dependency pins in Package.resolved; marked Target.prune as deprecated and made Target.metadata mutable; added customWorkingDirectory and useCustomWorkingDirectory properties and initializer/test parameters to RunAction.

Changes

Cohort / File(s) Summary
Dependency Pins
Package.resolved
Updated originHash; bumped tuist/FileSystem from 0.11.5 (rev 23bcf23c...) to 0.11.8 (rev d2f49d5a...); bumped tuist/XcodeProj from 9.4.3 (rev 9799bb42...) to 9.5.0 (rev e1f2a436...).
XcodeGraph Target Model
Sources/XcodeGraph/Models/Target.swift
Marked public prune: Bool as deprecated with a detailed message; changed metadata from let to var to allow mutation.
RunAction Model
Sources/XcodeGraph/Models/RunAction.swift
Added public vars customWorkingDirectory: AbsolutePath? and useCustomWorkingDirectory: Bool; extended initializer and RunAction.test factory to accept and forward these parameters (defaults: nil, false).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

I nibble through commits with whiskers keen,
Pins hop forward, code fields turn green.
Prune tips a hat, metadata grows free,
RunAction finds a path where carrots be.
Thump—builds bustle under moonlit sheen. 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mutable-metadata

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@pepicrft pepicrft changed the title feat: Make Target.metadata mutable and mark prune as deprecated feat: Make Target.metadata mutable and mark Target.prune as deprecated Aug 12, 2025
@dosubot dosubot bot added the enhancement New feature or request label Aug 12, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
Sources/XcodeGraph/Models/Target.swift (1)

59-63: Clarify deprecation message wording and include a concrete migration hint

The current message says “we removed it,” while the property still exists (deprecated). It may confuse adopters. Consider rephrasing and giving a concrete tag example for migration.

Apply this diff to tighten wording:

-    @available(*, deprecated, message: """
-    The prune attribute coupled XcodeGraph to a particular use-case of Tuist and therefore
-    we removed it in favor of using metadata as an in-memory context holder that can be leveraged
-    using conventional tags.
-    """)
+    @available(*, deprecated, message: """
+    The `prune` attribute coupled XcodeGraph to a Tuist-specific use case and is deprecated.
+    Prefer encoding this intent in `metadata` using conventional tags (e.g., "tuist:prunable").
+    """)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88c9363 and c9cb275.

📒 Files selected for processing (2)
  • Package.resolved (3 hunks)
  • Sources/XcodeGraph/Models/Target.swift (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.swift

📄 CodeRabbit Inference Engine (AGENT.md)

Use Swift 6.0.3+ with StrictConcurrency enabled

Files:

  • Sources/XcodeGraph/Models/Target.swift
Sources/XcodeGraph/Models/**/*

📄 CodeRabbit Inference Engine (AGENT.md)

Core data structures like Project, Target, Scheme, and BuildConfiguration should be implemented in Sources/XcodeGraph/Models/

Files:

  • Sources/XcodeGraph/Models/Target.swift
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: SPM Test (ubuntu-22.04, 6.0.3)
  • GitHub Check: SPM Build (ubuntu-22.04, 6.0.3)
  • GitHub Check: Build
🔇 Additional comments (3)
Package.resolved (3)

2-2: Confirm lockfile change is intentional

originHash changed. If this PR’s scope is limited to model changes, consider isolating dependency resolution updates into a separate commit to simplify rollbacks and bisects.

Would you confirm that these lockfile updates are intentional and tied to the Target changes rather than incidental local resolution differences?


36-37: filesystem pin bumped to 0.11.8

Looks fine. Please ensure there are no transitive API changes affecting XcodeGraph code paths.

If helpful, I can run a repo-wide grep to spot usages that may have changed between 0.11.5 and 0.11.8.


171-172: xcodeproj pin bumped to 9.5.0

This is a relatively central dependency. Confirm no breaking changes impact consumers and that CI passes across supported Swift toolchains.

I can also prepare a small script to scan for symbols removed/renamed in new XcodeProj APIs if you’d like.

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Aug 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
Sources/XcodeGraph/Models/RunAction.swift (2)

85-87: Test factory: derive default for useCustomWorkingDirectory from customWorkingDirectory

Small ergonomics improvement: when a path is provided, default the flag to true to reduce footguns in tests.

Apply this diff to the test helper signature:

-            useCustomWorkingDirectory: Bool = false
+            useCustomWorkingDirectory: Bool? = nil

Then forward a derived value (see suggested change at Lines 103–105).


103-105: Forward derived default for useCustomWorkingDirectory in test factory

If the flag isn’t specified, infer it from the presence of a path.

Apply this diff:

-                customWorkingDirectory: customWorkingDirectory,
-                useCustomWorkingDirectory: useCustomWorkingDirectory
+                customWorkingDirectory: customWorkingDirectory,
+                useCustomWorkingDirectory: useCustomWorkingDirectory ?? (customWorkingDirectory != nil)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9cb275 and b919ac4.

📒 Files selected for processing (1)
  • Sources/XcodeGraph/Models/RunAction.swift (5 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.swift

📄 CodeRabbit Inference Engine (AGENT.md)

Use Swift 6.0.3+ with StrictConcurrency enabled

Files:

  • Sources/XcodeGraph/Models/RunAction.swift
Sources/XcodeGraph/Models/**/*

📄 CodeRabbit Inference Engine (AGENT.md)

Core data structures like Project, Target, Scheme, and BuildConfiguration should be implemented in Sources/XcodeGraph/Models/

Files:

  • Sources/XcodeGraph/Models/RunAction.swift
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: SPM Build (macos-15, 6.0.3)
  • GitHub Check: SPM Test (macos-15, 6.0.3)
  • GitHub Check: SPM Test (ubuntu-22.04, 6.0.3)
  • GitHub Check: SPM Build (ubuntu-22.04, 6.0.3)
  • GitHub Check: Build
🔇 Additional comments (1)
Sources/XcodeGraph/Models/RunAction.swift (1)

58-59: LGTM: new properties are correctly assigned

The initializer assigns the new fields as expected.

Comment on lines +21 to +22
public var customWorkingDirectory: AbsolutePath?
public var useCustomWorkingDirectory: Bool
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Default useCustomWorkingDirectory to avoid breaking Decodable; consider restricting external mutation

Adding a non-optional Bool without a default breaks backward Decoding when the key is absent. Also consider limiting write access to maintain invariants.

Apply this diff to make Decoding backward-compatible and reduce external mutation risks:

-    public var customWorkingDirectory: AbsolutePath?
-    public var useCustomWorkingDirectory: Bool
+    public internal(set) var customWorkingDirectory: AbsolutePath?
+    public internal(set) var useCustomWorkingDirectory: Bool = false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public var customWorkingDirectory: AbsolutePath?
public var useCustomWorkingDirectory: Bool
public internal(set) var customWorkingDirectory: AbsolutePath?
public internal(set) var useCustomWorkingDirectory: Bool = false
🤖 Prompt for AI Agents
In Sources/XcodeGraph/Models/RunAction.swift around lines 21–22, make
useCustomWorkingDirectory backward-compatible and less writable by giving it a
default value and restricting external mutation: change its declaration to
provide a default (e.g., = false) so Decodable won’t break when the key is
missing, and limit external write access (e.g., public private(set) var) so
callers cannot mutate it freely; also adjust any explicit initializers or
CodingKeys/Decodable init to respect the default if present.

Comment on lines +40 to +42
appClipInvocationURL: URL? = nil,
customWorkingDirectory: AbsolutePath? = nil,
useCustomWorkingDirectory: Bool = false
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard against invalid state when enabling custom working directory without a path

Ensure we don’t end up with useCustomWorkingDirectory == true and customWorkingDirectory == nil.

Add a precondition at the beginning of the initializer body:

precondition(
    !useCustomWorkingDirectory || customWorkingDirectory != nil,
    "useCustomWorkingDirectory requires customWorkingDirectory to be non-nil"
)
🤖 Prompt for AI Agents
In Sources/XcodeGraph/Models/RunAction.swift around lines 40 to 42, guard
against the invalid state where useCustomWorkingDirectory is true while
customWorkingDirectory is nil by adding a precondition at the start of the
initializer body: check that !useCustomWorkingDirectory ||
customWorkingDirectory != nil and provide a clear message like
"useCustomWorkingDirectory requires customWorkingDirectory to be non-nil".

@pepicrft pepicrft merged commit 1f0dc60 into main Aug 14, 2025
8 checks passed
@pepicrft pepicrft deleted the mutable-metadata branch August 14, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants