Skip to content

test(lifecycle): observe project-scope native plugin roots and declarations (#4808) - #4843

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
cloud-4808-native-plugin-observation
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
cloud-4808-native-plugin-observation

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Scenario.deployed() did not observe a project-scope native plugin, and projected_cells() dropped its gated native cell. So a scenario passed when an allowed plugin was never deployed or declared, and when a denied plugin stayed active.

This PR changes the lifecycle scenario kit only:

  • projected_cells() now keeps the gated native cell of a plugin installed whole ([FEATURE] Native plugins at project scope for Claude and Copilot #3921: p-native-claude* for claude/copilot at project scope). It still drops the plugin's loose kinds, so the existing check that loose copies are absent stays.
  • Scenario.deployed() observes that cell per target from two parts: the root .agents/plugins/<name>/.claude-plugin/plugin.json and the target's enabledPlugins declaration (.claude/settings.json or .github/copilot/settings.json). Either part makes the cell observed, so a denied plugin left active fails I4. The root counts as a managed path, so I1 also checks it against the lock's native fingerprint.
  • After each successful install or update (not dry-run), every allowed native cell must have both parts (Scenario.native_gaps). Only APM's <plugin>@apm-p-* key counts as the declaration. If the settings file holds declared user bytes, only the root is required. A plugin that ships bin/ must be whole only on a --trust-bin step; without trust it is parked whole.
  • New scenario test_a_native_plugin_is_one_gated_cell_at_project_scope (claude + copilot, kinds native/skill/mcp so loose copies are observed): install, approve, install, then deny and install.
  • New scenario test_a_native_plugin_with_bin_deploys_whole_only_when_trusted: an approved plugin that ships bin/ is parked until install --trust-bin deploys it whole.

Issue and approved scope

Issue: Fixes #4808

Human scope-approval comment: #4808 (comment)

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)

Red first. I simulated each product defect with a temporary, uncommitted edit to src/apm_cli/claude_plugins/registrar.py, then ran these nodes:
test_ownership_siblings.py::test_a_native_plugin_is_one_gated_cell_at_project_scope and test_network_offline.py::test_native_plugin_works_offline.

Simulated defect kit on origin/main kit in this PR
A: allowed plugin never declared (write_declaration replaced by a preview) 2 passed (gap) 2 failed: install: allowed native plugins not whole: ["p-native-claude/native/claude: found ['.agents/plugins/p-native-claude/.claude-plugin/plugin.json']", ...]
B: denied plugin left active (_retire returns False) 2 passed (gap) new scenario fails: I1 ... deployed file is not in the lock: .agents/plugins/p-native-claude/.claude-plugin/plugin.json and I4 ... p-native-claude/native/... still deployed but not allowed

Without a simulated defect, both nodes pass with this PR's kit.

Validation commands, with results:

  • uv run --extra dev pytest tests/lifecycle/scenarios -n 2 -p no:cacheprovider -q -> 265 passed, 2 skipped (at head)
  • uv run --extra dev pytest tests/quality/test_promise_obligations.py tests/quality/test_scenario_refusal_credit.py -q -> 40 passed
  • Negative controls for the bin/ rule: with trust forced on, the untrusted install fails allowed native plugins not whole: ["p-native-claude-bin/native/claude: found [] .... With defect A, the --trust-bin install fails the same check.
  • uv run --extra dev python -m tests.lifecycle.generator --check -> [+] generated lifecycle obligations are up to date
  • ruff check and ruff format --check (ruff 0.15.12, CI paths) -> clean
  • pylint R0801 -> 10.00/10
  • bash scripts/lint-auth-signals.sh -> clean
  • scripts/check_complexity_ratchet.py --base-ref origin/main -> clean
  • python -m tests.quality.taxonomy --changed -> [+] tm006: 1 changed test module(s) carry their marker and promise
promise: P-INV-I4 -- a deny never increases what is deployed; the next mutating command removes what is no longer allowed (source: .agents/skills/apm-lifecycle-tests)
cell: OP=install SRC=native-plugin PRIM=native SCOPE=project TGT=multi GATE=denied-after-deploy   owner: claude_plugins/registrar.py
instrument: target scenario -> tests/lifecycle/scenarios/test_ownership_siblings.py::test_a_native_plugin_is_one_gated_cell_at_project_scope (new: no scenario covered a project-scope native deny)
oracles: [I1, I4, native whole-cell]  decisive: Scenario.native_gaps / I4 on p-native-claude/native/<target>
failing-before: simulated defects A/B on the main kit -> 2 passed (gap)
passing-after: same nodes on this kit -> pass; with A/B -> fail
guard+mutation: n/a     ledger: n/a (gap in the test oracle, not a product defect)
hints executed: none printed

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.

…ations (#4808)

Scenario.deployed() now observes each Claude-format plugin installed whole
at project scope as one gated native cell per target: its root under
.agents/plugins and the target's enabledPlugins declaration. projected_cells()
keeps that native cell while still dropping loose copies. A successful
install must leave every allowed native cell whole; a denied plugin left
active fails I4.

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 can accept unrelated plugin declarations, reject correctly preserved user disables, and miss unintended loose skill or MCP copies because of incomplete fixture coverage.

3 open issues
What changed in this PR

This PR strengthens the lifecycle scenario kit’s checks for project-scope native plugins in Claude and Copilot, addressing the test-oracle gap in #4808 without changing production behavior.

Changes:

  • Retains gated native cells while excluding loose plugin components from expected deployment.
  • Observes plugin roots and target declarations, and checks completeness after successful installs and updates.
  • Adds an approval-to-denial scenario covering both targets.
File Description
tests/​lifecycle/​scenarios/​test_ownership_siblings.py Adds a project-scope native plugin approval and denial scenario.
tests/​lifecycle/​scenarios/​_kit.py Adds native-cell projection, root and declaration observation, and completeness checks.

Review effort: Balanced

Comment thread tests/lifecycle/scenarios/_kit.py Resolved
Comment thread tests/lifecycle/scenarios/_kit.py Resolved
…bserve loose kinds (#4808)

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 tests incorrectly require native deployment without bin trust even when parking is valid, and the oracle accepts truthy non-boolean enable values that violate the settings contract.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Require native plugin enable values to be the boolean true

tests/​lifecycle/​scenarios/​_kit.py:142

This accepts any truthy enable value, not just the JSON boolean true required by the native settings contract (src/apm_cli/native_plugins/settings.py:9). For example, an owned key with the string value "false" is observed as enabled, so native_gaps() passes when the root exists even though the plugin has no valid enabled declaration. Compare the value with True explicitly so malformed declarations cannot satisfy the whole-cell oracle.

3 resolved since last review

Review effort: Balanced

Comment thread tests/lifecycle/scenarios/_kit.py Resolved

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 scenario helper raises on malformed settings before running the CLI, preventing tests from validating invalid-settings refusal and byte preservation.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Malformed plugin settings abort pre-command scenario observation

tests/​lifecycle/​scenarios/​_kit.py:140

With a native package in the scenario, malformed user settings (for example, {broken, or a nonempty list for enabledPlugins) now make the pre-command observation raise JSONDecodeError or AttributeError. Consequently, Scenario.run(..., exit=1) cannot exercise the CLI's supported invalid-settings refusal and byte-preservation behavior (native_plugins/settings.py::read_settings and _section), because the command never runs. Treat malformed or non-object settings as no observed declaration, allowing the exit-code and I1 checks to validate the refusal.

1 resolved since last review

Review effort: Balanced

@danielmeppiel Daniel Meppiel (danielmeppiel) added the full-integration Run the full integration suite (ci-integration.yml) on this PR before merge label Nov 22, 2026 — with Copilot SWE Agent
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 549437d into main Nov 22, 2026
89 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the cloud-4808-native-plugin-observation branch November 22, 2026 23:59
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
… regenerate

Keeps #4843's native observation (a root half plus the enabledPlugins declaration half, native_gaps). Builds _surface_hits on train 5's entry-aware surfaces (JsonEntry, MergedHooks) and _observable. projected_cells keeps #4843's native projection plus the shared-root loose skill (#4559). #4751 fixed #4744, so the user-scope bin target-change cell drops its strict known and is required (known 9 -> 8, L15).

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

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Lifecycle scenarios do not observe project-scope native plugin roots and declarations

2 participants