Skip to content

Centralize build feature profiles in Cargo metadata#11103

Open
VitalyAnkh wants to merge 1 commit into
warpdotdev:masterfrom
VitalyAnkh:fix/10979-build-profile-matrix
Open

Centralize build feature profiles in Cargo metadata#11103
VitalyAnkh wants to merge 1 commit into
warpdotdev:masterfrom
VitalyAnkh:fix/10979-build-profile-matrix

Conversation

@VitalyAnkh
Copy link
Copy Markdown
Contributor

Summary

Fixes #10979.

This centralizes the Cargo feature matrix in app/Cargo.toml so the bundle scripts and Nix package resolve named build profiles from the same metadata instead of keeping their own stale feature lists.

  • add package.metadata.warp.build_feature_groups and package.metadata.warp.build_profiles
  • teach flake.nix to read the Nix build profile from Cargo metadata
  • update bundle/deploy/run scripts to resolve profile features through the shared helper
  • add script/check_cargo_build_profiles to validate the declared profile matrix
  • keep the review-sensitive matrix behavior intact: Windows local includes agent_mode_debug, while macOS preview stays off heap diagnostics

Validation

  • script/check_cargo_build_profiles --profile windows.local.app
  • script/check_cargo_build_profiles --profile macos.preview.app
  • script/check_cargo_build_profiles --profile macos.preview.cli
  • script/check_cargo_build_profiles --all
  • cargo metadata --format-version 1 --no-deps --locked --no-default-features --features "$features" --manifest-path app/Cargo.toml for every declared profile
  • nix eval .#warp-terminal-experimental.buildFeatures --json
  • nix eval --impure --expr 'let app = builtins.fromTOML (builtins.readFile ./app/Cargo.toml); in app.package.metadata.warp.nix.build_profile' --raw
  • nix build .#warp-terminal-experimental --no-link --print-out-paths
  • bash -n script/cargo_bundle_features.sh script/check_cargo_build_profiles script/deploy_remote_server script/deploy_remote_server_to_test_vm script/linux/bundle script/macos/bundle script/run script/wasm/bundle
  • git diff --check

@cla-bot cla-bot Bot added the cla-signed label May 16, 2026
@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label May 16, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 16, 2026

@VitalyAnkh

This PR is not linked to an issue that is marked with ready-to-implement.

Issue-state enforcement details:

Readiness check:

To continue, link this PR to a same-repo issue such as Closes #123 in the PR description, and make sure that issue has ready-to-implement.

Powered by Oz

oz-for-oss[bot]
oz-for-oss Bot previously requested changes May 16, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

@VitalyAnkh

This PR is not linked to an issue that is marked with ready-to-implement.

Issue-state enforcement details:

  • Associated same-repo issues checked: #10979

  • Required readiness label: ready-to-implement

Readiness check:

  • #10979: missing ready-to-implement; readiness labels present: none

To continue, link this PR to a same-repo issue such as Closes #123 in the PR description, and make sure that issue has ready-to-implement.

Powered by Oz

@VitalyAnkh VitalyAnkh force-pushed the fix/10979-build-profile-matrix branch 2 times, most recently from 1bfbe0f to d2d3820 Compare May 28, 2026 09:08
@acarl005
Copy link
Copy Markdown
Contributor

/oz-review

@acarl005 acarl005 self-assigned this May 29, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 29, 2026

@acarl005

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @warpdotdev/oss-maintainers.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot dismissed their stale review May 29, 2026 18:41

Oz no longer requests changes for this pull request after the latest automated review.

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR centralizes the packaging/build feature matrix in app/Cargo.toml metadata and updates the Nix and bundle scripts to resolve their Cargo features from that shared source. I did not find blocking correctness, security, or spec-alignment issues in the changed build paths.

Concerns

  • One non-blocking robustness concern: the new profile resolver should reject non-leaf profile paths instead of treating parent objects as empty feature sets.

Verdict

Found: 0 critical, 0 important, 1 suggestions

Approve with nits

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread script/cargo_build_profiles.jq Outdated

def resolve_profile($package; $profile_path):
($package.metadata.warp.build_profiles | descend($profile_path | split("."))) as $profile
| if ($profile | type) != "object" then
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.

💡 [SUGGESTION] Reject profile objects that lack base, groups, and features; as written, a parent path like linux is an object and resolves successfully to an empty feature list instead of reporting a mistyped/non-leaf profile.

@oz-for-oss oz-for-oss Bot requested review from a team and lucieleblanc and removed request for a team May 29, 2026 18:41
@lucieleblanc lucieleblanc requested review from acarl005 and removed request for lucieleblanc May 29, 2026 21:17
@VitalyAnkh VitalyAnkh force-pushed the fix/10979-build-profile-matrix branch from d2d3820 to 09868ce Compare May 30, 2026 16:43
@VitalyAnkh
Copy link
Copy Markdown
Contributor Author

Updated for the latest review suggestion.

  • Rebased the branch onto origin/master at 74d25664.
  • Added leaf-profile validation to both the jq resolver and the Nix resolver, so non-leaf profile paths like linux.preview now fail instead of resolving to an empty feature set.
  • Verified the positive profile matrix, non-leaf/missing-profile negative cases, all 34 resolved profiles through cargo metadata, shell syntax, whitespace, Nix positive eval, temporary Nix non-leaf negative eval, and nix build .#warp-terminal-experimental --no-link --print-out-paths.

nix build output for the final commit: /nix/store/qsbrg1ackm190m0bkc7cp9178dl76qll-warp-terminal-experimental-0.1.0+09868ce.

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 30, 2026

@VitalyAnkh

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR centralizes packaging/build feature profiles in app/Cargo.toml and updates Nix plus bundle/run scripts to resolve features through the shared metadata helper.

Concerns

  • No blocking correctness, security, or spec-alignment concerns found in the annotated diff.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@vkodithala vkodithala requested review from bnavetta and removed request for acarl005 June 1, 2026 17:49
Comment thread app/Cargo.toml Outdated
build_profile = "linux.oss.app"

