Skip to content

refactor: dedup installer helpers and simplify marked-block splicing - #254

Merged
ScriptedAlchemy merged 5 commits into
masterfrom
simplify/dedup-installers
Jul 3, 2026
Merged

refactor: dedup installer helpers and simplify marked-block splicing#254
ScriptedAlchemy merged 5 commits into
masterfrom
simplify/dedup-installers

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Goal: finish the Claude-deferred /simplify follow-ups from the plugin-bundle/installer cleanup without duplicating merged/open work, while preserving installer safety boundaries.

Detailed execution plan:

  1. Start from latest master and verify the branch contains origin/master.
  2. Reconcile open PRs/worktrees first; use existing active branch simplify/dedup-installers instead of creating a duplicate PR.
  3. Apply only behavior-preserving dedupes called out by Claude/reviewer sessions:
    • clone MCP hook route cache once per refresh
    • share tracedecay marker detection and recursive file walking
    • derive Codex retired-skill sweep from the shipped bundle
    • share manifest version stamping and MCP command rewrite helpers
    • simplify marked-block splicing and derive prompt-index targets
    • reuse the LSP file-URI encoder from Kiro
  4. Re-check skipped items explicitly:
    • full Cursor/Codex reconcile-primitive consolidation
    • job_webhook transport replacement
    • git.rs PATH resolver/broker reuse
    • safe_relative_path guard pattern
    • remove_range vs prompt_rules::splice_out
  5. Verify with commit-message, fmt, clippy, build, lib, agent, hooks/LSP, and core CLI test gates.

Applied:

  • perf(mcp): hook route cache now clones once under the lock via refresh_into, removing the prior snapshot() plus clone_from double-clone.
  • agents: skill_contents_have_tracedecay_marker and recursive collect_regular_files live in agents::mod instead of cursor/codex copies.
  • agents: Codex retired-skill sweep now derives from the live bundle keep-set, matching Cursor's safer pattern and removing the stale 19-entry list.
  • agents: manifest version stamping and MCP command rewriting moved to plugin_bundle::{stamp_manifest_version,set_mcp_command}.
  • skills: replace_or_append_marked_block resolves the target range once via splice_range; remove_all_marked_blocks derives target files via writes_prompt_index() and reuses prompt_rules::SKILL_INDEX_START.
  • agents: Kiro file URI handling reuses file_uri_from_path_text, gaining the same Windows-drive and UNC behavior as LSP diagnostics.
  • tests: the canceled-refresh recovery test now uses the existing recovery timeout on the recovery leg, matching nearby crash-recovery tests and avoiding macOS full-suite spawn/scheduling flakes.

Deliberately deferred, after re-check:

  • Full Cursor/Codex "reconcile owned plugin dir" consolidation: not simplify-safe in this PR. It is large and security-relevant; this PR removes the worst duplication around marker detection, bundle-derived sweep, manifest stamping, and command rewrite without changing ownership/deletion behavior.
  • job_webhook to ureq: not safe. The hand-rolled transport connects to a pre-validated SocketAddr to preserve SSRF/DNS-rebind pinning.
  • git.rs PATH resolver to broker: not applicable. Broker answers bool; the resolver needs the actual path.
  • safe_relative_path: left alone as the existing codebase-wide guard pattern.
  • remove_range to prompt_rules::splice_out: left alone. remove_range preserves trailing-newline semantics for managed skill files; splice_out trims final whitespace.

Validation:

  • scripts/check-conventional-commits.sh origin/master..HEAD: pass
  • cargo fmt --all --check: pass
  • cargo clippy --all-targets -- -D warnings: pass
  • cargo build: pass
  • cargo nextest run --lib: 795 passed
  • cargo nextest run --test agent_suite: 427 passed
  • cargo nextest run --test core_cli_suite: 189 passed
  • cargo nextest run --test hooks_lsp_suite broker_cancels_partial_refresh_without_poisoning_warm_client: pass
  • cargo nextest run --test hooks_lsp_suite: 116 passed

Production code tests were not modified; the only test change widens an already-designated recovery path timeout.

@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 60bfa38

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy
ScriptedAlchemy force-pushed the simplify/dedup-installers branch from 93ca93b to f764f8c Compare July 3, 2026 21:40
ScriptedAlchemy added a commit that referenced this pull request Jul 3, 2026
…255)

