Skip to content

test(lifecycle): re-ground 21 stale known cells; sign and gate every known cell - #4584

Merged
Daniel Meppiel (danielmeppiel) merged 34 commits into
mainfrom
danielmeppiel-ql-w3-red-triage
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 34 commits into
mainfrom
danielmeppiel-ql-w3-red-triage

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Fixes #4571 (this PR carries #4653's O8 -> O8a/O8b journey oracle split and lands as one unit; #4653 closes as superseded).

Twenty-one strict known cells in tests/quality/generated_obligations.json cited tracking issues that the 0.37 release train #4424 had already completed (Refs #4053, #4178, #4224, #4174). All 21 still failed on main bfc0929, but for new reasons. The fixes had landed and the test oracles had gone stale. A strict xfail asserts only that a test fails, so it could not tell the two causes apart. This PR re-grounds the 21 cells and adds a structural guard so the same thing cannot go unnoticed again.

Per-cell classification (run on main under host_guard, real binary):

Cells Tracking issue (Refs) Cause today Action
10 LSP cells G|frozen|*|lsp, G|frozen-g|*|lsp, G|audit-ci|*|lsp #4053 The fix landed: --frozen exits 1 with "records an executables decision the gate no longer makes". FROZEN_REFUSAL did not accept that wording. FROZEN_REFUSAL accepts it. The cells become required.
9 cells P|approve|* #4178 The fix landed: apm approve resolves the org policy once through resolve_trust_policy. Block classes now exit 1 with "Blocked by org policy" and "Nothing was written". Warn classes print "Org policy not applied (outcome=...)" once, and I9 holds. Expectations now follow the shared routing, matching the exec-map site. The cells become required. empty/warn and the forbids lists now name the routed line, because the old "approval is proceeding" text no longer exists in src/.
J|E01|4|O8 #4224 The fix landed: the sarif run names the failed check on stderr. O8 still fires because no format of audit --ci prints a runnable remedy for a dependency-allowlist failure. This is a different cause. Re-keyed to #4570 (filed by the lead).
J|E04|4|O8 #4174 The fix landed: the advice is runnable and --verbose names the credential source. Following diagnostic advice on a repo that does not exist still exits 1, and #4174's own regression test pins that. Q&L ruling: drop O8 from E04 step 4. Model residual #4571 ("O8 cannot model diagnostic advice"). The key lines and O5 now pin the host, the credential and the advice.

None of the 21 is a product bug, so no issue was reopened.

