Skip to content

P1: Apply Python semantic rename atomically with rollback #266

Description

@tomdps

Parent

Tracking parent #249; epic #243. This is one vertical delivery slice. Do not close or bypass the parent tracker from this child.

Goal

Apply only a reviewed semantic preview after exact validation binding, path/version/hash rechecks, deterministic commit, final verification, and proven rollback.

Dependency contract

Required behavior

  1. Only opcore edit apply of an exact serialized A plan may apply Python semantic edits; one-shot rename --apply remains refused. Recompute planHash/planId, repo/context/input/baseline/preimage fingerprints, and reject any tamper or drift before staging.
  2. Extend normalization/apply only to a safe single regular-file RenameFile returned by semantic rename. Reject Create/Delete/folders, overwrite/ignore flags, malformed order, unsupported metadata, destination/source/case/cycle collisions, and unreviewed operations.
  3. Construct one exact Hypothetical (validate pre-write) evaluation must be comprehensive — graph-backed checks are silently skipped #197 after-state and require mandatory Python syntax, canonical imports, and P0 — Harden Python type checking and configuration semantics #245 authoritative type gate plus only explicitly requested fix(python): make ruff and pytest toolchain status honest #211 Ruff/pytest gates. Verify overall and every mandatory/requested run is exact passed and validation recomputed after-state hash equals preview; disabled/unavailable/invalid/timeout/findings/skipped/not-applicable/provider/infrastructure/malformed states refuse without writes.
  4. Before/after validation and immediately precommit, canonicalize and lstat-walk source/destination/ancestors; refuse symlink, hardlink, special/generated/private/ignored/cache/read-only/unwritable/out-of-root/case/identity/inode swaps. Support verified UTF-8/BOM/line endings/final newline and measured mode/uid/gid only; refuse unsupported encoding/metadata rather than overclaim.
  5. Snapshot reviewed content/metadata, stage all writes, recheck precommit identities, commit deterministically, reread final checksums/metadata against afterStateHash, and clean temps. Validation/stage refusal reports not_started/unchanged. Commit/postverify failure restores reverse order and verifies every path/metadata/directory; incomplete restore is rollback_failed with uncertain paths.
  6. Guarantee all-or-nothing only for handled in-process failures with verified rollback; make no crash/power-loss durability or ASP host apply claim.

Acceptance criteria

Observable outcomes

  • Clean success carries positive execution/provenance evidence; zero diagnostics alone is never proof.
  • Findings and every unavailable/invalid/timeout/crash/resource/stale/unsupported state are machine-readable and fail or degrade exactly as the capability contract says.
  • No implicit fallback, partial result, or skipped execution is reported as a pass.
  • Target source, configuration, lockfiles, environments, and caches remain unchanged except where this issue explicitly owns a validation-gated atomic edit; every temporary resource/process is cleaned.

Non-goals

  • module/package moves
  • ASP apply authority
  • tool install/checker selection
  • power-loss journal
  • arbitrary binary encodings
  • readiness claims

Verification

Run focused behavior first, then the configured repository proof only after the acceptance matrix works:

  • npm run build
  • node --test tests/edit-python-rename-preview.test.mjs tests/edit-python-rename-apply.test.mjs tests/edit-atomic-writer.test.mjs tests/edit-atomic-writer-mixed.test.mjs tests/edit-validation.test.mjs tests/validation-overlays.test.mjs tests/validation-runner.test.mjs tests/contracts.test.mjs tests/installed-bins.test.mjs
  • npm run lint
  • npm run pack:check
  • bash ./scripts/ci/run-local-ci-equivalent.sh
  • Attach exact real-tool/artifact versions, argv/config/cwd/source, normalized result examples, before/after cleanliness evidence, and packed-install proof where the slice changes public package behavior.

Execution rule

Implement only after a just-in-time review against current dev. Keep exactly one implementation run active. PR base is dev; require green checks, clean scoped diff, merged PR, closed child, parent checklist update, focused reproductions, and opcore-ci proof before starting the next child. Do not claim Python readiness/parity, ASP authority, old-tool replacement, security/SAST, all-stack support, automatic fixes, or a blended score.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions