Skip to content

fix(skills): harden duplicate skill retirement paths, deduplicate manifest reads, and eliminate Any - #9427

Open
hhyykk wants to merge 2 commits into
mainfrom
codex/skill-readback-zero-any-io
Open

hhyykk wants to merge 2 commits into
mainfrom
codex/skill-readback-zero-any-io

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

  • Outcome basis / optional anchor: Self-contained host skill installation readback hardening, hot-loop I/O deduplication, and Zero-Any typing cleanup.
  • Goal/source and gap: loopx/skill_install_readback.py previously carried 14 Any annotations, re-read and re-parsed target/.loopx-skill-install.json on every non-facade candidate iteration inside retire_duplicate_managed_skills, read candidate/SKILL.md twice per candidate for facade marker checks, deduplicated candidate_dirs via linear list scans, and did not guard against target/<skill> or target/<skill>/SKILL.md symlinking or resolving inside alternate/<skill> before shutil.rmtree(candidate).
  • Observable before → after, with the validation row that proves it:
    • Before: retiring N rich managed duplicate skills read target/.loopx-skill-install.json N times and read each candidate/SKILL.md twice during facade checks; a symlinked replacement resolving into alternate/<skill> could delete the underlying copy; module_metrics("loopx/skill_install_readback.py")["any_count"] was 14.
    • After: target/.loopx-skill-install.json is lazily read at most once on the first non-facade replacement (0 reads when all candidates are command facades), each SKILL.md is read once for facade classification, candidates whose target, replacement, or replacement/SKILL.md are symlinks or resolve into candidate are safely skipped and preserved, and any_count / dict_any_count are 0 under mypy --strict. Proven by tests/test_skill_discovery_reconciliation.py.
  • Issue/task and intended base: Self-contained maintenance and safety fix targeting main.

Author Declaration

  • Written by: OpenAI Codex (GPT-6 Luna model agent), orchestrated and independently verified by Google Gemini.

Implemented against

  • Specification and revision: No separate written specification; the request in this PR and existing contracts in loopx/skill_install_readback.py at origin/main are the basis.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
Eliminate all Any annotations in skill_install_readback while preserving public return contracts implemented loopx/skill_install_readback.py mypy --strict loopx/skill_install_readback.py and test_skill_install_readback_has_no_any_annotations
Deduplicate candidate directory discovery, single-pass facade marker reads, and lazy single-read target manifest loading implemented retire_duplicate_managed_skills, _read_target_skill_manifest in loopx/skill_install_readback.py test_retirement_reads_target_manifest_lazily_once in tests/test_skill_discovery_reconciliation.py
Prevent deleting a candidate when target, replacement, or replacement/SKILL.md is a symlink or resolves inside candidate implemented _replacement_paths_are_safe in loopx/skill_install_readback.py test_retirement_skips_replacement_that_resolves_into_candidate in tests/test_skill_discovery_reconciliation.py
  • Self-check before submission: Reviewed the full diff line by line, verified any_count == 0 and dict_any_count == 0, ran ruff, mypy --strict, focused reconciliation and installation pytest suites, semantic vocabulary drift checks, loopx check public-boundary scan, check_rfc_bilingual.py, and loopx canary premerge.

Scope And Continuation

  • Completed scope and remaining work: Complete within this scope (loopx/skill_install_readback.py and tests/test_skill_discovery_reconciliation.py).
  • Slice boundary / successor: N/A — self-contained module hardening and test update.

Validation

  • Tested revision: b296c125c129a1c58039cef9146e5957338027fa
  • Run state: finished
  • Input classes: synthetic, public_fixture
Check kind Result Public-safe evidence / limitation
static passed ruff check loopx/skill_install_readback.py tests/test_skill_discovery_reconciliation.py, mypy --strict loopx/skill_install_readback.py, module_metrics (any_count=0, dict_any_count=0), loopx check public-boundary scan, and scripts/check_rfc_bilingual.py --base origin/main --head HEAD.
unit passed pytest -q tests/test_skill_discovery_reconciliation.py (21 passed), verifying lazy single-read manifest loading, single-read facade detection, symlink/nested-target preservation, and zero-Any metrics.
integration passed pytest -q tests/test_workflow_skill_install.py tests/test_doctor_install_freshness.py tests/test_install_source_git_provenance.py tests/test_project_skill_cli.py tests/test_ark_managed_agent_host.py tests/architecture/test_managed_slash_command_marker_owner.py and loopx canary premerge --from-git-diff --git-diff-base origin/main.
  • Coverage and gaps: Changed skill readback and duplicate reconciliation paths are covered on Linux with synthetic skill trees; Windows/macOS live host profile upgrades were not separately executed.

See validation disclosure guidance.

Frontend / Visual Evidence

  • UI impact: none
  • Before: N/A
  • After: N/A
  • First viewport and preview: N/A
  • States and viewports shown: N/A
  • Source data: none
  • Attention review: N/A
  • Craft review: N/A

Type of Change

  • Bug fix
  • Refactoring (no functional changes)
  • Test update

LoopX Area

  • Host or runtime integration

Technical Direction

  • Direction / acceptance reference, when applicable: Core host installation hygiene and deterministic readback safety.

Shared-authority RFC fixture impact

  • Production-scale fixture schema: N/A
  • Semantic dimensions changed, or reviewed no-impact rationale: N/A
  • Provider conformance arms run: N/A
  • Read-only legacy/file/PostgreSQL three-arm rehearsal (required for promotion, runtime-routing, or compatibility-projection changes): N/A

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check python3 scripts/check_rfc_bilingual.py --base origin/main --head HEAD passes, or no paired RFC changed.
  • I completed the visual evidence section for UI changes, or marked UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T03:13:40.965788Z f539f7c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

[P2] 清单更新后,退役仍沿用旧的目标安装证明

在隔离目录中让目标安装清单在一次退役预览内换代。新清单只认证第一项,基线保留第二项,候选仍把第二项列入 would_retire。两份源技能都保留,未执行删除。 第 228 行把首次读取的当前清单复用到之后所有候选。工作流安装器释放目标安装锁后才调用退役,缓存没有覆盖发布新清单的边界。 让清单发布和退役共用现有安装锁,或在决定保留或删除前验证快照代际,观察到清单变化时重读或保留现有副本。保留 facade 的零清单读取快路径。 对应源码

动机 / Motivation

同一个主机能发现两处 skills 目录,安装器需要去重,同时保留仍然可用的替代副本。 基线逐项检查完整技能的目标清单,因此每项决策会看到当时已发布的安装证明。 稳定清单的计划一致。换代时基线保留本轮缺少安装证明的副本,候选仍计划退役。 本轮核对安装清单、预览决定及两处可用副本。 适用依据

改动思路 / Approach

代码仍由既有文件所有者读取清单和两处技能树,识别命令 facade、已管理的完整技能和回读摘要,然后才输出计划或退役。 修复应落在现有清单读写和退役决定之间。 降低 IO 的快照方案要和当前安装代际绑定。 可用原子清单的单次快照降低读取,但要用同一提交边界保证之后的判断有效。给候选层叠加另一个独立清单所有者会增加冲突。 以调用真实安装路径的可用副本和结果回读为验收。稳定输入的 IO 数量不足以验证安装和退役重叠。

具体改动 / Changes

本轮精确 head b296c125c129a1c58039cef9146e5957338027fa。当前评审包基线 3347302d17195fc63fdb916f96fdd18fc00f0ebf,完整差异与源码验证以实际共同祖先 3347302d17195fc63fdb916f96fdd18fc00f0ebf 为准。新增测试覆盖同一清单的 IO 合并、路径拒绝和类型度量。本次另检验清单代际改变,原测试使用稳定清单。

  • 稳定清单退役。本 PR 给替代路径增加守卫,收敛候选的重复查找和 facade 读入。稳定目标下,单次读取复用对照保持原退役计划。
  • 换代后保留副本。退役完整技能前,资格应基于与替代副本对应的当前安装清单。

关键代码讲解

整份变更新增 184 行、删除 41 行,范围为技能安装回读和其 reconcile 测试。返回字典类型收窄,外层回执字段保持不变。 候选枚举保留排序并用集合去重。替代目录与主文件检查阻止危险路径。facade 分类保持单次读取。完整技能的分支首次加载目标清单,后续候选继续拿同一清单和实际目录哈希比较。安装器在释放目标锁之后才进入这个分支。

对主干的风险 / Risks

PASS。在相同的两份普通技能和不变清单上,基线和候选都只计划退役两项。两侧现有副本均未修改。 源码 premerge 6 项直接检查、8 项所选检查均通过。 技能发现、工作流安装、doctor 及宿主入口相关测试 140 通过、2 跳过。

FAIL。在隔离目录中让目标安装清单在一次退役预览内换代。新清单只认证第一项,基线保留第二项,候选仍把第二项列入 would_retire。两份源技能都保留,未执行删除。 以同一隔离树做稳定和换代对照,检查当前清单、基线与候选的计划及源文件保留。

语义与 CI 对齐

读取次数减少可保留。当前还缺少把该快照生命周期与安装代际关联的前置条件。 实测涵盖 macOS 上的隔离技能树、真实清单 writer 与预览。换代顺序由测试控制,未在安装中的用户 profile 执行删除,未查询远端 CI。

我的整体评价 / Verdict

请求修改。本 PR 给替代路径增加守卫,收敛候选的重复查找和 facade 读入。稳定目标下,单次读取复用对照保持原退役计划。 让清单发布和退役共用现有安装锁,或在决定保留或删除前验证快照代际,观察到清单变化时重读或保留现有副本。保留 facade 的零清单读取快路径。

English verdict: REQUEST_CHANGES at b296c12. The lazy manifest cache can keep scheduling a skill for retirement after a newer installation manifest no longer verifies its replacement.

@mergify

mergify Bot commented Nov 28, 2026

Copy link
Copy Markdown

Hi @hhyykk, the DCO Sign-off check did not pass. Please inspect
its details first: checkout, fetch, timeout or infrastructure errors
need their own recovery, not a rewrite of otherwise signed commits.

If the log confirms a missing Signed-off-by trailer, amend the
affected commit with git commit --amend -s; for multiple commits,
use an interactive rebase against the current base from the correct
base-repository remote and sign off each affected commit. Push the
rewritten PR branch with git push --force-with-lease origin HEAD.

This branch has not been deployed

No deployments
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.

3 participants