Skip to content

fix: fold Copilot review findings from #4357 and #4370 - #4379

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
danielmeppiel-t1-review-folds
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
danielmeppiel-t1-review-folds

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Fixes the two valid Copilot review findings that were left on #4357 and #4370 when those PRs merged.

#4357 (#4351): report keyed to a sink

_report_cache_mismatch recorded the package as reported even when no diagnostic collector or logger existed (run_install_pipeline(logger=None); diagnostics are assigned later). The integrate phase then suppressed its fallback, and the mismatch diagnostic was lost entirely. The package is now recorded only when a sink actually received the notice.

  • New test: tests/unit/install/test_direct_dep_failure.py::test_cache_mismatch_counts_as_reported_only_when_a_sink_received_it.

#4370: the child's environment decides

The verbose/debug exemption for logging records read pytest's os.environ, not the environment the command ran with. ApmLifecycleRunner now passes its explicit env through _check_output -> check_cli_output -> output_violations. The os.environ fallback applies only to direct callers that pass no env.

  • New test: test_logging_records_follow_the_child_env_not_pytest covers both mismatches. A child with APM_DEBUG is exempt; pytest with APM_DEBUG and a child without it still fails I9.

Validation

  • pytest tests/unit/install/test_direct_dep_failure.py tests/unit/scripts/test_lifecycle_evidence.py: 214 passed.
  • ruff check and format: clean.

Steward pre-approval (A-C)

  • Node-set diff vs main: no deletions or renames; adds tests/unit/install/test_direct_dep_failure.py::test_cache_mismatch_counts_as_reported_only_when_a_sink_received_it and tests/unit/scripts/test_lifecycle_evidence.py::test_logging_records_follow_the_child_env_not_pytest.
  • Oracle and obligations: tightens one rule. The I9 logging-record exemption now applies only when the command's own environment enables debug; previously pytest's environment could exempt a default child run. 0 cells added or removed; 0 obligation changes.

- install/download: a cache content-hash mismatch counts as reported only when a
  diagnostic collector or logger received it, so integrate keeps its fallback
  report on logger-less pipelines (#4351).
- Output oracle: the verbose/debug exemption for logging records reads the
  command's own environment (ApmLifecycleRunner passes it through), not pytest's;
  unit cases cover both parent/child mismatches (#4113).

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 new tests exceed assertion-quality baseline allowances by patching imported helpers and omitting observable-outcome assertions, causing the quality gate to fail despite targeted tests passing.

2 open issues
What changed in this PR

This PR addresses follow-up fixes from #4357 and #4370: preserving cache-mismatch diagnostics when no reporting sink exists and making lifecycle output checks use the command's environment.

Changes:

  • Mark cache mismatches as reported only after notifying a diagnostic collector or logger.
  • Pass the child environment through lifecycle output checks.
  • Add regression tests for missing reporting sinks and parent/child debug-environment differences.
File Description
tests/​utils/​lifecycle_evidence.py Uses the supplied environment to determine debug-output exemptions.
tests/​utils/​apm_lifecycle_runner.py Forwards the command environment to output validation.
tests/​unit/​scripts/​test_lifecycle_evidence.py Tests differing parent and child debug settings.
tests/​unit/​install/​test_direct_dep_failure.py Tests cache-mismatch reporting with and without a logger.
src/​apm_cli/​install/​phases/​download.py Records a mismatch as reported only when a sink receives it.

Review effort: Balanced

Comment on lines +144 to +149
from apm_cli.install import source_helpers
from apm_cli.install.phases import download

monkeypatch.setattr(source_helpers, "locked_content_mismatch", lambda *a, **k: True)
monkeypatch.setattr(source_helpers, "observed_package_hash", lambda *a, **k: "sha256:b")
locked = SimpleNamespace(content_hash="sha256:a")
)
download._report_cache_mismatch(heard, "pkg", locked, tmp_path)
assert heard.cache_mismatch_reported == {"pkg"}
assert len(lines) == 1
…owner patches

Fixes the AQ003/AQ004 ratchet: a real on-disk mismatch replaces the
source_helpers monkeypatches, and the case asserts printed output.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 96e98b7 into main Nov 21, 2026
42 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-t1-review-folds branch November 21, 2026 05:24
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.

2 participants