Repository navigation
test(lifecycle): M-SCOPE-LOCK drift spine for stale and absent lockfiles (T-3 batch 1) - #4604
Merged
Merged
Conversation
…ckfiles A second scope-lock spine drives a stale lockfile (the manifest and the lock disagree on the toggle package), an absent lockfile and the side-door commands (deny, install --mcp, a local bundle, marketplace list) through every lock state the lockfile spine leaves open. Each step runs I1-I9; admitted side doors also assert their own outcome. Lockfile cells now carry the context their step acted on and credit, anchored on LOCK, the pairs it implies. apm marketplace list creating ~/.apm/marketplaces.json is a strict known cell (#4600). Refs #4564 Refs #4097 Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 21, 2026 11:49
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Active gaps in the lifecycle tests allow missing ownership records, unauthorized deployment, read-side mutations, unpersisted denials, and incomplete reconciliation to pass undetected.
5 open issues
What changed in this PR
Extends the M-SCOPE-LOCK lifecycle tests for the 0.38 coverage effort, exercising stale and absent lockfiles in project and user scopes without changing production behavior.
Changes:
- Adds a drift test sequence covering lockfile commands, deny, MCP installation, bundle installation, and marketplace listing.
- Adds lock-context witness crediting and adjusts observations when lockfile provenance is unavailable.
- Regenerates obligations: 94 become required and two become known-failing, tracking #4600.
| File | Description |
|---|---|
tests/quality/lifecycle_obligations.json |
Updates obligation statuses, witnesses, and coverage counts. |
tests/lifecycle/machines/test_m_scope_lock.py |
Adds drift scenarios, side-door checks, and the known marketplace failure. |
tests/lifecycle/machines/_kit.py |
Clears managed-path attribution when no readable lockfile exists. |
tests/lifecycle/generator/witnesses.py |
Maps drift cells and lock-specific context to generated obligations. |
Review effort: Balanced
| self.current = op | ||
| exits = self.exits(op) | ||
| requested = self._requested(op) | ||
| step = self.step( |
| cells=(cell,), | ||
| converged=False, | ||
| model=requested, | ||
| mutating=op in MUTATING and state != "newer", |
| mutating=op in MUTATING and state != "newer", | ||
| ) | ||
| refused = step.result.returncode != 0 | ||
| unchanged = self.durable() if refused else {"outside": ("*",)} |
Comment on lines
+499
to
+500
| if not refused: | ||
| self.check_side_door(op) |
Comment on lines
+505
to
+506
| if not refused and self.bench.lock_path.is_file() and state in DRIFT_STATES: | ||
| self.lock_state = "consistent" |
This was referenced Nov 21, 2026
Collaborator
Author
|
Superseded by the train #4614 (corpus train 2), which merges this branch with --no-ff and regenerates the obligation ledger once. The red here was an unrelated Windows flake (tests/unit/policy/test_cache_atomicity.py). This PR stays open as the linked source until the train lands. |
…record Per review on corpus train 2: outcome checks now run before a drift cell is credited. A resolving command must leave a readable lockfile whose rows match the manifest and that records each deployed declared skill; a local bundle install must record p-lsp's approval key and LSP type in apm_modules/.local-bundle-pending.json while its server stays parked. Refs #4564 Co-authored-by: Copilot App <[email protected]>
6 of 14 tasks
Jason 'Jay' Jack (jasonjack-jay)
pushed a commit
to jasonjack-jay/Agent-Package-Manager
that referenced
this pull request
Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
T-3 (M-SCOPE-LOCK) batch 1 of the 0.38 lifecycle burn-down. 96 obligations leave the baseline: 94 T-3 + 2 T-2. 94 become required; 2 become known-failing and track #4600.
Drift spine (
test_scope_lock_drift_spine_credits_stale_absent_and_side_doors[project|user]) covers two lockfile states:It runs the lockfile commands the existing spine leaves open in those states. It also runs four side doors at every lock state the generator still lists:
apm denyon an installed gated package;apm install --mcp <registry server>;apm install <local bundle>;apm marketplace list(project scope only).Every step runs
check_cross_cutting(I1-I9). Admitted side doors also assert their own outcome: the requested MCP server is declared and configured, and the bundle's LSP server stays parked. Refusals assert byte-identical durable state.Observed behavior pinned:
install --frozen;apm denysucceeds under a newer-generator lock (it writes the approval store, never the lockfile) and refuses without a lockfile (nothing is installed);install --mcpand bundle install refuse a newer-generator lock.Lock context. Every lockfile cell also records what its step acted on, via
lock_context: source, primitive, gate level, target, network and prior deployment (a deleted lock meanspresent-provenance-unknown).generator/witnesses.pycredits those values only on implied ids that name LOCK (the anchor), so a refused write never discharges a success cell. The plain OP x SCOPE x LOCK credit is unchanged.Bench. An absent or unreadable lockfile attributes nothing, so I1 has no ledger to compare. After a deleted lockfile, files stay unattributed until a resolving command records them again;
apm lockand the side doors write a lock without them.Strict known cell [BUG] apm marketplace list writes ~/.apm/marketplaces.json #4600.
apm marketplace listis a read command, but on a fresh HOME it creates~/.apm/marketplaces.json(I5). CellT4|marketplace|project|consistentis known-failing until the fix.Obligation counts (
tests/quality/lifecycle_obligations.json, regenerated on main):T-3 baseline: 243 -> 149. T-2: 496 -> 494.
PR shard cost: one new parametrized test with about 30 CLI steps per scope. Locally on a loaded host it takes 57 s (project) and 32 s (user); expect about half that on CI.
Issue and approved scope
Issue: Refs #4564, Refs #4565, Refs #4097
Human scope-approval comment: #4564 (comment)
Does this PR complete the issue, or what remains? Partial. Still open: T-3 pairs that need other sources, targets, network modes and gate levels under each lock state, and
packunder a stale or newer lock (it refuses local-path dependencies).Type of change
Testing
Tested locally
All existing tests pass
Added tests for new functionality (if applicable)
pytest tests/lifecycle/machines/test_m_scope_lock.py tests/quality/test_promise_obligations.py tests/quality/test_generated_obligations.py tests/lifecycle/generator/test_generator_rules.py tests/lifecycle/world/test_world.py -k "not policy_variant"-> 175 passed (engine driver, host-guarded)python -m tests.lifecycle.generator --check-> up to dateLint contract: ruff 0.15.12 check and format,
lint-auth-signals.sh, complexity ratchet (--base-ref origin/main),tests.quality.taxonomy --changedandcheck_test_assertions.py-> cleanChangelog
## [Unreleased]inCHANGELOG.md.Spec conformance (OpenAPM v0.1)