Skip to content

fix(workspace-manifest-writer): respect list indentation when pruning (pnpm/pnpm#15571) - #15580

Merged
zkochan merged 3 commits into
mainfrom
fix-15571
Sep 24, 2026
Merged

zkochan merged 3 commits into
mainfrom
fix-15571

Conversation

@zkochan

@zkochan zkochan commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #15571.

When running pnpm install in a repository with minimumReleaseAgeExcludePrune: true (or trustPolicyExcludePrune: true), if pnpm-workspace.yaml contained list items indented without leading spaces (0-indent, e.g. - item), top_level_span and item_layout stopped scanning at the first 0-indent item because they treated any line with structural indentation 0 as the next top-level key. This caused:

  1. reconcile_sequence_items to fail and fall back to replace_exclude_sequence, which hardcoded 2-space indentation.
  2. top_level_span to terminate before the 0-indent items, leaving all old items behind in the file and inserting a duplicate indented entry, resulting in invalid YAML syntax errors.

This PR:

  • Distinguishes top-level mapping keys from block-sequence items at indent 0 (is_top_level_key).
  • Detects existing list item indentation (detect_sequence_indent) so both 0-indent - item and indented - item (or custom indentation) are preserved when pruning or appending entries.
  • Removes 0-indent blocks cleanly when emptied without orphaning lines.
  • Adds regression unit and CLI integration tests.

Checklist

[✓] I checked the referenced issue and verified that none of the PRs already linked to it solves it.
[✓] New features are implemented only in the Rust pnpm v12 CLI. Bug fixes are implemented in every affected version.
[✓] Added a changeset (pnpm changeset) if this PR changes any published package.
[✓] Added or updated tests.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Pruning minimumReleaseAgeExclude entries preserves existing list indentation, including zero-, two-, and four-space styles.
    • Comments and other workspace settings remain intact when entries are pruned or the list becomes empty.
    • Newly added exclude entries follow the manifest’s existing indentation style.
    • YAML document-end markers are preserved when the exclude list is updated.
    • Exclude entries for packages that are no longer present are removed.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: e44c445f-f2b2-40d3-9020-c709bdae7880

📥 Commits

Reviewing files that changed from the base of the PR and between 4e0aa08 and d5d8ebb.

📒 Files selected for processing (4)
  • pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs
  • pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs
  • pnpm/crates/workspace-manifest-writer/src/tests.rs
  • pnpm/crates/workspace-manifest-writer/src/tests/behavior.rs

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


📝 Walkthrough

Walkthrough

The workspace manifest writer now detects sequence indentation and uses it when rendering updated sequences. Exclude-list pruning and appending have test coverage for indentation variants and YAML document boundaries. A CLI regression test checks pruning with a zero-indented exclude list.

Changes

Workspace manifest sequence indentation

Layer / File(s) Summary
Sequence scanning and rendering
pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs, pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs, pnpm/crates/workspace-manifest-writer/src/edit.rs
Top-level block scanning now treats document boundaries as block boundaries while excluding sequence items. Sequence handling detects item indentation and passes it to the renderer instead of always using two spaces.
Exclude-list updates and validation
pnpm/crates/workspace-manifest-writer/src/edit/policies.rs, pnpm/crates/workspace-manifest-writer/src/tests.rs, pnpm/crates/workspace-manifest-writer/src/tests/behavior.rs, pnpm/crates/cli/tests/suite/catalog.rs, .changeset/prune-exclude-indentation.md
Exclude-list pruning uses detected indentation. Tests cover pruning, comments, empty lists, appending, list creation, and document-end markers. The CLI test covers pruning a zero-indented list, and the changeset records a patch release.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Assessment against linked issues

Objective Addressed Explanation
Respect existing minimumReleaseAgeExclude list indentation during pruning [#15571] ✅

Suggested labels: product: pacquet

Merge Risk: ⚪ Minimal · up to d5d8e

The change preserves indentation for the covered pruning and append paths, with no actionable merge risk identified.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov-commenter

codecov-commenter commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.83%. Comparing base (2ebf755) to head (d5d8ebb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15580   +/-   ##
=======================================
  Coverage   91.83%   91.83%           
=======================================
  Files        1442     1442           
  Lines      194577   194645   +68     
=======================================
+ Hits       178687   178757   +70     
+ Misses      15890    15888    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.01     14.1±1.23ms    26.5 MB/sec    1.00     14.0±1.86ms    26.8 MB/sec
packument/parse                                  1.00     41.9±1.03µs  1584.7 MB/sec    1.00     41.8±0.29µs  1586.0 MB/sec
tarball/download_dependency                      1.08      4.4±0.47ms   994.9 KB/sec    1.00      4.0±0.19ms  1072.9 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.02   212.5±10.37ms 75.3 KElem/sec    1.00    208.4±7.36ms 76.8 KElem/sec
workspace_resolution/hoist_heavy                 1.00   287.7±14.42ms        ? ?/sec    1.09   313.4±15.41ms        ? ?/sec
workspace_sort/chained_projects                  1.00     15.5±1.92ms        ? ?/sec    1.05     16.3±1.70ms        ? ?/sec

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Same-run regression check

HEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval.

Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2401.22 ms 2445.03 ms 1.8% 120.06 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1501.52 ms 1476.56 ms -1.7% 75.08 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 280.80 ms 296.60 ms 5.6% 14.04 ms Inconclusive (overlapping samples)
isolated-fresh-restore-hot-cache-hot-store pnpr 312.70 ms 329.61 ms 5.4% 15.63 ms Inconclusive (overlapping samples)
isolated-repeat-install-hot-cache-hot-store pacquet 9.62 ms 10.00 ms 3.9% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 9.67 ms 9.93 ms 2.8% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 15.50 ms 12.73 ms -17.8% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 12.33 ms 17.07 ms 38.4% 2.00 ms Inconclusive (overlapping samples)
isolated-fresh-install-cold-cache-cold-store pacquet 2672.60 ms 2695.68 ms 0.9% 133.63 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1597.38 ms 1659.53 ms 3.9% 79.87 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 593.61 ms 631.16 ms 6.3% 29.68 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pnpr 357.82 ms 347.19 ms -3.0% 17.89 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1720.84 ms 1775.47 ms 3.2% 86.04 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 320.00 ms 341.15 ms 6.6% 16.00 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pacquet 290.05 ms 312.54 ms 7.8% 14.50 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pnpr 109.38 ms 111.16 ms 1.6% 5.47 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 1150.53 ms 1378.63 ms 19.8% 57.53 ms Inconclusive (overlapping samples)
isolated-linked-workspace-resolve-hot-cache-offline pacquet 265.98 ms 275.60 ms 3.6% 13.30 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4386.48 ms 4430.87 ms 1.0% 219.32 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3493.54 ms 3500.28 ms 0.2% 174.68 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 175.94 ms 174.68 ms -0.7% 8.80 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 195.85 ms 190.66 ms -2.6% 9.79 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: d5d8ebb0c12e

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked-workspace scenario compares current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.438 ± 0.114 2.284 2.634 1.65 ± 0.17
pacquet@main 2.452 ± 0.141 2.301 2.674 1.66 ± 0.18
pnpr@HEAD 1.474 ± 0.134 1.285 1.673 1.00
pnpr@main 1.510 ± 0.174 1.309 1.720 1.02 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4375890483400005,
      "stddev": 0.11370713510294626,
      "median": 2.4450291702399998,
      "user": 1.54676848,
      "system": 1.44228832,
      "min": 2.28403487874,
      "max": 2.63397990674
    },
    {
      "command": "pacquet@main",
      "mean": 2.45216974274,
      "stddev": 0.1414860324299063,
      "median": 2.40121623724,
      "user": 1.6835953799999999,
      "system": 1.53861742,
      "min": 2.3013197187400003,
      "max": 2.6736149577400004
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.47371380734,
      "stddev": 0.1336359250639517,
      "median": 1.47656383774,
      "user": 1.19631308,
      "system": 1.21755202,
      "min": 1.2846226927400002,
      "max": 1.6731689367400002
    },
    {
      "command": "pnpr@main",
      "mean": 1.5100255318400002,
      "stddev": 0.17409136321725383,
      "median": 1.50152176724,
      "user": 1.31325898,
      "system": 1.3642130199999998,
      "min": 1.30931651174,
      "max": 1.7203964177400002
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 295.5 ± 7.2 284.7 307.3 1.05 ± 0.04
pacquet@main 282.1 ± 8.5 272.3 293.2 1.00
pnpr@HEAD 374.3 ± 83.9 297.4 514.3 1.33 ± 0.30
pnpr@main 313.1 ± 9.4 302.7 333.4 1.11 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.29551592168,
      "stddev": 0.007216788591607696,
      "median": 0.29660013558,
      "user": 0.30865724,
      "system": 0.7649151199999997,
      "min": 0.28468919508,
      "max": 0.30726731708
    },
    {
      "command": "pacquet@main",
      "mean": 0.28210124168,
      "stddev": 0.008453152037823604,
      "median": 0.28080161058,
      "user": 0.30291094,
      "system": 0.7539334199999999,
      "min": 0.27225389408,
      "max": 0.29316279308
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.37429200048,
      "stddev": 0.08391489084846877,
      "median": 0.32961171158,
      "user": 0.38161133999999997,
      "system": 0.9194714199999998,
      "min": 0.29740952208,
      "max": 0.5143415730800001
    },
    {
      "command": "pnpr@main",
      "mean": 0.31310056898000005,
      "stddev": 0.009446880627059001,
      "median": 0.31269781108,
      "user": 0.31968714,
      "system": 0.7925767199999999,
      "min": 0.30271715308,
      "max": 0.33342165708
    }
  ]
}

Scenario: Isolated linker: repeat install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 10.0 ± 1.0 8.1 13.2 1.03 ± 0.13
pacquet@main 9.7 ± 0.7 8.3 12.6 1.00
pnpr@HEAD 10.1 ± 0.9 8.3 13.8 1.04 ± 0.12
pnpr@main 9.9 ± 1.0 8.1 13.2 1.01 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.010002577746130272,
      "stddev": 0.0009913274520730602,
      "median": 0.009995733340000002,
      "user": 0.005743253793103448,
      "system": 0.004938571800766288,
      "min": 0.008053643340000001,
      "max": 0.013226046340000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.009731328419245289,
      "stddev": 0.0006919643825002007,
      "median": 0.009618007340000002,
      "user": 0.005388270792452829,
      "system": 0.005044622037735848,
      "min": 0.00827365134,
      "max": 0.012623509340000002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.010125248214551975,
      "stddev": 0.0009269085083070196,
      "median": 0.009932934340000001,
      "user": 0.005986424802867383,
      "system": 0.004866957419354841,
      "min": 0.008255631340000001,
      "max": 0.013788145340000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.009859610370508483,
      "stddev": 0.001012883290885589,
      "median": 0.00966554434,
      "user": 0.005923243389830506,
      "system": 0.004605154440677968,
      "min": 0.00810114334,
      "max": 0.013159219340000002
    }
  ]
}

Scenario: Isolated linker: repeat install, cold cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 13.2 ± 2.2 9.0 22.5 1.06 ± 0.28
pacquet@main 16.3 ± 4.1 9.7 31.9 1.30 ± 0.43
pnpr@HEAD 18.2 ± 5.6 9.9 37.0 1.45 ± 0.54
pnpr@main 12.5 ± 2.6 7.9 24.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.013201867599433979,
      "stddev": 0.0021965759100542066,
      "median": 0.012734563340000001,
      "user": 0.007788858867924528,
      "system": 0.0062325949056603784,
      "min": 0.00904387234,
      "max": 0.02254408834
    },
    {
      "command": "pacquet@main",
      "mean": 0.016284318427837844,
      "stddev": 0.00407510360218778,
      "median": 0.015500160340000001,
      "user": 0.00946596162162162,
      "system": 0.007645000810810812,
      "min": 0.00973155134,
      "max": 0.031924006340000005
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.018185737445263157,
      "stddev": 0.005564630876152453,
      "median": 0.01707137434,
      "user": 0.009662366315789473,
      "system": 0.009241167578947367,
      "min": 0.009859390340000001,
      "max": 0.036950355340000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.012500825352500003,
      "stddev": 0.0026496520432074764,
      "median": 0.012330770340000002,
      "user": 0.007915308749999999,
      "system": 0.005381823750000002,
      "min": 0.00790923634,
      "max": 0.02482621634
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.735 ± 0.111 2.604 2.893 1.70 ± 0.11
pacquet@main 2.701 ± 0.065 2.649 2.832 1.68 ± 0.09
pnpr@HEAD 1.649 ± 0.133 1.489 1.798 1.02 ± 0.10
pnpr@main 1.612 ± 0.082 1.505 1.780 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.73458254624,
      "stddev": 0.11125245485367002,
      "median": 2.69567806824,
      "user": 2.5272928599999998,
      "system": 2.2527440999999992,
      "min": 2.60443901374,
      "max": 2.8927865757399998
    },
    {
      "command": "pacquet@main",
      "mean": 2.7008670497400002,
      "stddev": 0.06462122064146066,
      "median": 2.67260360124,
      "user": 2.523444659999999,
      "system": 2.1333743000000003,
      "min": 2.64878154074,
      "max": 2.83204262274
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.64887016104,
      "stddev": 0.13334232111459746,
      "median": 1.65952530224,
      "user": 1.46885166,
      "system": 1.8021129999999999,
      "min": 1.48931017174,
      "max": 1.79810003974
    },
    {
      "command": "pnpr@main",
      "mean": 1.61161758654,
      "stddev": 0.08198263332471226,
      "median": 1.5973803207400001,
      "user": 1.67223656,
      "system": 1.8005657,
      "min": 1.50518546074,
      "max": 1.77973160774
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 667.3 ± 107.2 573.8 949.4 1.91 ± 0.31
pacquet@main 597.2 ± 55.9 531.0 681.3 1.71 ± 0.17
pnpr@HEAD 349.5 ± 10.4 336.3 367.2 1.00
pnpr@main 365.7 ± 36.7 311.7 425.3 1.05 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6673387536800002,
      "stddev": 0.10716345284325617,
      "median": 0.6311560771800001,
      "user": 0.9889273999999999,
      "system": 1.0487856599999998,
      "min": 0.5737885816800001,
      "max": 0.9494078826800001
    },
    {
      "command": "pacquet@main",
      "mean": 0.5972370585800001,
      "stddev": 0.055885161582197175,
      "median": 0.5936147921800001,
      "user": 0.8768182999999998,
      "system": 0.95244276,
      "min": 0.5310387246800001,
      "max": 0.6813443636800001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3494998743800001,
      "stddev": 0.010413015242084623,
      "median": 0.34719337618,
      "user": 0.3042573,
      "system": 0.64651006,
      "min": 0.33627599668,
      "max": 0.36717241768000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.36570070858000003,
      "stddev": 0.03666073714609945,
      "median": 0.35782111668000005,
      "user": 0.32192879999999996,
      "system": 0.65976696,
      "min": 0.31166916168000003,
      "max": 0.42534074168
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.787 ± 0.065 1.704 1.902 5.56 ± 0.29
pacquet@main 1.725 ± 0.060 1.643 1.856 5.37 ± 0.28
pnpr@HEAD 0.343 ± 0.018 0.324 0.384 1.07 ± 0.07
pnpr@main 0.322 ± 0.012 0.298 0.338 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.78666027732,
      "stddev": 0.0651205408606344,
      "median": 1.7754726667200003,
      "user": 1.20766422,
      "system": 1.05354528,
      "min": 1.70412905672,
      "max": 1.9018162517200001
    },
    {
      "command": "pacquet@main",
      "mean": 1.7251009933200003,
      "stddev": 0.06040939409805053,
      "median": 1.7208430092200002,
      "user": 1.0868861200000002,
      "system": 0.91859158,
      "min": 1.6428513297200003,
      "max": 1.8556783207200003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.34328867152000003,
      "stddev": 0.017939694699729926,
      "median": 0.34115407622000005,
      "user": 0.2994496199999999,
      "system": 0.62568858,
      "min": 0.32376206372,
      "max": 0.38368392872
    },
    {
      "command": "pnpr@main",
      "mean": 0.32154463221999996,
      "stddev": 0.012272927630734846,
      "median": 0.32000082972,
      "user": 0.27197282,
      "system": 0.5955107799999999,
      "min": 0.29817815372,
      "max": 0.33756156472000004
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 315.0 ± 16.2 293.9 344.0 2.88 ± 0.19
pacquet@main 284.0 ± 19.7 254.1 314.7 2.60 ± 0.21
pnpr@HEAD 111.7 ± 5.6 104.3 123.3 1.02 ± 0.07
pnpr@main 109.3 ± 4.5 99.1 118.5 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.31500604252,
      "stddev": 0.016158549906303332,
      "median": 0.31253718602,
      "user": 0.35142671999999997,
      "system": 0.09602356,
      "min": 0.29389174002,
      "max": 0.34401191002
    },
    {
      "command": "pacquet@main",
      "mean": 0.28403995771999996,
      "stddev": 0.019707953682313425,
      "median": 0.29004681652,
      "user": 0.31354582,
      "system": 0.08677875999999998,
      "min": 0.25407432702,
      "max": 0.31471280902
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.11174807656166669,
      "stddev": 0.005641856269582239,
      "median": 0.11115974652,
      "user": 0.047519428333333336,
      "system": 0.02124766,
      "min": 0.10430308502,
      "max": 0.12330314602
    },
    {
      "command": "pnpr@main",
      "mean": 0.10933504574000003,
      "stddev": 0.004512115130234384,
      "median": 0.10938437802,
      "user": 0.048210579999999996,
      "system": 0.017497479999999996,
      "min": 0.09913915702000001,
      "max": 0.11854016902000002
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.408 ± 0.223 1.170 1.823 1.01 ± 0.35
pacquet@main 1.394 ± 0.433 0.911 2.117 1.00
pnpm@HEAD 6.229 ± 0.858 4.992 7.468 4.47 ± 1.52
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.4076495946933332,
      "stddev": 0.2227270337974871,
      "median": 1.3786286723599999,
      "user": 1.3709470333333331,
      "system": 0.3014074111111111,
      "min": 1.16989238136,
      "max": 1.82298078736
    },
    {
      "command": "pacquet@main",
      "mean": 1.3940220290266667,
      "stddev": 0.43330547066812425,
      "median": 1.15053261336,
      "user": 1.3526715888888887,
      "system": 0.32876930000000004,
      "min": 0.91066269436,
      "max": 2.1171752053599997
    },
    {
      "command": "pnpm@HEAD",
      "mean": 6.228636088359999,
      "stddev": 0.8578013380344809,
      "median": 6.49246198436,
      "user": 8.57008781111111,
      "system": 0.5812415222222221,
      "min": 4.99179492336,
      "max": 7.46782582836
    }
  ]
}