`broker_cancels_partial_refresh_without_poisoning_warm_client` asserts
that aborting a partial refresh does not poison the broker: a subsequent
refresh must spin up a clean client. On a loaded macOS CI runner the
recovery client's `python3` cold-start intermittently exceeds the 3s
initialize floor, surfacing a transient "initialize timed out" — a slow
start, not a poisoned broker — which failed the test on two consecutive
unrelated PRs (#253, #254).

Retry the recovery refresh a bounded number of times (5, 50ms apart),
tolerating only the transient initialize-timeout error and still failing
fast on any other error. The Ready/total_errors assertions are unchanged.

Co-authored-by: Claude <noreply@anthropic.com>
ScriptedAlchemy and others added 5 commits July 3, 2026 22:04
The per-request route refresh deep-cloned the shared cache twice: once in
`snapshot()` and again via `clone_from` inside `refresh_from_shared`. Add
`SharedHookProjectRouteCache::refresh_into`, which clones the shared cache
exactly once under the lock and moves it into the target, preserving the
target's local `project_path`. Drops the throwaway intermediate clone.

Co-Authored-By: Claude <noreply@anthropic.com>
Three sets of byte-identical duplication across the host installers:

- Hoist `skill_contents_have_tracedecay_marker` and the recursive
  `collect_regular_files` walker into `agents::mod` and route the Cursor
  (and, next commit, Codex) copies through them.
- Add `plugin_bundle::{stamp_manifest_version, set_mcp_command}` and route
  Claude, Cursor, and Codex manifest/MCP-command rewrites through them.
  Codex layers its scope-specific args/env on top of the shared base.

Behavior is byte-identical; the shared helpers reproduce each host's exact
output (pretty JSON + trailing newline, same marker clauses/walk order).

Co-Authored-By: Claude <noreply@anthropic.com>
Replace the hand-maintained 19-entry `RETIRED_CODEX_PLUGIN_SKILL_DIRS`
list with the same bundle-derived sweep Cursor already uses: enumerate
`skills/<dir>` on disk, keep whatever the live embedded bundle ships plus
the agent-managed overlays, and remove any other dir whose `SKILL.md`
carries a tracedecay marker. A newly retired skill is now swept
automatically without editing a legacy list.

Security-preserving: only non-shipped dirs that are demonstrably
tracedecay-owned are removed; a same-name user-authored skill without a
marker is left untouched (covered by update_plugin_test). Also routes the
codex marker predicate and file walk through the shared helpers.

Co-Authored-By: Claude <noreply@anthropic.com>
- C: collapse the twin if-let/else-if-let arms in
  `replace_or_append_marked_block` — resolve the target range once (this
  target's slugged block, else the legacy unslugged one) and splice via a
  single `splice_range` helper.
- D: derive the prompt-block target subset in `remove_all_marked_blocks`
  from `ALL_SKILL_INSTALL_TARGETS` via a new
  `SkillInstallTarget::writes_prompt_index()` predicate instead of a
  hardcoded 5-entry list, so the two stay in sync. The derived set equals
  the previous {Claude, Agents, OpenCode, Kimi, Kiro} exactly.
- K: point the local `PROMPT_INDEX_START` at the identical
  `prompt_rules::SKILL_INDEX_START` literal. `remove_range` and
  `splice_out` differ in trailing-newline normalization, so they are left
  separate.

Co-Authored-By: Claude <noreply@anthropic.com>
Kiro had a byte-duplicated `file_resource_uri` +
`percent_encode_file_uri_path`. Widen the LSP client's
`file_uri_from_path_text` to `pub(crate)` and have kiro delegate to it,
deleting the private copies. POSIX paths encode identically to before;
kiro now also gains the client's Windows drive-path and `//` UNC handling.

Co-Authored-By: Claude <noreply@anthropic.com>
@ScriptedAlchemy
ScriptedAlchemy force-pushed the simplify/dedup-installers branch from d00e2e0 to 60bfa38 Compare July 3, 2026 22:04
@ScriptedAlchemy
ScriptedAlchemy merged commit 66d601a into master Jul 3, 2026
16 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the simplify/dedup-installers branch July 4, 2026 01:13
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.

1 participant