Skip to content

test(lifecycle): I1-X2, a declared user write is the user's and APM must keep it - #4617

Merged
Daniel Meppiel (danielmeppiel) merged 9 commits into
mainfrom
danielmeppiel-i1-x2-user-bytes
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 9 commits into
mainfrom
danielmeppiel-i1-x2-user-bytes

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Adds I1-X2, a narrow, explicit exception to the lifecycle I1 law (lock and deployed files agree), as ruled by the Q&L lead.

A scenario that edits a deployed file (DEPLOYED=edited), or writes its own file at a package's path (DEPLOYED=unowned), now declares those bytes with Scenario.user_write(path, text). Observation.user_bytes carries the path and the sha256 of those bytes into the oracle.

  • Exemption: I1 skips the lock==disk check (a hash mismatch, or a managed path missing from the lock) for that path only while disk holds exactly the declared bytes.
  • Positive assertion: APM must keep those bytes. If a step changes or removes them, I1 fails ("I1-X2: the user's bytes were changed / file was removed").
  • No credit from an exemption: a step where an exemption applied earns no I1 receipt. Pairs are credited by their own evidence.
  • Scenario.release_user_write(path) handles the case where the user asks APM to replace the file (install --force).
  • The law text in ORACLE_LAWS["I1"] names I1-X2, alongside I7-X1.
  • The [BUG] The user lockfile does not record the bin/ files a marketplace plugin deployed #4225 native-plugin carve-out (_native_plugin_recorded) is keyed on lock records, not user bytes, so it does not fit this case and is left unchanged.

This unblocks the T-6b ownership scenario suite: all 141 DEPLOYED x {edited, unowned, present-provenance-unknown} pair obligations currently fail I1 by construction, not because of the product. Per the ruling, it ships on its own because oracles.py is shared by every lane.

Issue and approved scope

Issue: Refs #4564 (0.38 lifecycle burn-down), Refs #4565 (epic)

Human scope-approval comment: #4564 (comment)

Does this PR complete the issue, or what remains? Partial: the oracle exception only. The T-6b suite that uses it rides corpus train 2.

Type of change

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

Testing

  • Tested locally

  • All existing tests pass

  • Added tests for new functionality (if applicable)

  • pytest tests/quality/test_oracle_user_writes.py -> 5 passed. The negative controls: an undeclared edit still fails I1; a declared edit the CLI changed fails I1; a declared user file the CLI removed fails I1; a kept declared edit is exempt and earns no receipt; an undeclared user file at a package path still fails I1.

  • pytest tests/quality/test_promise_obligations.py tests/quality/test_generated_obligations.py -> passed (54 with the new module).

  • Lint contract: ruff 0.15.12 check/format, taxonomy --changed, assertion-quality ratchet -> clean.

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.

Added: I4-X2 (ruling #5)

I4-X2: a gate surface whose every deployed path holds exactly declared user bytes (Scenario.user_write) is exempt from I4 only if the step announces the keep AND audit --ci fails naming the path; it earns no I4 receipt.

  • Observation.cell_paths (each deployed cell's paths) and Observation.audit_ci (the kit runs audit --ci once after a step that left such a surface).
  • Four negative controls in tests/quality/test_oracle_user_writes.py: undeclared bytes fail I4; an unannounced keep fails I4; an undetected keep fails I4; an announced, detected keep is exempt with no receipt.
  • Review fixes: user_write / release_user_write mark the model unconverged (source_moved).

…ust keep it

A scenario that edits a deployed file, or writes its own file at a package
path, declares those bytes with Scenario.user_write. I1 exempts the path
from lock==disk only while disk holds exactly the declared bytes; changing
or removing them fails I1, and an exempted step earns no I1 receipt.
Negative controls in tests/quality keep the exception narrow.

Refs #4564 #4565

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…t a deployment

Scenario.deployed() leaves a path holding the user's declared bytes to the
user when no lock row records it (a user file at a package path, or an
edited file left after its package was removed), so I4 does not count it
as a deployed surface. An edited file the lock still records stays its
package's deployment.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

User writes and edit releases fail to invalidate convergence, producing incorrect I2 idempotence checks, while filesystem-accessing tests are incorrectly marked as unit tests.

3 open issues
What changed in this PR

Adds I1-X2 to the shared lifecycle oracle, allowing scenarios to declare user-owned bytes that APM must preserve. This supports the ownership scenarios planned under #4564 without changing production behavior.

Changes:

  • Adds helpers to declare user writes and release protection for authorized replacement.
  • Exempts matching user bytes from lock/disk agreement checks, rejects changes or removal, and withholds I1 receipts for exempted steps.
  • Adds focused tests for declared and undeclared edits and unowned files.
File Description
tests/​quality/​test_oracle_user_writes.py Tests preservation, exemption boundaries, and receipt suppression.
tests/​lifecycle/​scenarios/​_kit.py Tracks declared user writes and passes their hashes into observations.
tests/​lifecycle/​oracles.py Defines and enforces the I1-X2 preservation exception.

Review effort: Balanced

Comment thread tests/lifecycle/scenarios/_kit.py Resolved
Comment thread tests/lifecycle/scenarios/_kit.py Resolved
#4597 fixed #4572 (a git -> registry switch now drops the stale
.apm-pin) but left the strict KnownCell registry-source-switch-stale-pin
in test_m_source.py. The cell no longer fails, so the source spine
(test_source_spine_covers_every_form_and_op, lifecycle_smoke shard 4)
fails strict on every PR. Drop the cell and its KNOWN_CELLS_BY_ID entry;
the regenerated pair X|install|pkg-registry|UPDATE=on moves from
known-failing to required.

Refs #4572, #4565

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The shape is the declared target set before the step; narrowed drops at
least one previously declared target (a switch counts), widened adds at
least one and drops none. factors.py and covering.py now say so.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…nly if announced and detected

Ruling #5 (Q&L lead): I4 exempts a gate surface whose every deployed path
holds exactly declared user bytes (Scenario.user_write) only when the step
announces the keep AND audit --ci fails naming the path; an exempted
surface earns no I4 receipt. The scenario kit records each cell's paths
(Observation.cell_paths) and runs audit --ci once after a step that left
such a surface (Observation.audit_ci). Four negative controls: undeclared
bytes, an unannounced keep and an undetected keep fail I4; an announced,
detected keep is exempt with no receipt.

Review: user_write and release_user_write are input edits, so they now
mark the model unconverged (source_moved).

Refs #4564 #4565

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #4564 #4565

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #4564 #4565

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 9dc707c into main Nov 21, 2026
42 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-i1-x2-user-bytes branch November 21, 2026 15:23
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