Scenario: Isolated linker: linked-workspace resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 281.6 ± 27.7 247.9 332.0 1.00
pacquet@main 296.6 ± 55.2 248.3 393.5 1.05 ± 0.22
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.28155894902000006,
      "stddev": 0.027696164723918396,
      "median": 0.27560007412000004,
      "user": 0.23019938,
      "system": 0.11285962000000001,
      "min": 0.24791188412,
      "max": 0.33197486912
    },
    {
      "command": "pacquet@main",
      "mean": 0.29663720062000004,
      "stddev": 0.05524761076792911,
      "median": 0.26598172912000007,
      "user": 0.24993327999999998,
      "system": 0.11247681999999999,
      "min": 0.24834128012,
      "max": 0.39347746212000007
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.450 ± 0.037 4.407 4.516 1.27 ± 0.03
pacquet@main 4.489 ± 0.171 4.334 4.823 1.28 ± 0.06
pnpr@HEAD 3.503 ± 0.077 3.380 3.655 1.00
pnpr@main 3.564 ± 0.128 3.458 3.764 1.02 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.45027467432,
      "stddev": 0.03713125412591538,
      "median": 4.430870818620001,
      "user": 1.7418336599999997,
      "system": 1.60343284,
      "min": 4.40690772362,
      "max": 4.51559751362
    },
    {
      "command": "pacquet@main",
      "mean": 4.48859709512,
      "stddev": 0.17077128292375665,
      "median": 4.38647798862,
      "user": 1.7014841599999997,
      "system": 1.59848014,
      "min": 4.33412245162,
      "max": 4.82263872862
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5034567893200004,
      "stddev": 0.07707845616610108,
      "median": 3.50028405262,
      "user": 1.60039706,
      "system": 1.5044820399999996,
      "min": 3.37974824462,
      "max": 3.65542727662
    },
    {
      "command": "pnpr@main",
      "mean": 3.56444946652,
      "stddev": 0.1284300999269577,
      "median": 3.49353994462,
      "user": 1.8645137600000001,
      "system": 1.69148164,
      "min": 3.45794998562,
      "max": 3.76399353462
    }
  ]
}

