Skip to content

fix(install): hash-check bundle compile staging so edits before apm compile are detected (#3718) - #3898

Merged
Daniel Meppiel (danielmeppiel) merged 11 commits into
mainfrom
danielmeppiel-bug-3718-staged-hashes
Nov 19, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 11 commits into
mainfrom
danielmeppiel-bug-3718-staged-hashes

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Since #3717, apm install <bundle> for Codex, Gemini and OpenCode stages bundle instructions under apm_modules/<slug>/.apm/instructions/ and records them in local_staged_files, but without a content hash. If someone edited a staged file between install and apm compile, compile merged the edited text into AGENTS.md with no warning, and apm audit --ci passed.

This PR mirrors local_deployed_file_hashes for staged files:

Piece Change Owner routed through
Record New lockfile map local_staged_file_hashes (path -> sha256:<hex>). It is hashed by compute_file_hash, the same hash used for deployed files, and written by DeploymentLedgerCodec.record_local_bundle_files(..., staged_hashes=). A pre-#3705 staging claim keeps its install-time hash when it migrates. A path that this install did not restage keeps its prior hash. install/services.py -> core/deployment_ledger.py -> deps/lockfile.py
Verify LockFile.staged_hash_drift(project_root) is the only verifier. Paths with no hash (older lockfiles), paths outside a staging root, paths containing .., and missing or symlinked files make no drift claim. deps/lockfile.py
Audit content-integrity fails with hash-drift: <path> (staged, expected=..., actual=...) and suggests 'apm install <bundle> --force' to restage. policy/ci_checks.py
Compile Prints [!] hash-drift: staged file <path> changed since install ... before compiling. commands/compile/cli.py
Lifecycle apm prune retirement drops the hashes too. Declarative installs carry records and hashes together through LockFile.carry_local_staging_from. A staged file that a reinstall skips on collision keeps its prior hash; if it has none (upgrading from an older lockfile), it is bound to the bundle's bytes, so a local edit still shows as drift. deps/lockfile.py, core/deployment_ledger.py (staged_fallback_hashes)

Guard: the existing install-deployment-bundle-compile-staging rule now also requires the hash field, the verifier, the use of compute_file_hash, the collision fallback, the carry helper, and the audit and compile call sites. It also rejects any local_staged_file_hashes write outside deps/lockfile.py and core/deployment_ledger.py. A new test, test_staged_compile_input_drift_routes_through_lockfile_owner, adds 7 mutation cases that prove the rule catches regressions. The verifier only checks paths that stay inside apm_modules (via ensure_path_within). The owner registry text is updated.

Advisory panel (lean): #3898 (comment). Follow-ups 1, 2, 3, 5 and 6 are folded in 1eadb7d. Follow-up 4 (fail closed on staged entries with no hash) is deferred: a newer bundle that drops a file leaves a legitimately unhashed entry that --force cannot fix, so failing on it would break the approved rule that older lockfiles make no drift claim.

Before: on main at f8ef817, an edited staged file compiled into AGENTS.md silently, and apm audit --ci reported "All 10 check(s) passed".
After: apm compile warns, apm audit --ci fails content-integrity with 1 staged file(s) with hash drift, and apm install <bundle> --force clears it.

Issue and approved scope

Issue: Fixes #3718

Human scope-approval comment: #3718 (comment)

This PR completes the issue. Out of scope (per the record): detecting unrecorded files added under a staging root, and blocking apm compile on drift (it warns).

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
Command Result
APM_BINARY_PATH=.venv/bin/apm pytest -p no:xdist tests/integration/test_local_bundle_compile_only_targets_lifecycle.py tests/integration/test_frozen_deployed_hash_lifecycle.py at cd3aaea 11 passed
mutation-break: drop the collision fallback in record_local_bundle_files lifecycle test_staged_instruction_edits_are_reported_as_hash_drift fails; drop the prior-hash carry -> unit test_staged_hashes_carry_with_their_records_and_bundle_fallback_never_wins fails
same file, -k "hash_drift or edited", against unfixed src/ 2 failed (new test_staged_instruction_edits_are_reported_as_hash_drift, and edited-skipped migration case), confirming the regression trap
pytest -p no:xdist tests/unit/deps/test_lockfile_local_staging.py tests/unit/deps/test_lockfile_consumer_contract.py tests/unit/deps/test_lockfile_field_properties.py / tests/unit/core/test_deployment_state.py tests/unit/install/test_install_local_bundle*.py / tests/unit/policy/test_ci_checks.py tests/unit/test_drift_detection.py tests/unit/install/test_frozen.py at cd3aaea 42 / 186 / 178 passed
pytest -p no:xdist tests/unit/policy (first push) 1562 passed (with local-bundle units), 1 xfailed
pytest -p no:xdist tests/integration/test_architecture_owner_rule_mutations.py -k "staged_compile_input or matrix or bundle-compile-staging" 12 passed (full matrix left to CI)
pytest -p no:xdist tests/unit/scripts/test_architecture_runner.py 72 passed
uvx [email protected] check / format --check (CI paths) All checks passed / 2411 files already formatted
pylint R0801 (CI args) 10.00/10
bash scripts/lint-auth-signals.sh / bash scripts/lint-architecture-boundaries.sh clean / exit 0

Lint ran on HEAD merged with main at b3df642.

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

local_staged_files is not one of the top-level keys that req-lk-001 lists, so its new sibling local_staged_file_hashes is also an APM lockfile extension and needs no spec amendment. The commit carries an apm-spec-waiver: trailer for Mode B.

…e are detected (#3718)

Bundle installs for Codex, Gemini and OpenCode now record a content hash
per staged instruction in local_staged_file_hashes, computed by the same
compute_file_hash owner as deployed files. LockFile.staged_hash_drift is
the single verifier: apm audit --ci content-integrity fails and
apm compile warns on drift. Older lockfiles without staged hashes make no
drift claim.

apm-spec-waiver: local_staged_files and its hashes are APM lockfile extensions outside the OpenAPM v0.1 key list

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 05:45
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 19, 2026

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 verifier can hash files outside the project through symlinked ancestors, and watch-mode compilation bypasses hash-drift warnings.

2 open issues
What changed in this PR

This PR addresses #3718 by adding content hashes to the bundle compile staging introduced in #3717. It extends APM's integrity checks to detect staged instruction edits without treating those files as deployment claims.

Changes:

  • Records staged hashes and preserves them through migration and declarative installs, removing them on prune.
  • Adds staged-content drift reporting to audit and one-shot compilation.
  • Updates lifecycle tests, architecture guards, and user documentation.
File Description
tests/​unit/​deps/​test_lockfile_local_staging.py Tests hash persistence, migration, retirement, and drift.
tests/​integration/​test_local_bundle_compile_only_targets_lifecycle.py Covers edited staging and forced-reinstall recovery.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds mutations checking hash-owner enforcement.
src/​apm_cli/​policy/​ci_checks.py Reports staged drift in content-integrity checks.
src/​apm_cli/​install/​services.py Computes hashes for staged bundle files.
src/​apm_cli/​install/​phases/​lockfile.py Preserves staged hashes during declarative installs.
src/​apm_cli/​install/​local_bundle_handler.py Passes staged hashes to the ledger.
src/​apm_cli/​deps/​lockfile.py Stores, verifies, and retires staged hashes.
src/​apm_cli/​core/​deployment_ledger.py Records staged hashes and migrates legacy hashes.
src/​apm_cli/​commands/​compile/​cli.py Warns about drift before one-shot compilation.
scripts/​architecture_linter/​checks/​install_bundle_compile_staging.py Extends staging ownership guards to hash verification.
packages/​apm-guide/​.apm/​skills/​apm-usage/​commands.md Documents staged drift and recovery.
docs/​src/​content/​docs/​reference/​lockfile-spec.md Defines the staged-hash lockfile field.
docs/​src/​content/​docs/​reference/​baseline-checks.md Documents audit coverage and remediation.
docs/​src/​content/​docs/​consumer/​deploy-a-bundle.md Explains staged-content integrity checks.
CHANGELOG.md Adds the fix announcement and repeats existing release entries.
.apm/​architecture/​owners/​install-deployment.json Updates ownership of staged hashing and verification.

Review effort: Balanced

Comment thread src/apm_cli/commands/compile/cli.py Resolved
Comment thread src/apm_cli/deps/lockfile.py Resolved
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Issue #3718: APM now records a hash for each bundle-staged compile input, so a staged file edited after install fails apm audit --ci and makes apm compile warn.

panel-mode=lean; personas=python-architect,supply-chain-security-expert,test-coverage-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

All three panelists agree on the core design. LockFile.staged_hash_drift is the single verifier and sits with the owner of the staging state. Hashes go through compute_file_hash, the same owner used for deployed-file hashes. Drift fails in apm audit --ci and only warns in apm compile, which matches the accepted scope. Old lockfiles without hashes make no drift claim, so the upgrade breaks nobody. None of the 8 findings is blocking.

The main gap is completeness. Every path in local_staged_files should carry a hash, and every write site that copies one field should copy the other. The panel found four ways a staged edit could still go unseen:

  • A staged file that is skipped on collision, when no prior hash exists, ends up with no hash.
  • Dropping the prior-hash carry still passes all 19 PR tests.
  • Deleting the declarative carry-forward still passes.
  • The two fields are kept in step by hand.

The overlapping findings are merged below. Follow-ups 1-6 are IN SCOPE: they make the accepted promise hold on these edge paths. The out-of-scope items stay out:

  • detecting unrecorded files added under a staging root
  • blocking compile on drift
  • spec changes

Follow-up 4 must report hashless paths only when the hash map is non-empty, so old lockfiles still make no drift claim.

Dissent. No substantive disagreement. The supply-chain evidence outcome is unknown, so it was weighed as opinion, but the code path it names (services.py:1127) is concrete and can be checked.

Aligned with: secure by default: Strengthened: lockfile hashes bind staged compile inputs, and audit fails closed on drift. The remaining gaps are unhashed collision-skipped paths and hashless entries that are skipped silently.; governed by policy: apm audit --ci content-integrity now covers staged compile inputs.; portable by manifest: Old lockfiles without hashes still load without false drift claims. Hashes carry forward across reinstalls, but no test protects that yet.; pragmatic as npm: Compile warns instead of blocking and the fix is to restage. There is no new command or flag to learn.

Panel summary

Persona B R N Takeaway
Python Architect 0 3 0 Owner placement is correct (staging-state owner owns the staged verifier). Tighten the static guard and paired-field writers so the single-owner claim is enforced.
Supply Chain Security Expert 0 3 0 Hash binding is sound and single-owner; warn-on-compile / fail-in-audit is defensible. One upgrade-path gap: a collision-skipped edited staged file gets no hash and is never verified.
Test Coverage Expert 0 2 0 Core drift lifecycle verified (19 passed). Gap: edit-then-plain-reinstall hash carry and declarative carry-forward are not trapped by any test.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 5 follow-ups

  1. [Test Coverage Expert] [IN SCOPE] Extend the lifecycle test: install, edit a staged file, run a plain reinstall, then assert apm audit --ci still reports staged hash-drift. -- Evidence missing (e2e): dropping the prior-hash carry at deployment_ledger.py:929 still passes all 19 PR tests.
  2. [Test Coverage Expert + Python Architect] [IN SCOPE] After the declarative install, assert that local_staged_file_hashes survives. Route the carry-forward through one LockFile helper that copies both fields and enforces the subset invariant, or remove it. -- Evidence missing: deleting the carry-forward still passes. Dropping a hash anywhere silently turns off drift detection for that path.
  3. [Supply Chain Security Expert] [IN SCOPE] When a staged file is skipped on collision, record the bundle digest as a fallback hash. A prior hash still wins. -- A staged file edited before upgrading and then skipped on collision stays unhashed. That is the Record content hashes for bundle compile staging so edits before apm compile are detected #3718 scenario, still open on the upgrade path.
  4. [Supply Chain Security Expert] [IN SCOPE, guarded] Report staged paths that have no hash, but only when local_staged_file_hashes is non-empty. -- A clean post-Record content hashes for bundle compile staging so edits before apm compile are detected #3718 install cannot produce a mix of hashed and hashless staged paths. Today, deleting one hash line silently turns off the check for that path.
  5. [Supply Chain Security Expert + Python Architect] [IN SCOPE] Replace the ad-hoc .. and leaf-symlink checks with containment under apm_modules (ensure_path_within), matching the install side. -- Today the two verifiers decide 'safe to verify' differently. A symlinked apm_modules/<slug> would get its out-of-tree bytes hashed.

Recommendation

The accepted #3718 scope is delivered and nothing blocks. Fold follow-ups 1-3 before merge; 4-6 are small in-scope tightening for the same pass.


Full per-persona findings

Python Architect

  • [recommended] Guard is presence-only: a second staged-hash verifier or writer elsewhere passes the linter at scripts/architecture_linter/checks/install_bundle_compile_staging.py:104
    check_bundle_compile_staging requires needles but never forbids parallel staged hashing/assignment outside the owner files, so 'only verifier / only writer' is convention not enforcement.
    Suggested: Add a negative scan for local_staged_file_hashes assignments / staged hashing outside an allowlist, plus a mutation case.
  • [recommended] local_staged_files and local_staged_file_hashes are kept in lockstep by hand; phases/lockfile.py carry-forward is an unlisted writer at src/apm_cli/install/phases/lockfile.py:693
    Drift silently disables for any path whose hash is dropped by a copy site; only retire_local_staging enforces the subset invariant.
    Suggested: Add LockFile.carry_local_staging_from(other) copying both fields with the subset invariant; route the builder through it and guard it.
  • [recommended] staged_hash_drift uses a weaker path-safety rule (leaf symlink only) than verify_deployed_file_hashes (any symlink component) at src/apm_cli/deps/lockfile.py:1270
    Two verifiers decide 'safe to verify' differently; if apm_modules/ is a symlink, audit hashes out-of-tree bytes (read-only, not exploitable).
    Suggested: Share one containment helper (or ensure_path_within against project_root/apm_modules) between both verifiers.

Supply Chain Security Expert

  • [recommended] Upgrade path: a staged file edited before upgrading and then skipped on collision is recorded with no hash, so the Record content hashes for bundle compile staging so edits before apm compile are detected #3718 edit stays invisible at src/apm_cli/install/services.py:1127
    In integrate_local_bundle the collision branch continues before staged_hashes is populated; with no prior hash (pre-Record content hashes for bundle compile staging so edits before apm compile are detected #3718 lockfile) the path stays in local_staged_files unhashed, staged_hash_drift skips it, audit passes and compile merges the edit silently. In scope: hash every staged file.
    Suggested: On collision skip of a staged file, record the bundle digest as a fallback (prior hash still wins) so the edit surfaces as drift.
    Proof (unknown): tests/unit/deps/test_lockfile_local_staging.py
  • [recommended] Hashless staged entries are silently skipped; deployed files have a missing-ownership fail-closed equivalent at src/apm_cli/deps/lockfile.py:1265
    A mixed state (some staged paths hashed, others not) cannot come from a clean post-Record content hashes for bundle compile staging so edits before apm compile are detected #3718 install; deleting a hash line silently disables the check (decision 19: lockfile hashes alone are never trusted).
    Suggested: Report hashless staged paths only when local_staged_file_hashes is non-empty, with the same restage remedy.
    Proof (unknown): tests/unit/deps/test_lockfile_local_staging.py
  • [recommended] Drift verifier uses an ad-hoc '..' check instead of the path_security containment guard at src/apm_cli/deps/lockfile.py:1266
    Install-side uses ensure_path_within(..., project_root/'apm_modules'); verify side should match.
    Suggested: Use ensure_path_within(file_path, project_root/'apm_modules') and skip on PathTraversalError.

Test Coverage Expert

  • [recommended] No regression trap for edit-then-plain-reinstall: dropping the prior staged-hash carry in record_local_bundle_files survives all PR tests at src/apm_cli/core/deployment_ledger.py:929
    Persona mutated deployment_ledger.py:929 (drop **lockfile.local_staged_file_hashes): PR suite 19 passed; only a temporary probe (install, edit, plain reinstall, audit exit 1) failed. Behavior is correct today but unguarded.
    Suggested: Extend the lifecycle test with a plain reinstall after the edit asserting audit still reports staged hash-drift.
    Proof (missing at): tests/integration/test_local_bundle_compile_only_targets_lifecycle.py
  • [recommended] Declarative-install carry-forward of local_staged_file_hashes is unasserted and the new LockfileBuilder line is not load-bearing at tests/integration/test_local_bundle_compile_only_targets_lifecycle.py:136
    Deleting install/phases/lockfile.py:694 carry-forward still passed with a temp hash assertion, so hashes survive via another path and nothing traps a regression.
    Suggested: Assert local_staged_file_hashes after the declarative install; drop or justify the redundant line.
    Proof (missing at): tests/integration/test_local_bundle_compile_only_targets_lifecycle.py

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

Addresses panel follow-ups 1-3, 5 and 6 on #3898. A staged file skipped
on collision is bound to the bundle digest when it has no prior hash,
so an edit made before upgrading is still drift. Declarative installs
carry staging records and hashes together through
LockFile.carry_local_staging_from. staged_hash_drift now requires
containment under apm_modules, and the bundle-compile-staging guard
rejects staged-hash writes outside the lockfile and ledger owners.
The lifecycle test covers plain reinstall after an edit and the
upgrade path.

apm-spec-waiver: local_staged_file_hashes is an APM lockfile extension outside the OpenAPM v0.1 key list

Co-authored-by: Copilot App <[email protected]>
The staged-hash fold pushed install/services.py past the 1175-line
budget in test_architecture_invariants. Compacts the new collision
fallback and tightens the adjacent comments. No behavior change; the
bundle-compile-staging guard needle follows the compacted line.

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

Addresses Copilot review on #3898. apm compile --watch now reports
staged hash drift before the initial compile and every recompile,
through the same _report_staged_hash_drift reporter. staged_hash_drift
skips staged files behind any symlinked component, matching compile
discovery, which never follows links, so audit makes no claim on content
compile will not read. The bundle-compile-staging guard requires both
watch call sites.

apm-spec-waiver: local_staged_file_hashes is an APM lockfile extension outside the OpenAPM v0.1 key list

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

Addresses delta-panel follow-ups on #3898. An instructions-only bundle
whose only staged file was skipped on collision never wrote the
lockfile, so the fallback hash was lost and an old-lockfile edit stayed
silent; the handler now persists when fallbacks exist. A new lifecycle
test proves an upgrade over unedited staging keeps the install-time
hash (no false drift) and the all-skipped fallback. The compile drift
reporter moves to commands/compile/staging.py, shared by one-shot and
watch compile, and the guard rejects non-owner writes to either staged
field, including augmented and del writes.

apm-spec-waiver: local_staged_file_hashes is an APM lockfile extension outside the OpenAPM v0.1 key list

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Issue #3718 is closed at 6dcfc7c. Every staged compile input now keeps a hash, including the instructions-only upgrade path, and the delta panel's in-scope findings are all folded with tests proven by mutation runs.

panel-mode=delta; personas=python-architect,supply-chain-security-expert,test-coverage-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

Changes since the previous advisory (a40bbdd). The last open path for #3718 is now closed: an instructions-only bundle reinstalled with every file skipped on collision. At d24cd08, supply-chain reproduced that case: the install reported '1 skipped', wrote no hashes, and apm audit --ci exited 0. At 6dcfc7c the handler writes the lockfile whenever staged_file_fallback_hashes exist, and the guard pins that behavior. The new lifecycle test test_instructions_only_bundle_upgrade_keeps_install_time_hash fails when the fix is reverted. The same test covers the precedence gap test-coverage raised: installing v2 over unedited v1 staging keeps the v1 hash and audit stays clean. It also fails when the prior-hash carry is removed. The other commits in the window: 1eadb7d folded first-panel follow-ups 1, 2, 3, 5 and 6, and b309a46 folded the two Copilot review items (watch-mode bypass, symlinked ancestors).

Structure. Both python-architect findings are folded. The static guard now covers writes to local_staged_files and local_staged_file_hashes, including |=, +=, del, popitem, append and extend. A mutation case proves that a write from a module that does not own these fields fails the linter. The shared drift reporter moved to commands/compile/staging.py::report_staged_hash_drift, and one-shot and watch compile both import it at the top.

What stays open. One item is deferred: a non-failing count of staged entries that have no hash (supply-chain #2 and the first panel's follow-up 4). The accepted scope promises that older lockfiles make no drift claim, so new output for legacy lockfiles needs a product decision. CI is green on 6dcfc7c (31 pass, 3 skipped). The exact-head runs passed: 43, 191 and 184 unit tests, plus the 9 + 5 lifecycle tests.

Dissent. The panelists did not disagree. Process note: the panelists reviewed d24cd08, not the final head. The orchestrator verified the folds at 6dcfc7c with mutation-break runs.

Aligned with: secure by default: Every staged compile input that APM writes or skips on collision now keeps a hash, and apm audit --ci fails on drift, including on the instructions-only upgrade path.; governed by policy: The apm audit --ci content-integrity check covers staged inputs on every install path. The static guard keeps writes to both staged fields inside their owning modules.; portable by manifest: A prior hash wins over the bundle fallback, and a lifecycle test proves it. Older lockfiles without hashes still load with no false drift claims.; pragmatic as npm: There is no new command or flag. Compile warns, audit fails, and apm install <bundle> --force restages. Watch and one-shot compile report drift through the same code.

Panel summary

Persona B R N Takeaway
Python Architect 0 2 0 All three prior findings are resolved. Small follow-ups: guard the paired field and augmented writes; move the shared drift reporter out of cli.py.
Supply Chain Security Expert 0 2 0 Folds (3) and the (2) deferral boundary are sound. Fold (1) missed instructions-only bundles where every file is skipped; reproduced silent audit pass.
Test Coverage Expert 0 1 0 Both prior findings are resolved by lifecycle assertions. Gap at d24cd08: prior-hash-over-fallback precedence was proven only at unit tier.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 1 follow-ups

  1. [Supply Chain Security Expert] [DEFERRED, needs product decision] Report staged entries that have no hash (a non-failing count, shown only when local_staged_file_hashes is non-empty), and decide whether a mix of hashed and hashless entries should eventually fail closed. -- A hashless entry is skipped without a message. It is out of scope here because it adds new user-facing output on legacy lockfiles, which the accepted scope promises make no drift claim.

Recommendation

Merge after the CODEOWNER review from Sergio Sisternes (@sergio-sisternes-epam), which is the only remaining gate: CI is green and the PR is mergeable. Every in-scope finding from both panels and from Copilot review is folded, and the tests behind the folds fail when the fixes are reverted. The deferred hashless-entry report needs a product decision.


Full per-persona findings

Python Architect

  • [recommended] Negative writer scan covered only local_staged_file_hashes and missed augmented/del writes at scripts/architecture_linter/checks/install_bundle_compile_staging.py
    The subset invariant spans both fields; a non-owner local_staged_files writer or |= / del would pass the guard. No live writer exists today.
    Suggested: Widen the regex to both fields plus |=, del, popitem, append/extend; add a mutation case.
  • [recommended] _report_staged_hash_drift is a private cli.py helper with call sites in two modules at src/apm_cli/commands/compile/cli.py:885
    Shared compile pre-flight depended on a private symbol of the click command module via lazy imports.
    Suggested: Move to commands/compile/staging.py report_staged_hash_drift and import it at the top of both modules.

Supply Chain Security Expert

  • [recommended] Fallback hash lost when every bundle file is collision-skipped (instructions-only bundle) at src/apm_cli/install/local_bundle_handler.py:334
    local_bundle_handler wrote the lockfile only if deployed or staged_instructions; an all-skipped reinstall dropped the fallback. Reproduced at d24cd08: '1 skipped', no hashes, audit --ci exit 0.
    Suggested: Persist when fallbacks exist; add an instructions-only lifecycle case and a guard pin.
    Proof (missing at): tests/integration/test_local_bundle_compile_only_targets_lifecycle.py
  • [recommended] Deferral of fail-closed on hashless entries is sound; a non-failing info count would surface them at src/apm_cli/deps/lockfile.py:1281
    A retired file has no bytes to bind, so failing closed needs a product decision; silent skip hides future writer bugs.
    Suggested: Optional info line with a count of hashless staged entries; widen the write regex to |=, del, popitem.

Test Coverage Expert

  • [recommended] Prior-hash-wins-over-bundle-fallback had no lifecycle case (newer bundle over unedited staging) at tests/integration/test_local_bundle_compile_only_targets_lifecycle.py:203
    If the fallback won, a plain v2 install over unedited v1 staging would make audit --ci report false hash-drift; lifecycle could not tell the two apart because pack() always shipped the same bytes.
    Suggested: Repack with changed text, plain reinstall, assert hash unchanged and audit clean.
    Proof (missing at): tests/integration/test_local_bundle_compile_only_targets_lifecycle.py

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit bf5867a into main Nov 19, 2026
34 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-bug-3718-staged-hashes branch November 19, 2026 08:51
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 19, 2026
Keep the one-line [Unreleased] block; add #3898 and #3905 one-line entries.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record content hashes for bundle compile staging so edits before apm compile are detected

2 participants