fix(sec-core): prevent adapter bytecode drift - #2265
Conversation
- Stop Python hooks from mutating digest-managed adapter resources. - Sweep historical caches during RPM installation and raw updates. - Keep full bundle hashing with strict raw post-install hooks. Fixes: 1a769d3 ("feat(sec-core): qwen plugin and observability hooks") Signed-off-by: kongche-jbw <kongche.jbw@alibaba-inc.com>
Why this fix uses
|
Why
sec-core Python hooks can create
__pycache__/*.pycinside digest-managedadapter resource roots. The next
anolisa adapter statusthen reports ahealthy adapter as degraded even though no managed source or manifest changed.
The digest must continue covering every managed byte, so this fixes the writer
and cleans historical runtime caches instead of weakening integrity checks.
What changed
-B.raw packaging/install flows.
post_installhooks during raw updates, resolvingthem before host mutation and rolling back on failure.
shared digest implementation.
resolution, strict-hook rollback, and ordinary bundle drift detection.
Related issue
Closes #2252
User / Agent impact
Normal sec-core hook execution no longer changes adapter health. Upgrading a
historical raw or RPM installation removes safe derived bytecode caches from
the six contract-owned adapter roots. Source, manifest, symlink, orphan
bytecode, and foreign payload changes remain detectable.
Risk and compatibility
Cleanup is restricted to sec-core contract-declared adapter roots and only
removes validated Python cache content. A strict cleanup failure aborts and
rolls back the raw update. Raw
pre_installand repair replay semantics areunchanged; only update
post_installis wired.The bundle digest format and receipt schema are unchanged.
Validation
cargo fmt --all -- --checkcargo check --workspace --lockedcargo test --locked --test update_adapter_actions— 8 passeduv run --project agent-sec-cli pytest -q tests/packaging/test_adapter_bytecode.py— 18 passed
tests/packaging/test-package-raw.shbash -nfor the cleaner, raw hook, package script, and package testtime.tzsetfailures on the local CPython build.rpmspecandrpmbuildare unavailable locally, so RPM macro/parservalidation remains outstanding.
Documentation and rollback
No user documentation changed. Reverting this commit restores the prior hook
and raw update behavior; the digest and receipt formats need no rollback.
Draft blockers before Ready
0.9.0in every version-bearingfile so raw clients can select an actual update and run the cleanup hook.
min_anolisa_versionto the released anolisa version that contains thisraw
post_installsupport. It must be newer than the affected0.2.17release.
index-v2.tomlonly;keep it out of the legacy index so older raw clients cannot select a package
whose cleanup hook they do not execute.
rpmspec/rpmbuild.Keep this PR in Draft until the anolisa version, sec-core version, and catalog
publication are synchronized.