Scenario: GVS linker: fresh restore, hot cache + hot store

Same install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 179.9 ± 18.4 161.5 219.3 1.03 ± 0.13
pacquet@main 174.7 ± 13.8 157.4 215.0 1.00
pnpr@HEAD 200.9 ± 22.5 179.4 260.8 1.15 ± 0.16
pnpr@main 192.0 ± 15.9 163.1 216.7 1.10 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.17992246584000002,
      "stddev": 0.018377182083330466,
      "median": 0.17467685624,
      "user": 0.2203531133333333,
      "system": 0.20101666666666668,
      "min": 0.16151094524,
      "max": 0.21933419124000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.17471890167750004,
      "stddev": 0.01383396217848675,
      "median": 0.17594085824000003,
      "user": 0.21104503000000002,
      "system": 0.21304336250000003,
      "min": 0.15738630324000003,
      "max": 0.21501042524000002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.20094104870153848,
      "stddev": 0.022480295964661404,
      "median": 0.19065968024000002,
      "user": 0.22282670307692304,
      "system": 0.22754249230769227,
      "min": 0.17942415024000002,
      "max": 0.26078529524
    },
    {
      "command": "pnpr@main",
      "mean": 0.19204595224,
      "stddev": 0.015903455617060552,
      "median": 0.19584796874000004,
      "user": 0.2215725657142857,
      "system": 0.20652829999999997,
      "min": 0.16314239424000002,
      "max": 0.21671603024000002
    }
  ]
}

@zkochan
zkochan marked this pull request as ready for review September 24, 2026 17:32
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Preserve YAML list indentation when pruning workspace exclusions

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Distinguish zero-indented sequence items from top-level YAML mapping keys.
• Preserve sequence indentation when pruning, replacing, or appending exclusion entries.
• Add unit and CLI regressions for indentation and clean block removal.
Diagram

graph TD
  A["pnpm-workspace.yaml"] --> B["Line scanner"] --> C["Exclusion policy"] --> D{"Sequence reusable?"}
  D -->|Yes| E["Item reconciliation"] --> G["Preserved manifest"]
  D -->|No| F["Indent-aware render"] --> G
Loading
High-Level Assessment

The targeted scanner and renderer changes are appropriate because they preserve the writer's comment-aware, line-level editing model while fixing the ambiguity at indentation zero. Replacing this logic with a full YAML AST round trip was considered but would be substantially broader and could introduce formatting or comment churn.

Files changed (8) +177 / -22

Bug fix (4) +68 / -22
edit.rsExpose sequence indentation and line classification helpers +7/-4

Expose sequence indentation and line classification helpers

• Wires the new sequence-indent detector and shared YAML line classifiers into the workspace manifest editing modules.

pnpm/crates/workspace-manifest-writer/src/edit.rs

policies.rsRender replacement exclusions with detected indentation +6/-4

Render replacement exclusions with detected indentation

• Detects indentation from the target sequence or another workspace sequence before replacing an exclusion block, rather than always using two spaces.

pnpm/crates/workspace-manifest-writer/src/edit/policies.rs

scanning.rsSeparate top-level keys from zero-indented sequence items +15/-3

Separate top-level keys from zero-indented sequence items

• Introduces explicit sequence-item and top-level-key classification. Top-level span discovery now includes zero-indented list items in their owning block instead of terminating early.

pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs

sequences.rsDetect and preserve block-sequence indentation +40/-11

Detect and preserve block-sequence indentation

• Updates sequence layout scanning to stop only at actual top-level keys. Adds indentation detection for preferred or neighboring sequences and parameterizes top-level sequence rendering with the detected spacing.

pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs

Tests (3) +104 / -0
catalog.rsCover zero-indented pruning through CLI install +34/-0

Cover zero-indented pruning through CLI install

• Adds an end-to-end install regression verifying that a surviving exclusion remains zero-indented and an obsolete exclusion is removed without creating invalid YAML.

pnpm/crates/cli/tests/suite/catalog.rs

tests.rsTest pruning across sequence indentation styles +33/-0

Test pruning across sequence indentation styles

• Adds regressions for zero- and four-space indentation, comment preservation, and clean removal when a zero-indented exclusion block becomes empty.

pnpm/crates/workspace-manifest-writer/src/tests.rs

behavior.rsTest indentation-preserving exclusion additions +37/-0

Test indentation-preserving exclusion additions

• Verifies appended exclusions retain zero- or four-space indentation and that newly created exclusion blocks infer zero indentation from the existing packages sequence.

pnpm/crates/workspace-manifest-writer/src/tests/behavior.rs

Documentation (1) +5 / -0
prune-exclude-indentation.mdDocument indentation-preserving exclusion pruning +5/-0

Document indentation-preserving exclusion pruning

• Adds a patch changeset for 'pacquet' describing preservation of workspace exclusion list indentation during pruning.

.changeset/prune-exclude-indentation.md

@qodo-code-review

qodo-code-review Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (3) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Tab-separated lists become invalid ✓ Resolved 🐞 Bug ≡ Correctness
Description
is_top_level_block_boundary treats a column-zero -\tvalue line as a boundary because
is_sequence_item_line recognizes only bare dashes and dash-space prefixes. When pruning or
appending policy exclusions in a tab-separated sequence, reconciliation and indentation detection
stop before the first item, so fallback replacement inserts a new block while leaving the original
items behind as invalid YAML.
Code

pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[R198-199]

+pub(super) fn is_top_level_block_boundary(content: &str) -> bool {
+    structural_indent(content) == Some(0) && !is_sequence_item_line(content)
Relevance

●●● Strong

Valid YAML parsing edge case directly undermines this PR’s scanning fix; similar parser hardening
was accepted recently.

PR-#14716

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Sequence detection accepts only - and - , while the new boundary predicate classifies every
other structural column-zero line as a boundary. The three changed scans use this predicate to
delimit reconciliation, replacement spans, and indentation discovery; failed reconciliation reaches
replace_exclude_sequence, which renders a new block using the prematurely terminated span.

pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[181-200]
pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[386-402]
pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[52-58]
pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[188-217]
pnpm/crates/workspace-manifest-writer/src/edit/policies.rs[181-203]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Valid YAML permits a tab as separation whitespace after a block-sequence dash, but the new top-level boundary predicate classifies `-\tvalue` as the end of the preceding block. Policy-list fallback replacement consequently leaves the original sequence behind and writes an invalid manifest.

## Fix Focus Areas
- pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[181-200]
- pnpm/crates/workspace-manifest-writer/src/tests/behavior.rs[333-347]

## Recommended Fix
Update `is_sequence_item_line` to recognize a dash followed by any supported YAML separation whitespace, including tabs, while continuing to reject document markers such as `---`. Add a regression test that updates a zero-indented tab-separated exclusion sequence and verifies that its items are replaced without orphaned lines or invalid YAML.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Two helper docs merely repeat names 📘 Rule violation ⚙ Maintainability ⭐ New
Description
is_sequence_item_line and is_top_level_key each have one-line documentation that only
paraphrases the helper name without recording accepted whitespace, exclusions, or caller-facing
guarantees. Because their bodies distinguish dash-space, dash-tab, document boundaries, and mapping
syntax, later changes receive no documented rationale or invariant beyond what the identifiers
already say.
Code

pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[R181-182]

+/// Whether a structural line carries a block-sequence item (`- value`).
+pub(super) fn is_sequence_item_line(content: &str) -> bool {
Relevance

●●● Strong

Nearby Rust review precedent accepted strengthening documentation for these exact sequence-scanning
helpers.

PR-#14716

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 713467 rejects comments that only restate a method name or directly inferable operation. The
comments above the two new predicates say only that they identify sequence-item lines and top-level
mapping keys, respectively.

Rule 713467: Avoid redundant comments that restate the code
pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[181-194]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Two new helper comments merely restate their function names and omit the non-obvious syntax distinctions implemented by the functions.

## Fix Focus Areas
- pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[181-194]

## Recommended Fix
Either remove the tautological comments or replace them with concise contract documentation covering accepted dash separators, excluded document boundaries, and the mapping-key conditions callers rely on.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Changeset link uses a forbidden colon 📘 Rule violation ✧ Quality ⭐ New
Description
.changeset/prune-exclude-indentation.md includes an issue URL whose https: scheme contains a
colon that introduces neither a list nor an example. Because the restriction applies throughout
changeset text, a later editor cannot classify this scheme separator as one of the convention's
permitted colon forms.
Code

.changeset/prune-exclude-indentation.md[5]

+`minimumReleaseAgeExcludePrune` now preserves existing list item indentation when pruning exclude entries in `pnpm-workspace.yaml` [pnpm/pnpm#15571](https://github.com/pnpm/pnpm/issues/15571).
Evidence
Rule 3058313 permits colons in changesets only when they introduce a list or example, while the
newly added release-note line uses one as part of https://.

Rule 3058313: Changeset text formatting conventions
.changeset/prune-exclude-indentation.md[5-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset's Markdown issue URL contains a colon that is not introducing a list or example, contrary to the changeset punctuation convention.

## Fix Focus Areas
- .changeset/prune-exclude-indentation.md[5-5]

## Recommended Fix
Replace the Markdown URL with the plain issue reference `pnpm/pnpm#15571`, preserving the release-note meaning without the disallowed colon.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Version 11 still rewrites list indents 📘 Rule violation ⌂ Architecture
Description
The v11 updateWorkspaceManifest path prunes both exclude lists through patchDocument and
Document.toString() without preserving their existing sequence indentation, while this PR adds
indentation detection only to the v12 writer. When either prune setting processes a zero- or
custom-indented list, the two supported versions produce different manifest formatting and only v12
retains the original layout.
Code

pnpm/crates/workspace-manifest-writer/src/edit/policies.rs[R198-199]

+    let indent = detect_sequence_indent(manifest.document.text(), Some(block));
+    let rendered = render_top_level_sequence(block, items, quote_style, indent);
Relevance

●●● Strong

Shared v11/v12 behavior is explicitly required, and prior v11 manifest-writer fixes were accepted.

PR-#12538

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 713428 requires shared bug fixes and regression coverage to remain observably
aligned across pnpm v11 and v12. The changed Rust path detects the existing indentation, while the
corresponding TypeScript path supports the same two prune settings but patches and serializes the
YAML document without an equivalent indentation-preservation mechanism.

Rule 713428: Keep pnpm v11 and v12 observable behavior aligned when fixing shared bugs
pnpm/crates/workspace-manifest-writer/src/edit/policies.rs[195-202]
pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[187-205]
pnpm11/workspace/workspace-manifest-writer/src/index.ts[122-161]
pnpm11/yaml/document-sync/src/patchDocument.ts[172-207]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The shared exclude-pruning settings now preserve zero and custom list indentation in the v12 writer, but the corresponding v11 path still serializes changed sequences without preserving that layout.

## Fix Focus Areas
- pnpm/crates/workspace-manifest-writer/src/edit/policies.rs[198-199]
- pnpm11/workspace/workspace-manifest-writer/src/index.ts[122-161]
- pnpm11/yaml/document-sync/src/patchDocument.ts[172-207]

## Recommended Fix
Implement equivalent indentation preservation in the v11 manifest-writing path and add v11 regression tests for zero- and custom-indented lists under both prune settings. Alternatively, explicitly document the deferred v11 implementation and its follow-up in the PR description.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View medium (1)
5. Manifest footers are silently deleted ✓ Resolved 🐞 Bug ≡ Correctness
Description
top_level_span and item_layout now stop only at recognized mapping keys, so a column-zero YAML
document-end marker such as ... is included in the preceding sequence block. When that policy
sequence is reconciled, replaced, or removed, the marker and any trailing footer content are deleted
with it.
Code

pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[386]

+        .find(|&idx| is_top_level_key(all[idx].content))
Relevance

●●● Strong

Recent workspace-manifest scanner findings protecting YAML structure and footers were accepted.

PR-#14716
PR-#14170

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
structural_indent classifies ... as a column-zero structural line, but is_top_level_key
rejects it because it has no mapping-key delimiter. The changed scans therefore run to EOF, after
which top-level replacement/removal or sequence rebuilding operates over the marker as part of the
policy block.

pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[168-192]
pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[378-395]
pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[50-75]
pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[125-154]
pnpm/crates/workspace-manifest-writer/src/edit.rs[404-420]
pnpm/crates/workspace-manifest-writer/src/edit/policies.rs[198-207]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Block scans now treat only recognized mapping keys as boundaries. Valid column-zero structural lines such as the YAML document-end marker are consequently absorbed into a preceding sequence and deleted when that sequence changes.

## Fix Focus Areas
- pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[383-386]
- pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[51-54]
- pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[207-210]

## Recommended Fix
Introduce a separate block-boundary predicate that matches any column-zero structural line except a block-sequence item. Use it when finding sequence or top-level block ends, while retaining `is_top_level_key` for locating named mapping keys.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 64 rules
✅ Skills: review-code
✅ Cross-repo context — repo relationships
Review mode: ⚖️ Balanced: This modifies YAML scanning, sequence reconciliation, and manifest-writing behavior across multiple code paths, with real correctness and compatibility risk despite the focused scope.

Grey Divider

Tip of the day
💡 Did you know, you can choose which labels appear on a finding, and whether they show icons or text

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit d5d8ebb

Results up to commit c9fe403 ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Version 11 still rewrites list indents 📘 Rule violation ⌂ Architecture
Description
The v11 updateWorkspaceManifest path prunes both exclude lists through patchDocument and
Document.toString() without preserving their existing sequence indentation, while this PR adds
indentation detection only to the v12 writer. When either prune setting processes a zero- or
custom-indented list, the two supported versions produce different manifest formatting and only v12
retains the original layout.
Code

pnpm/crates/workspace-manifest-writer/src/edit/policies.rs[R198-199]

+    let indent = detect_sequence_indent(manifest.document.text(), Some(block));
+    let rendered = render_top_level_sequence(block, items, quote_style, indent);
Relevance

●●● Strong

Shared v11/v12 behavior is explicitly required, and prior v11 manifest-writer fixes were accepted.

PR-#12538

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 713428 requires shared bug fixes and regression coverage to remain observably
aligned across pnpm v11 and v12. The changed Rust path detects the existing indentation, while the
corresponding TypeScript path supports the same two prune settings but patches and serializes the
YAML document without an equivalent indentation-preservation mechanism.

Rule 713428: Keep pnpm v11 and v12 observable behavior aligned when fixing shared bugs
pnpm/crates/workspace-manifest-writer/src/edit/policies.rs[195-202]
pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[187-205]
pnpm11/workspace/workspace-manifest-writer/src/index.ts[122-161]
pnpm11/yaml/document-sync/src/patchDocument.ts[172-207]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The shared exclude-pruning settings now preserve zero and custom list indentation in the v12 writer, but the corresponding v11 path still serializes changed sequences without preserving that layout.

## Fix Focus Areas
- pnpm/crates/workspace-manifest-writer/src/edit/policies.rs[198-199]
- pnpm11/workspace/workspace-manifest-writer/src/index.ts[122-161]
- pnpm11/yaml/document-sync/src/patchDocument.ts[172-207]

## Recommended Fix
Implement equivalent indentation preservation in the v11 manifest-writing path and add v11 regression tests for zero- and custom-indented lists under both prune settings. Alternatively, explicitly document the deferred v11 implementation and its follow-up in the PR description.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Manifest footers are silently deleted ✓ Resolved 🐞 Bug ≡ Correctness
Description
top_level_span and item_layout now stop only at recognized mapping keys, so a column-zero YAML
document-end marker such as ... is included in the preceding sequence block. When that policy
sequence is reconciled, replaced, or removed, the marker and any trailing footer content are deleted
with it.
Code

pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[386]

+        .find(|&idx| is_top_level_key(all[idx].content))
Relevance

●●● Strong

Recent workspace-manifest scanner findings protecting YAML structure and footers were accepted.

PR-#14716
PR-#14170

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
structural_indent classifies ... as a column-zero structural line, but is_top_level_key
rejects it because it has no mapping-key delimiter. The changed scans therefore run to EOF, after
which top-level replacement/removal or sequence rebuilding operates over the marker as part of the
policy block.

pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[168-192]
pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[378-395]
pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[50-75]
pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[125-154]
pnpm/crates/workspace-manifest-writer/src/edit.rs[404-420]
pnpm/crates/workspace-manifest-writer/src/edit/policies.rs[198-207]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Block scans now treat only recognized mapping keys as boundaries. Valid column-zero structural lines such as the YAML document-end marker are consequently absorbed into a preceding sequence and deleted when that sequence changes.

## Fix Focus Areas
- pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[383-386]
- pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[51-54]
- pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[207-210]

## Recommended Fix
Introduce a separate block-boundary predicate that matches any column-zero structural line except a block-sequence item. Use it when finding sequence or top-level block ends, while retaining `is_top_level_key` for locating named mapping keys.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit 4e0aa08 ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Action required
1. Tab-separated lists become invalid ✓ Resolved 🐞 Bug ≡ Correctness
Description
is_top_level_block_boundary treats a column-zero -\tvalue line as a boundary because
is_sequence_item_line recognizes only bare dashes and dash-space prefixes. When pruning or
appending policy exclusions in a tab-separated sequence, reconciliation and indentation detection
stop before the first item, so fallback replacement inserts a new block while leaving the original
items behind as invalid YAML.
Code

pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[R198-199]

+pub(super) fn is_top_level_block_boundary(content: &str) -> bool {
+    structural_indent(content) == Some(0) && !is_sequence_item_line(content)
Relevance

●●● Strong

Valid YAML parsing edge case directly undermines this PR’s scanning fix; similar parser hardening
was accepted recently.

PR-#14716

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Sequence detection accepts only - and - , while the new boundary predicate classifies every
other structural column-zero line as a boundary. The three changed scans use this predicate to
delimit reconciliation, replacement spans, and indentation discovery; failed reconciliation reaches
replace_exclude_sequence, which renders a new block using the prematurely terminated span.

pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[181-200]
pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[386-402]
pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[52-58]
pnpm/crates/workspace-manifest-writer/src/edit/sequences.rs[188-217]
pnpm/crates/workspace-manifest-writer/src/edit/policies.rs[181-203]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Valid YAML permits a tab as separation whitespace after a block-sequence dash, but the new top-level boundary predicate classifies `-\tvalue` as the end of the preceding block. Policy-list fallback replacement consequently leaves the original sequence behind and writes an invalid manifest.

## Fix Focus Areas
- pnpm/crates/workspace-manifest-writer/src/edit/scanning.rs[181-200]
- pnpm/crates/workspace-manifest-writer/src/tests/behavior.rs[333-347]

## Recommended Fix
Update `is_sequence_item_line` to recognize a dash followed by any supported YAML separation whitespace, including tabs, while continuing to reject document markers such as `---`. Add a regression test that updates a zero-indented tab-separated exclusion sequence and verifies that its items are replaced without orphaned lines or invalid YAML.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 24, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4e0aa08

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

…#15571)

When pruning `minimumReleaseAgeExclude` or `trustPolicyExclude`
entries in `pnpm-workspace.yaml`, preserve existing list item indentation
(including 0-indent `- item` and custom-indent items) instead of
rewriting them with 2-space indentation and orphaning lines.

Closes #15571.
…ers (#15571)

Stop block scans at column-zero non-sequence lines, preserving
document boundaries such as '...' and trailing footers.
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d5d8ebb

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan
zkochan merged commit ac2f045 into main Sep 24, 2026
53 checks passed
@zkochan
zkochan deleted the fix-15571 branch September 24, 2026 22:02
u9g pushed a commit to u9g/pnpm that referenced this pull request Sep 25, 2026
…pnpm#15571) (pnpm#15580)

Closes pnpm#15571.

When running `pnpm install` in a repository with `minimumReleaseAgeExcludePrune: true` (or `trustPolicyExcludePrune: true`), if `pnpm-workspace.yaml` contained list items indented without leading spaces (0-indent, e.g. `- item`), `top_level_span` and `item_layout` stopped scanning at the first 0-indent item because they treated any line with structural indentation 0 as the next top-level key. This caused:
1. `reconcile_sequence_items` to fail and fall back to `replace_exclude_sequence`, which hardcoded 2-space indentation.
2. `top_level_span` to terminate before the 0-indent items, leaving all old items behind in the file and inserting a duplicate indented entry, resulting in invalid YAML syntax errors.

This PR:
- Distinguishes top-level mapping keys from block-sequence items at indent 0 (`is_top_level_key`).
- Detects existing list item indentation (`detect_sequence_indent`) so both 0-indent `- item` and indented `  - item` (or custom indentation) are preserved when pruning or appending entries.
- Removes 0-indent blocks cleanly when emptied without orphaning lines.
- Adds regression unit and CLI integration tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minimumReleaseAgeExcludePrune: true does not respect indentation

2 participants