[package.metadata.warp.build_feature_groups]
linux_app_base = [
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.

This generally makes sense, but I think we can actually cut down some of the boilerplate by getting rid of "base" groups. Most of the Cargo features here are cross-cutting, so we can put them in corresponding groups rather than repeating them across different base configurations.

For example, something like:

# Feature groups specific to the kind of artifact
app = ["release_bundle", "gui"]
cli = ["release_bundle", "standalone"]

# Feature groups for Warp-built artifacts
linux_official = ["crash_reporting"]
macos_official = ["cocoa_sentry"]

# Platform-specific features 
macos_common = ["extern_plist"]

That way, we don't need to list out all the combinations - linux_cli_base becomes ["cli", "linux_official"], and macos_app_base becomes ["app", "macos_official", "macos_common"]

This also simplifies adding new artifacts, as in #11772 - we can pick from the existing set of groups, instead of needing to add a bunch of new base group definitions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — I reworked the metadata to use composable cross-cutting groups (app, cli, platform/common groups, diagnostics groups, NLD groups, etc.) instead of the combination-style base groups. I also tightened the resolver so stale base entries are rejected rather than silently accepted.

Comment thread app/Cargo.toml Outdated
"release_bundle",
"crash_reporting",
"standalone",
"agent_mode_debug",
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.

@kevinyang372 correct me if I'm wrong, but I'm pretty sure we don't need agent_mode_debug here - it should be fine to omit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — windows.local.app now omits agent_debug / agent_mode_debug. I also re-checked the current base script/windows/bundle.ps1; the local channel does not append agent_mode_debug, while the dev channel still does.

Comment thread flake.nix Outdated
warpMetadata = appCargoToml.package.metadata.warp;
buildFeatureGroups = warpMetadata.build_feature_groups;
buildProfiles = warpMetadata.build_profiles;
nixBuildProfile =
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.

Instead of defining the build profile for Nix in app/Cargo.toml, it seems more consistent to do so here, the same way that the platform-specific build scripts construct their profiles

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — the Nix-selected profile is now defined in flake.nix as nixBuildProfile = "linux.oss.app", matching the convention that each packaging entrypoint chooses its own profile.

Comment thread flake.nix Outdated
warpMetadata.nix.build_profile
else
throw "app/Cargo.toml package.metadata.warp.nix.build_profile is missing";
uniqueFeatures =
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.

Order of Cargo features shouldn't matter, so we can use lib.lists.uniqueStrings for this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — replaced the custom Nix unique helper with lib.lists.uniqueStrings.

Comment thread flake.nix Outdated
throw "app/Cargo.toml package.metadata.warp.build_profiles.${profilePath} references undefined Cargo features: ${lib.concatStringsSep ", " missingFeatures}"
else
features;
invalidBuildProfiles =
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.

The Nix flake shouldn't need to validate all profiles

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — flake evaluation now only resolves and validates the selected Nix profile. Full-matrix validation remains in script/check_cargo_build_profiles --all.

Package scripts and Nix were drifting from app/Cargo.toml feature policy, so the build matrix now resolves named metadata profiles from the manifest. The profiles use composable cross-cutting feature groups instead of platform/artifact base groups, Nix selects its own profile path, and flake evaluation only resolves that selected profile.

Constraint: Upstream master now applies NLD v2 to preview app bundles and keeps macOS preview bundles on heap diagnostics.
Rejected: Keeping preview app profiles on nld_v1 | would regress the rebased upstream matrix.
Rejected: Dropping macOS preview heap diagnostics | would change current script/macos/bundle preview app and CLI behavior.
Rejected: Leaving feature arrays duplicated in platform scripts | would keep the stale flag failure mode from issue warpdotdev#10979.
Rejected: Keeping Nix's build profile in Cargo metadata | platform scripts construct their profile paths locally, and the review requested the same convention for Nix.
Rejected: Supporting base build-profile groups in resolvers | the review asked to get rid of base groups, so stale base entries now fail validation.
Rejected: Validating every Cargo build profile during flake evaluation | full-matrix validation belongs in script/check_cargo_build_profiles, while flake evaluation should only resolve the Nix-selected profile.
Confidence: high
Scope-risk: moderate
Directive: When adding packaging features, add reusable package.metadata.warp.build_feature_groups and compose leaf package.metadata.warp.build_profiles from groups/features only.
Tested: script/check_cargo_build_profiles --all; cargo metadata accepted 34 resolved profiles; targeted profile checks for linux.preview.app, macos.preview.app, macos.preview.cli, windows.local.app, windows.preview.app; non-leaf, missing, and unsupported base profile negative checks for script/check_cargo_build_profiles; nix eval .#warp-terminal-experimental.buildFeatures --json; temporary non-leaf nixBuildProfile negative eval; temporary unused invalid profile proves flake only resolves the selected profile while script/check_cargo_build_profiles --all catches it; nix build .#warp-terminal-experimental --no-link --print-out-paths; bash -n modified shell scripts; git diff --check
Not-tested: PowerShell parse on Windows
@VitalyAnkh VitalyAnkh force-pushed the fix/10979-build-profile-matrix branch from 09868ce to d5b117e Compare June 2, 2026 11:37
@VitalyAnkh
Copy link
Copy Markdown
Contributor Author

Updated for the latest review comments.

What changed:

  • Rebased onto origin/master at ac4225c1.
  • Reworked package.metadata.warp.build_feature_groups into composable cross-cutting groups (app, cli, platform/common groups, diagnostics groups, NLD groups, etc.) and removed the combination-style base group definitions from the matrix.
  • Removed agent_mode_debug from windows.local.app.
  • Moved the Nix-selected build profile back into flake.nix as nixBuildProfile = "linux.oss.app".
  • Replaced the custom Nix unique helper with lib.lists.uniqueStrings.
  • Scoped flake evaluation to the selected Nix profile only; full-matrix validation remains in script/check_cargo_build_profiles --all.
  • Tightened the resolvers so stale base build-profile entries are rejected instead of silently accepted.
  • Restored macOS preview heap diagnostics (jemalloc_pprof, heap_usage_tracking) after an independent pre-push review caught that dropping them would regress the current script/macos/bundle preview behavior.

Verified locally:

  • script/check_cargo_build_profiles --all (34 profiles)
  • targeted profile checks for linux.preview.app, macos.preview.app, macos.preview.cli, windows.local.app, and windows.preview.app
  • all 34 resolved profiles accepted by cargo metadata --no-default-features --features ...
  • non-leaf, missing, unsupported-base, and unused-invalid-group negative checks for the profile resolver behavior
  • nix eval .#warp-terminal-experimental.buildFeatures --json => ["gui","nld_classifier_v1","nld_heuristic_v1","release_bundle"]
  • temporary non-leaf nixBuildProfile negative eval failed as expected
  • bash -n on the modified shell scripts
  • git diff --check origin/master HEAD and git diff --check
  • nix build .#warp-terminal-experimental --no-link --print-out-paths => /nix/store/1ylb1bynjm7vm850hj7m4lcnjvpngp87-warp-terminal-experimental-0.1.0+d5b117e
  • independent gpt-5.5 xhigh pre-push review: approved with no blocking issues after the macOS preview diagnostics fix

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Jun 2, 2026

@VitalyAnkh

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

oz-for-oss[bot]
oz-for-oss Bot previously requested changes Jun 2, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR centralizes build feature profile resolution in Cargo metadata and updates Nix plus bundle/run scripts to consume those profiles.

Concerns

  • The Windows local app profile drops agent_mode_debug, which the previous script/windows/bundle.ps1 local channel path appended before building. That changes local Windows bundle behavior while the dev profile still keeps the debug feature.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread app/Cargo.toml
groups = ["cli", "macos_common"]

[package.metadata.warp.build_profiles.windows.local.app]
groups = ["app", "windows_official", "nld_v2"]
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.

⚠️ [IMPORTANT] Preserve the previous Windows local bundle behavior by including agent_debug; the old script/windows/bundle.ps1 local path appended agent_mode_debug, but this profile now omits it.

Suggested change
groups = ["app", "windows_official", "nld_v2"]
groups = ["app", "windows_official", "agent_debug", "nld_v2"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I re-checked this against the current PR base (origin/master at ac4225c1). The base script/windows/bundle.ps1 does not append agent_mode_debug for the local channel; it only appends it in the dev branch.

Base behavior:

  • local: sets WARP_BIN, BINARY_NAME, and APP_NAME, with no feature append.
  • dev: appends agent_mode_debug.
  • local / dev / preview: append the NLD v2 features afterward.

The current metadata profile resolves to:

windows.local.app=release_bundle,gui,crash_reporting,nld_classifier_v2,nld_heuristic_v2

So leaving windows.local.app without agent_debug preserves the current base behavior and matches the earlier human review note that local should be fine without agent_mode_debug. Adding agent_debug here would introduce the behavior change this comment is trying to avoid.

@VitalyAnkh
Copy link
Copy Markdown
Contributor Author

I re-checked the Windows local agent_mode_debug comment against the current PR base (origin/master at ac4225c1). The base script/windows/bundle.ps1 only appends agent_mode_debug in the dev branch, not the local branch, so the current windows.local.app profile without agent_debug preserves base behavior:

windows.local.app=release_bundle,gui,crash_reporting,nld_classifier_v2,nld_heuristic_v2

I left the code unchanged for this point because adding agent_debug would introduce the behavior change the review comment is trying to avoid, and it would also conflict with the earlier human review note that local should be fine without agent_mode_debug.

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Jun 2, 2026

@VitalyAnkh

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @acarl005.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot dismissed their stale review June 2, 2026 11:51

Oz no longer requests changes for this pull request after the latest automated review.

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR centralizes packaging feature profiles in app/Cargo.toml metadata and updates the Nix, bundle, deploy, wasm, and run scripts to resolve features from that shared metadata.

Concerns

  • No blocking correctness, security, or spec-drift concerns found in the annotated diff.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot requested a review from acarl005 June 2, 2026 11:51
@bnavetta bnavetta mentioned this pull request Jun 2, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to install warp through nix flake

3 participants