Skip to content

fix(tests): allow retained lifecycle lock in generated state-machine write set - #3566

Merged
Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-lifecycle-lock-write-set
Nov 11, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-lifecycle-lock-write-set

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

Release dry run 43039615994 fails Build & Validate (macOS x86_64) on 5
[project] cases of tests/integration/test_generated_lifecycle_state_machine.py:
Artifact root 'user' wrote outside its declared write set: ['.apm/.apm-lifecycle.lock'].

Since #3465, Python >= 3.11 uses filelock 4, which no longer unlinks lock files on
release. The OS-user lifecycle lock ~/.apm/.apm-lifecycle.lock therefore persists
after a project-scope install. This PR declares it in the test's _USER_WRITE_PATHS
(the write set is an allow-list, so this also holds on filelock 3.x / Windows where
the file may be removed). tests/integration/test_brownfield_lifecycle.py already
declares the same path. Re-adding an unlink in product code would reintroduce the
lock-file race filelock 4 removed, so no product change. Test-only.

The Linux integration legs were skipped in that dry run (blocked by #3560) and would
hit the same failure; this module does not run in PR or push-to-main CI.

Issue and approved scope

Issue: Fixes #3565

Human scope-approval comment: scope approved by Daniel Meppiel (@danielmeppiel)'s explicit
session mandate ("loop until the CI pipelines in main are fixed, and that the
release pipeline is passing on a dry run"), recorded in #3565. Review contact:
Daniel Meppiel (@danielmeppiel).

Does this PR complete the issue, or what remains? Completes it.

Type of change

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

Testing

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

On macOS, Python 3.12, APM from the editable install:

  • Before (main, filelock 4.2.8): APM_E2E_TESTS=1 APM_BINARY_PATH=$PWD/.venv/bin/apm .venv/bin/pytest "tests/integration/test_generated_lifecycle_state_machine.py::test_generated_identity_write_scope_is_exact" -q -> failed with the CI assertion.
  • Same command with filelock 3.29.0 -> 7 passed (confirms filelock 4 as the trigger).
  • After (this PR, filelock 4.2.8): APM_E2E_TESTS=1 APM_BINARY_PATH=$PWD/.venv/bin/apm .venv/bin/pytest tests/integration/test_generated_lifecycle_state_machine.py -q -n 4 -> 14 passed.
  • Sweep of the other 48 artifact-snapshot integration modules on filelock 4.2.8 -> 495 passed; the only 5 failures are test_ssh_semver_transport_contract.py binary-provenance preflight, which needs a native PyInstaller binary (environment-only, unrelated).
  • ruff check / ruff format --check on the CI-mirror paths -> clean.

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

…write set

filelock 4 (adopted for Python >= 3.11 in #3465) no longer unlinks the
lock file on release, so a project-scope install now leaves the OS-user
lifecycle lock ~/.apm/.apm-lifecycle.lock on disk. The generated
lifecycle state-machine test rejected it as a write outside the declared
user-root write set, failing the release dry run on macOS (run
43039615994). Declare the lock in _USER_WRITE_PATHS, matching
test_brownfield_lifecycle.py. Re-adding an unlink in product code would
reintroduce the lock-file race filelock 4 removed.

Refs #3565

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.

🟢 Approval recommended

No active review issues remain for the test-only allow-list update permitting the retained lifecycle lock file.

No open issues 🎉

What changed in this PR

This test-only fix addresses #3565 by allowing the retained lifecycle lock file introduced by filelock 4 behavior. It updates the generated lifecycle state-machine test without changing production locking behavior.

Changes:

  • Adds .apm/.apm-lifecycle.lock to the user-root write allow-list.
  • Documents why the lock file may remain after release; its presence is permitted, not required.
File Description
tests/​integration/​test_generated_lifecycle_state_machine.py Allows the retained user lifecycle lock in the declared write set.

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit b55dcf6 into main Nov 11, 2026
38 of 42 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-lifecycle-lock-write-set branch November 11, 2026 18:01
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.

CI: release dry run fails lifecycle state-machine write set after filelock 4 (retained .apm-lifecycle.lock)

2 participants