Structural fix (approved by the lead):

  • tests/lifecycle/known.py adds KnownFailure(tracking, reason, match, kind="bug"|"deferred-design", raises=AssertionError). Its .mark() builds the strict xfail. The same module is a pytest plugin, registered by tests/conftest.py. It reports an expected failure whose message lacks the match signature as a failure ("failed for a different reason").

  • Every strict xfail in tests/lifecycle now goes through KnownFailure: the gate, policy, egress, integrity, origin, world and journey tables. The six User-scope (-g) org policy source: govern global installs consistently #3703 cells carry their I4 signature.

  • The [FEATURE] @registry dependency shorthand (owner/repo@<registry>#<semver>) #4543 Vasily Pupkin (@registry) shorthand cells are a deferred design whose tracker stays open. They become KnownFailure(kind="deferred-design") with the signature Shorthand '@alias' is not supported. Their reason text and strictness are unchanged, and all 19 nodes still xfail.

  • New gate tests/quality/test_known_cells_cite_open_issues.py (offline, repository ratchet scope, added to the ratchet contract job in ci.yml and main-architecture-ratchets.yml) checks four things:

    • Every known cell cites #<n> with n > 0. This covers the generated known_failing list, journey known_cells, machine KNOWN_CELLS, RULE_CELL_KNOWN, and an AST scan of every strict xfail and KnownFailure in tests/.
    • The snapshot tests/quality/known_cell_issue_states.json records exactly the cited issues.
    • No cited issue is recorded closed.
    • No raw pytest.mark.xfail appears in tests/lifecycle outside known.py.

    A pytester test proves the signature hook: a matching failure is reported as xfailed, and a failure with a different message is reported as failed.

  • Regenerate the snapshot with python -m tests.quality.known_cell_issues --write, which reads issue state through gh.

Obligation counts (tests/quality/generated_obligations.json): required 1064 -> 1083 (+19), known_failing 27 -> 7 (the six #3703 cells plus J|E01|4|O8 -> #4570). J|E04|4|O8 leaves the universe (residual #4571). tests/quality/lifecycle_obligations.json is unchanged (baseline 1468, required 1023).

Added after review and lead rulings:

Issue and approved scope

Issue: Refs #4565, Refs #4549 (also #4570, #4571, #4594, #4543)

Human scope-approval comment: Quality & Lifecycle lead rulings, 2026-11-21. Task A brief: classify the 21 stale cells, then ship the moves, the re-keys and the open-issue gate in one PR. E01 is re-keyed to #4570. The E04 O8 drop was accepted with residual #4571. KnownFailure, the makereport hook, the static ban and the snapshot gate were approved as designed. The #4543 deferred-design kind follows the regent ruling relayed by the lead.

Does this PR complete the issue, or what remains? It completes the stale-cell triage for #4565. #4570 (product) and #4571 (model residual) remain open and are tracked separately.

Type of change

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

Testing

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

All runs used host_guard with APM_BINARY_PATH=.venv/bin/apm:

  • pytest tests/lifecycle/security/test_gate_removal.py tests/lifecycle/security/test_policy_outcomes.py -k "lsp or approve": 78 passed (all 12 lsp rows and all 22 approve rows, no xfail left).
  • pytest "tests/lifecycle/journeys/test_journeys.py::test_journey[E01]" "...[E04]" plus the six User-scope (-g) org policy source: govern global installs consistently #3703 gate rows: 8 passed, 6 xfailed (each xfail carries its signature).
  • pytest tests/quality tests/unit/test_apm_yml_registries.py tests/unit/test_reference_registry_shorthand.py tests/unit/registry/test_compat_matrix.py tests/lifecycle/journeys/test_journeys.py::test_journey_files_agree_with_the_index -n 2: 599 passed, 19 xfailed.
  • Lint contract: ruff 0.15.12 check and format are clean; pylint R0801 10.00/10; lint-auth-signals.sh clean; check_complexity_ratchet.py --base-ref origin/main clean; python -m tests.quality.taxonomy --changed reports 11 changed modules OK.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

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

…n cells

The 21 cells citing closed #4053, #4178, #4224 and #4174 still failed on
main, but for new reasons: the fixes had landed and the oracles were stale.

- #4053 (10 LSP gate cells): --frozen now refuses with 'records an
  executables decision the gate no longer makes'; FROZEN_REFUSAL accepts
  it and the cells are required.
- #4178 (9 approve cells): approve routes the org policy through the trust
  reader once; block classes refuse and write nothing, warn classes report
  'Org policy not applied' once. Expectations follow; cells required.
- J|E01|4|O8: sarif audit now names the failed check (#4224) but no format
  prints a runnable remedy: re-keyed to #4570.
- J|E04|4|O8: the advice is diagnostic (#4174); O8 cannot model it
  (residual #4571), so step 4 drops O8 and pins host, credential, advice.

KnownFailure (tests/lifecycle/known.py) replaces raw strict xfails: it
names the tracking issue and the failure signature, and a makereport hook
fails a known cell that failed without it. The gate
tests/quality/test_known_cells_cite_open_issues.py requires every known
cell to cite an issue recorded OPEN in known_cell_issue_states.json.

Refs #4565, #4549

Co-authored-by: Copilot App <[email protected]>
- KnownFailure gains kind (bug | deferred-design) and raises; the
  signature plugin is registered by tests/conftest.py for every suite.
- The #4543 @registry shorthand cells (a deferred design whose tracker
  stays open) become KnownFailure(kind='deferred-design') with their
  failure signature; reason text and strictness are unchanged.
- The gate now discovers every strict xfail in tests/ by AST, so a raw
  strict xfail anywhere must cite an issue recorded OPEN.
- test_journeys.py names its promise ids literally (tm006 --changed).

Refs #4565, #4549

Co-authored-by: Copilot App <[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 known-issue gate can still hide unrelated invariant regressions, and its inventory omits scenario expectations tied to the closed #4164 issue.

2 open issues
What changed in this PR

This PR updates APM’s lifecycle tests to reflect fixes shipped in 0.37 and strengthens how the test suite tracks remaining known failures. It changes test infrastructure and CI, not product behavior.

Changes:

  • Promotes 10 LSP and nine approval cells from known failures to required coverage.
  • Re-keys E01’s missing-remedy failure to #4570 and removes E04’s inapplicable remediation check, tracking diagnostic coverage under #4571.
  • Adds failure-signature checks, an issue-state snapshot, and CI checks for known-cell tracking.
File Description
tests/​unit/​test_reference_registry_shorthand.py Signs deferred registry-shorthand failures.
tests/​unit/​test_apm_yml_registries.py Signs the deferred registry-override failure.
tests/​unit/​registry/​test_compat_matrix.py Signs deferred registry identity checks.
tests/​quality/​test_known_cells_cite_open_issues.py Adds citation, snapshot, marker, and signature-hook checks.
tests/​quality/​known_cell_issues.py Discovers known cells and refreshes recorded issue states.
tests/​quality/​known_cell_issue_states.json Records issue states for discovered known cells.
tests/​quality/​generated_obligations.json Updates required and known-failing obligations.
tests/​lifecycle/​world/​test_world.py Routes world-row expected failures through KnownFailure.
tests/​lifecycle/​security/​test_policy_outcomes.py Updates approval expectations and expected-failure handling.
tests/​lifecycle/​security/​test_origin_and_credentials.py Adopts signed credential and origin expectations.
tests/​lifecycle/​security/​test_integrity.py Adopts signed integrity expectations.
tests/​lifecycle/​security/​test_gate_removal.py Applies signed gate-row markers.
tests/​lifecycle/​security/​test_egress.py Applies signed egress-row markers.
tests/​lifecycle/​security/​gate_slices/​native.py Signs known user-scope native deployment failures.
tests/​lifecycle/​security/​gate_slices/​mcp.py Types MCP expectations as KnownFailure.
tests/​lifecycle/​security/​gate_slices/​lsp.py Removes obsolete LSP expected failures.
tests/​lifecycle/​security/​gate_slices/​hook.py Types hook expectations as KnownFailure.
tests/​lifecycle/​security/​gate_slices/​bin.py Signs known user-scope executable deployment failures.
tests/​lifecycle/​security/​gate_slices/​__init__.py Updates the shared gate-row expectation type.
tests/​lifecycle/​security/​gate_paths/​__init__.py Accepts the current stale-decision refusal diagnostic.
tests/​lifecycle/​security/​egress_slices/​__init__.py Updates the shared egress-row expectation type.
tests/​lifecycle/​known.py Defines signed known failures and the pytest reporting hook.
tests/​lifecycle/​journeys/​test_journeys.py Adopts signed journey markers and explicit promise IDs.
tests/​lifecycle/​journeys/​index.yaml Removes E04’s remediation oracle and documents the residual.
tests/​lifecycle/​journeys/​enterprise/​E04-private-hosts.yaml Updates diagnostic assertions and removes obsolete remediation expectations.
tests/​lifecycle/​journeys/​enterprise/​E01-org-policy-rollout.yaml Re-keys the missing-advice failure to #4570.
tests/​conftest.py Registers the known-failure plugin across the suite.
.github/​workflows/​main-architecture-ratchets.yml Runs the new quality checks on main.
.github/​workflows/​ci.yml Adds the new quality checks to CI.

Review effort: Balanced

Comment thread tests/lifecycle/known.py Resolved
Comment thread tests/quality/known_cell_issues.py Resolved
…cells

- Scenario Known cells of test_failure_phase cited closed #4164, but still
  fire with their original signature: product residual filed as #4594 and
  the cells re-keyed to it.
- Table-level known cells need an open issue and a failure signature:
  machine KNOWN_CELLS_BY_ID and KNOWN_T4 map to KnownFailure; scenario
  credits take a Known; Known, known_defect and KnownCell reject '#0' and
  an empty match.
- The gate's static scan covers Known, known_defect and KnownCell and
  resolves module-level tracking constants.

Refs #4565, #4549

Co-authored-by: Copilot App <[email protected]>
…s its signature

Review follow-up. An oracle failure can list a known violation next to an
unrelated one; a substring search over the whole message kept the row
xfailed and hid the new one. For a lifecycle oracle failure (header, one
line per violation, then 'args=' evidence) every violation line must now
match the KnownFailure signature; other failures keep a message search.
The #3703 signature names all three of its symptoms, and the gate test
adds a mixed known-plus-new case that must fail.

Refs #4565, #4549

Co-authored-by: Copilot App <[email protected]>
Resolve: main's new strict known cell X|install|pkg-registry|UPDATE=on
(#4572) becomes a KnownFailure with its KnownCell signature; the issue
snapshot records #4572 OPEN.

Co-authored-by: Copilot App <[email protected]>
…riage

# Conflicts:
#	.github/workflows/ci.yml
#	.github/workflows/main-architecture-ratchets.yml
Union resolution: main's source rule cells keep the KnownFailure-typed
KNOWN_CELLS_BY_ID; both FIRST_PARTY_MCP_CELL and KnownFailure imports;
snapshot drops #4324 (no longer cited on main).

Co-authored-by: Copilot App <[email protected]>
… diagnostic

O8 ran every printed "Run 'apm ...'" advice and required the failing
command to pass afterwards. That cannot model diagnostic advice, whose
job is to show why a step failed, so E04 step 4 sat on a strict cell
keyed to a closed issue and J13 step 4 passed vacuously (`apm list`,
then a rerun of a different command that already worked).

- O8a (REMEDIATION-TRUTH) is today's O8, renamed in the index, the E01
  known cell and the runner.
- O8b (DIAGNOSTIC-TRUTH): in a copy of the project and the step's own
  environment, the advice writes nothing, exits 0 or with the failing
  exit, prints every line it promises that the step did not, and the
  failing command keeps its exit.
- Journey files mark advice as `remediate` (O8a) or `diagnose` (O8b with
  promises); check_journey_file refuses a mismatch with the index.
- E04 step 4 (#4584's hunk carried verbatim: host, credential and advice
  key lines, the e04 strict cell keyed to closed #4174 dropped) and J13
  step 4 are O8b: J|E04|4|O8b and J|J13|4|O8b are required.

Fixes #4571
Refs #4565

Co-authored-by: Copilot App <[email protected]>
… quality module

The static O8a/O8b schema test asserted no CLI outcome inside the e2e
journey module (AQ003). It is a schema check, so it lives with the
other journey-index checks (unit).

Refs #4571

Co-authored-by: Copilot App <[email protected]>
…filtered diff

Review on #4653:
- The diagnostic probe is a clone of the whole world (project, HOME,
  APM_HOME, caches) under the failing step's environment, so advice
  that writes outside the project cannot leak into later steps and is
  seen by the read-only check.
- "Writes nothing" compares every durable root with the unfiltered
  artifact diff (bookkeeping such as .apm-local and directory entries
  included), not the journey's filtered file delta.

Refs #4571

Co-authored-by: Copilot App <[email protected]>
#4224 is closed; #4570 tracks the missing runnable next step of a failed
dependency-allowlist audit.

Refs #4571

Co-authored-by: Copilot App <[email protected]>
…4571)

The obligation-status ratchet (#4586, now on main) requires a named rule for
each required id that disappears; the 9 journey O8 ids are witnessed by
their O8a/O8b successors.

Co-authored-by: Copilot App <[email protected]>
# Conflicts:
#	tests/lifecycle/scenarios/test_failure_phase.py
#	tests/quality/generated_obligations.json
…uire the open-issue guard in merge-train

Co-authored-by: Copilot App <[email protected]>
@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
# Conflicts:
#	tests/lifecycle/scenarios/test_failure_phase.py
…; main flipped its cell)

Co-authored-by: Copilot App <[email protected]>
…n candidate

The root conftest registers tests/lifecycle/known.py, so the bounded candidate
copy must carry it or every mutation run fails at pytest_configure.

Co-authored-by: Copilot App <[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

Active findings leave forbidden credential output unchecked in advice and reruns, while durable-write detection misses environment-selected cache and configuration roots.

2 open issues
2 resolved since last review

Review effort: Balanced

…s, and snapshots every durable root

The diagnostic advice and each failing-command rerun must not print the
step's forbidden lines (raw output), recorded as evidence. The no-write
check snapshots every root the environment selects (cache, XDG, GitHub and
Azure config), collapsing nested roots, with a write-outside-HOME regression.

Co-authored-by: Copilot App <[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 checks can incorrectly accept unrelated fixture setup failures as known failures and miss creation or removal of empty artifact roots, leaving two correctness gaps unresolved.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Include root existence changes in artifact snapshot diffs

tests/​lifecycle/​journeys/​test_journeys.py:1437

ArtifactSnapshot.diff() compares entries only, not root_existed (tests/utils/artifact_snapshot.py:81-94). Creating an empty environment-selected root such as GH_CONFIG_DIR, or removing an existing empty root, therefore produces no changes here and passes O8b's no-write check. Compare root_existed as well so these durable writes are reported.

Medium severity Validate known-failure signatures for fixture setup errors

tests/​lifecycle/​known.py:96

A KnownFailure-marked test can xfail during fixture setup, but this call-only guard skips its signature check. An unrelated setup AssertionError is therefore accepted as an expected failure even when it lacks the known signature. Check every xfailed report with exception information, and add a pytester case covering a mismatched fixture failure.

2 resolved since last review

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 202efb7 into main Nov 22, 2026
63 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-ql-w3-red-triage branch November 22, 2026 21:50
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 22, 2026
test(lifecycle): train L -- signed known cells (#4584) and bundle allow-list policy (#4677)
Jason 'Jay' Jack (jasonjack-jay) pushed a commit to jasonjack-jay/Agent-Package-Manager that referenced this pull request Nov 23, 2026
…er its base

Main's T-6b/T-7b scenario modules passed issue strings to credits(known=);
microsoft#4584's credits() takes signed Known cells. Each step and its CREDITS
entry now share one module constant.

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.

[TEST] Journey oracle O8 cannot model diagnostic advice (split remediation vs diagnostic)

2 participants