Skip to content

fix(prune): record dev-only survivors so pack after prune excludes them - #5780

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
fix-5776-prune-is-dev
Dec 2, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
fix-5776-prune-is-dev

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 3c6d5bcfc317677410242f1fc911c1a1d1246fc5

Dimension Assessment Rationale
Change confidence 9/10 ↑ Red-first cells (seed 1057546234 pinned; prune-then-pack) fail at c360772 and pass after the fix.
↑ Prune modules that touch dev status: 224 passed locally; prune/orphan unit suites: 4843 passed.
↓ The full Integration run at this head is pending.
Diagnosis confidence 9.5/10 ↑ _decide_installed_paths re-derived is_dev only for repaired or direct rows, and only when settled; seed 1057546234 keeps an alias chain fail-closed, so p5 was never re-derived.
Evidence fit 9.5/10 ↑ The seed's exact drift (p5 is_dev None -> True on the next install) reproduces at main and is gone after the fix.

Description

After apm prune, a surviving dependency that is now reachable only through dev declarations kept its production flag (is_dev unset) until the next apm install. apm pack in that window shipped it, because the exporters skip only rows marked is_dev.

Prune re-derived dev status only for rows it re-parented or repaired, and only when it kept nothing fail-closed. Now every surviving row the complete reachability walk reaches takes the dev status a fresh install records (orphans._walked_dev_status). The walk is used only when it is complete; rows prune removes are excluded. No other lockfile field changes, and install-time is_dev computation is untouched. _direct_rows, now a subset of the new rule, is removed.

Issue and approved scope

Issue: Fixes #5776

Human scope-approval comment: #5776 (comment) (scripts/governance/eligibility.cjs at main ef53e98: record-present, review contact danielmeppiel).

This PR completes the issue.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
promise: P-OWN-orphan-package-selection -- after apm prune, a surviving row records the dev status a fresh resolve records, so pack right after prune ships what it ships after the next install (source: #5776 scope record)
cell: OP=prune|pack SRC=local PRIM=skill SCOPE=project GRAPH={generated seed 1057546234, alias chain kept fail-closed}
owner: src/apm_cli/install/orphans.py (_decide_installed_paths -> rescued_dev)
instrument: today test -> test_prune_generated_local_graphs.py (seed pinned into _FIXED_SEEDS, last chunk takes it); test_prune_survivor_metadata_lifecycle.py::test_pack_right_after_prune_leaves_out_a_survivor_now_reached_only_through_dev (new); ::test_prune_keeps_a_survivors_parent_while_it_keeps_an_alias_chain (oracle: s row unchanged except is_dev: True)
decisive: pack after prune ships no s/a/z skill; seed 1057546234 converges
failing-before: red-first commit c3607727 -> seed 1057546234 "p5 is_dev None -> True"; pack shipped ['s-skill', 'z-skill']
passing-after: prune modules 23 passed, 1 xfailed; prune modules touching dev 224 passed
ledger: tests/fixtures/lifecycle_bug_ledger/bugs/5776.json

All runs used the host guard local-test.sh, sequentially:

  • APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm pytest tests/integration/test_prune_survivor_metadata_lifecycle.py tests/integration/test_prune_generated_local_graphs.py tests/integration/test_prune_multi_parent_survivor_lifecycle.py: 23 passed, 1 xfailed
  • The 7 integration modules that run prune and touch dev status: 224 passed
  • Unit modules that touch prune or orphans, plus tests/unit/install: 4843 passed
  • CI-mirror lint: ruff 0.15.12 check and format, R0801 (0 findings), YAML, file-length and relative_to guards, symlinks, auth signals, architecture boundaries, complexity, taxonomy and obligation ratchets, and tm006: all clean.

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Pin generated-graph seed 1057546234, where a survivor left reachable only
through dev keeps its production flag after prune, and add a prune-then-
pack cell: with the alias chain kept fail-closed, pack right after prune
must ship no dependency that is now dev-only.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Prune re-derived a survivor's dev status only for rows it re-parented or
repaired, and not at all while it kept a chain fail-closed. A row left
reachable only through dev declarations kept its production flag until
the next install, so apm pack in that window shipped it. Every surviving
row the complete walk reaches now takes the dev status a fresh install
records; no other lockfile field changes.

Fixes #5776

apm-spec-waiver: prune dev-flag repair on the lockfile is not normed by any OpenAPM requirement

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 2, 2026 15:06
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the prune-to-pack dependency metadata fix.

No open issues 🎉

What changed in this PR

Fixes #5776 by refreshing surviving dependencies’ dev-only status during prune, so an immediate apm pack excludes them without requiring another install.

Changes:

  • Derives survivor dev status from the complete reachability walk, including when ambiguous chains are retained.
  • Adds prune-to-pack regression coverage and pins the reported failing seed.
  • Records the regression and user-visible fix.
File Description
tests/​integration/​test_prune_survivor_metadata_lifecycle.py Tests survivor metadata and dev-only exclusion from packs.
tests/​integration/​test_prune_generated_local_graphs.py Pins the failing seed and includes it in chunked coverage.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​5776.json Records the bug and regression tests.
src/​apm_cli/​install/​orphans.py Refreshes dev status for reached survivors.
changelog.d/​5780.fixed.md Documents the prune-to-pack fix.

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 96e2f86 into main Dec 2, 2026
79 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the fix-5776-prune-is-dev branch December 2, 2026 19:22
@danielmeppiel Daniel Meppiel (danielmeppiel) mentioned this pull request Dec 2, 2026
5 of 10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] After apm prune, a dependency reachable only through dev dependencies keeps its production flag until the next install

2 participants