Skip to content

test(lifecycle): witness prune and marketplace bin cells through whole native plugins (#4894) - #4975

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
ql/cloud-4894-prune-bin-witness
Nov 23, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
ql/cloud-4894-prune-bin-witness

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The lifecycle generator rule U-BIN removed every project-scope PRIM=bin cell because it assumed bin/ never deploys at project scope. That holds for loose bin/ (exec_gate.plugin_bin_deployable), but a trusted Claude plugin that ships bin/ deploys whole to .agents/plugins/<plugin>/. So prune and marketplace reach bin/ at project scope, and four T1 cells had no witness.

Changes (test corpus only, no src/ change):

  • tests/lifecycle/generator/rules.py, bin_pin.py: U-BIN no longer removes project-scope bin cells. Its evidence covers the whole-plugin path (claude_plugins/admission.py, native_plugins/record.py, native_plugins/uninstall.py, reference/cli/prune.md) as well as plugin_bin_deployable. The pin now hashes plugin_bin_deployable, admission _UNSUPPORTED_ROOTS and PLUGINS_RELATIVE. If the pin changes, the project-scope bin cells become must-cover.

  • tests/lifecycle/generator/covering.py: covering rows no longer claim U-BIN cells. Loose bin/ in a row never deploys at project scope.

  • tests/lifecycle/machines/_gate_plugin_bin.py (new) and test_m_gate.py::test_gate_plugin_bin_spine_credits_project_scope_prune_cells: an M-GATE side-door spine drives p-native-claude-bin from git on the claude target at project scope:

    1. install --trust-bin with no executables block, undeclare, prune (GATE=none, orphan)
    2. install --trust-bin, an empty executables block turns the gate on, prune (GATE=unapproved-exec)
    3. approve, install --trust-bin, org policy denies the plugin, marketplace add (project bytes unchanged), prune (GATE=denied-dependency)

    Each retiring prune must remove every file of the plugin root (bin/ included), the plugin's enabledPlugins keys in .claude/settings.json and .github/copilot/settings.json, and its lockfile native_plugin record. It must also keep apm.yml declarations as the step left them. I1-I9 run after every step.

  • tests/lifecycle/generator/witnesses.py: registers the spine. Its deploying installs also credit pair|PRIM=bin|SCOPE=project.

  • Regenerated tests/quality/lifecycle_obligations.json. Stale comments that said bin/ never deploys at project scope now say loose bin/.

Obligation status changes (python -m tests.lifecycle.generator --counts):

Measured against main at the latest merge (after #4758 and #5012):

main this PR
required 2383 2388
known-failing 3 3
baseline 41 37
removed by U-BIN 1 0

U-BIN-OPS (pack, marketplace and bundle-install only; audit and prune stay out of BIN_LESS_OPS) and U-MCPOWN-USER from main are unchanged.

Cells credited: T1|OP=prune|PRIM=bin|GATE=none, T1|OP=prune|PRIM=bin|GATE=unapproved-exec, T1|OP=prune|PRIM=bin|GATE=denied-dependency, T1|OP=marketplace|PRIM=bin|GATE=denied-dependency (baseline -> required), and pair|PRIM=bin|SCOPE=project (removed -> required).

pair|PRIM=bin|GATE=denied-dependency moves from known-failing (#3703, a user-scope install that ignores the org deny) to required. The project-scope spine proves it, and machine witnesses take precedence in the generator. The user-scope defect stays in the ledger as a strict known failure: tests/lifecycle/scenarios/test_policy_pairs.py::test_a_denied_plugin_with_bin_is_refused_at_user_scope still runs under known_defect("#3703", ...) and still fails strictly (verified on this branch).

CLI behavior observed on main (all exit 0, matching reference/cli/prune.md): a prune after an approval is removed, after apm deny, or under an org dependencies.deny retires the plugin root (bin/ included), drops the lock record and clears both enabledPlugins keys. An orphan prune also removes the lock entry. marketplace add under the deny leaves the project unchanged. Removing the whole executables block turns the gate off, and both install and prune keep the plugin, as the gate opt-in docs describe. No product defect was found.

Issue and approved scope

Issue: Fixes #4894

Human scope-approval comment: #4894 (comment)

Does this PR complete the issue, or what remains? It completes it. --counts no longer removes the reachable project-scope bin cells, and the prune x bin gate cells have a witness that fails if prune keeps the root or bin/.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Validation evidence:

  • uv run --extra dev pytest tests/lifecycle/generator tests/quality/test_promise_obligations.py tests/quality/test_generated_obligations.py tests/quality/test_gate_cell_obligations.py tests/lifecycle/machines/test_m_gate.py::test_gate_plugin_bin_spine_credits_project_scope_prune_cells tests/lifecycle/machines/test_m_gate.py::test_gate_bin_spine_credits_user_scope_bin_cells -n 4 -> 96 passed
  • uv run --extra dev pytest tests/lifecycle/scenarios/test_policy_pairs.py::test_a_denied_plugin_with_bin_is_refused_at_user_scope -> 1 passed (strict known failure still holds)
  • Negative control: making retire_gated_native_plugins return early in a local, reverted src/ edit fails the new spine with I4: p-native-claude-bin/bin/claude still deployed but not allowed
  • uv run --extra dev python -m tests.lifecycle.generator --check -> up to date
  • uv run --extra dev python scripts/check_obligation_status_ratchet.py --base-ref origin/main -> clean
  • uv run --extra dev ruff check and ruff format --check on the changed files -> clean
  • uv run --extra dev python -m tests.quality.taxonomy --changed -> clean; scripts/check_complexity_ratchet.py --base-ref origin/main -> 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)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

…e native plugins (#4894)

U-BIN assumed bin/ never deploys at project scope, but a trusted Claude
plugin that ships bin/ deploys whole to .agents/plugins/<plugin>/. The rule
now removes no project-scope bin cell; its pin covers the whole-plugin path
(claude_plugins/admission.py _UNSUPPORTED_ROOTS, native_plugins/record.py
PLUGINS_RELATIVE) beside plugin_bin_deployable, and a changed pin makes
those cells must-cover. Covering rows no longer claim them.

A new M-GATE plugin bin spine drives p-native-claude-bin at project scope:
install --trust-bin with the gate off, then prune of the orphaned plugin
(none), prune after the gate turns on over the deployed plugin
(unapproved-exec), and, after approve and install --trust-bin, marketplace
add and prune under an org dependency deny (denied-dependency). Each prune
must remove every file of the root, bin/ included, the enabledPlugins keys
and the lockfile record.

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

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.

🟡 Changes recommended

The lifecycle tests leave pruning regressions undetected because they do not fully verify dependency and lockfile outcomes or create and check plugin declarations for both Claude and Copilot.

2 open issues
What changed in this PR

This test-only PR addresses #4894 by recognizing that trusted native plugins can deploy bin/ at project scope. It updates the lifecycle coverage generator and adds a whole-plugin witness without changing CLI behavior.

Changes:

  • Preserve project-scope bin obligations and expand U-BIN’s source pin and evidence.
  • Add lifecycle coverage for orphan and gate-driven prune, plus marketplace non-mutation.
  • Register the witness, regenerate obligations, and clarify loose-bin deployment comments.
File Description
tests/​quality/​lifecycle_obligations.json Regenerate coverage statuses, witness mappings, and U-BIN evidence.
tests/​lifecycle/​scenarios/​test_network_offline.py Clarify the loose-bin limitation in a comment.
tests/​lifecycle/​scenarios/​test_history_upgrade.py Clarify the loose-bin limitation in a comment.
tests/​lifecycle/​scenarios/​_kit.py Correct the user-scope bin-path comment.
tests/​lifecycle/​machines/​test_m_gate.py Add the project-scope plugin-bin spine test.
tests/​lifecycle/​machines/​_kit.py Clarify the loose-bin deployment comment.
tests/​lifecycle/​machines/​_gate_plugin_bin.py Add the command sequence, state checks, and coverage receipts.
tests/​lifecycle/​machines/​_gate_matrix.py Document separate whole-plugin bin coverage.
tests/​lifecycle/​machines/​_gate_bin.py Distinguish user-scope coverage from the new project spine.
tests/​lifecycle/​generator/​witnesses.py Register the spine and its project-scope deployment credits.
tests/​lifecycle/​generator/​test_generator_rules.py Test revised U-BIN classification, pins, and witnesses.
tests/​lifecycle/​generator/​rules.py Stop excluding reachable project-scope bin cells.
tests/​lifecycle/​generator/​covering.py Prevent loose-bin rows from claiming whole-plugin coverage.
tests/​lifecycle/​generator/​bin_pin.py Extend hashing to whole-plugin admission and root constants.

Review effort: Balanced

…plugin bin spine

After install the plugin must be declared in both harness settings files
(claude enabled, copilot pinned off), so the prune check sees a removal in
each. A gate-retiring prune must keep the declared dependency's lock row and
drop only its native_plugin record; an orphan prune must leave no row, and
deletes apm.lock.yaml when no dependency remains (reference/cli/prune.md).

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

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.

🔵 Needs a closer look

The scope predicate misses T1/T3 bin IDs without an explicit scope, falsely crediting coverage to a prune dry run without a deployed bin witness.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Missing project scope lets undeployed T1/T3 bins falsely cover prune obligations

tests/​lifecycle/​generator/​covering.py:441

Because u_bin_applies() requires an explicit SCOPE=project, it does not filter T1/T3 bin IDs, which omit scope. This leaves T1|OP=prune|PRIM=bin|GATE=revoked-after-deploy credited to generated_cover-01's prune --dry-run, even though its loose p-exec bin/ never deploys. Evaluate the predicate with the row's known project scope, then regenerate the replay rows and obligations so these cells are not reported as covered without a genuine bin witness.

2 resolved since last review

Review effort: Balanced

Copy link
Copy Markdown
Collaborator Author

On the "previously missed issue" in the review overview (covering rows credit T1/T3 bin cells without a deployed bin/):

This convention predates this PR and reaches past prune. Covering rows act on p-exec at project scope and credit the T1, T3 and pair cells of its bin unit for every OP. Its loose bin/ never deploys there, so those receipts prove that the command handled a package that carries bin/. They do not prove that a bin/ was deployed. That covers 79 obligations today (34 T1, 16 T3, 29 pair), including T1|OP=prune|PRIM=bin|GATE=revoked-after-deploy. This PR changes none of them.

This PR narrows only the cells U-BIN names (SCOPE=project with PRIM=bin). Only the whole-plugin path can witness those. Applying the same filter to all scope-less bin cells would move 79 required cells back to baseline and needs witnesses for each OP. That is a separate change from #4894's accepted scope, so it is left for a follow-up decision rather than folded here.

The pin-drift check replaces bin_pin.predicate_digest and observes only
classify's verdict, which is a unit seam, not a component outcome (AQ003).
It now lives in tests/lifecycle/generator/test_u_bin_seam.py. The test that
only restated bin_pin.PREDICATES is dropped.

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

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.

🔵 Needs a closer look

The bin deployment pin omits the admission function, allowing a critical deployment-admission change to leave the digest unchanged and evade the required transition check.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

High severity Plugin pin omits the bin-deploy admission function

tests/​lifecycle/​generator/​bin_pin.py:33

The whole-plugin portion of this pin covers _UNSUPPORTED_ROOTS and PLUGINS_RELATIVE, but not the admission function that decides whether bin/ deploys. Reversing elif ships_bin and skip_bin: in plan_native_claude_plugin leaves the digest equal to U_BIN_PIN, so that admission change does not trigger the must-cover transition. Include the admission function in PREDICATES, regenerate the approved digest and catalog, and add a source-mutation test for this case.

Review effort: Balanced

Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Keeps U-BIN-OPS (audit and prune stay out of BIN_LESS_OPS) and
U-MCPOWN-USER from main, the bundle, pack and render witness credits, and
this branch's whole-plugin U-BIN re-derivation and plugin bin spine. The
lifecycle obligations are regenerated once.

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

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.

🟡 Changes recommended

The pin omits whole-plugin admission logic, allowing a trusted-bin-plugin behavior change to leave the digest unchanged; planner coverage, a source-mutation regression, and updated pin and ledger values are still needed.

1 open issue

Review effort: Balanced

Comment thread tests/lifecycle/generator/bin_pin.py Resolved
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
Regenerated; the #4981 named removals now match the 127 bin cells the
filter demotes against this base.

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 99fcb48 into main Nov 23, 2026
95 of 96 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the ql/cloud-4894-prune-bin-witness branch November 23, 2026 13:52
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
bin_pin: main's element_tokens refactor plus train 6's user_org_policy_digest on it (pins unchanged). Ledger 3/1/2419: audit x bin x none and the two named #3703 removals.

Co-authored-by: Copilot App <[email protected]>
Gregory (gdelpu) pushed a commit to gdelpu/apm that referenced this pull request Nov 23, 2026
On 2026-11-23 the job took 252 s at p50, 296 s at p90 and 299 s at most
across 30 green runs, against a 300 s timeout, and about 9 runs were
cancelled at the cap (microsoft#4975, microsoft#4964, microsoft#5001, microsoft#4982). The cap moves to 10
minutes as headroom only: the scaling assertion, selection and the job's
non-required status are unchanged. The ratchet topology pin follows.

Co-authored-by: Copilot App <[email protected]>
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] Lifecycle corpus: U-BIN assumes bin/ never deploys at project scope, but whole native plugins deploy it

2 participants