Skip to content

Add safe managed lifecycle for generated host bundles #101

Closed

Description

@ScriptedAlchemy

Summary

Move from build-only host artifacts to an optional, receipt-backed lifecycle:
preview, install, update, repair, uninstall, rollback, recovery, and Doctor
verification. Preserve unrelated host configuration and apply component sets
atomically.

Problem

Generating valid plugin directories is insufficient for complex integrations.
Hosts may own shared JSON/TOML registries, require their own CLI installer,
prompt for trust, stage a plugin before activation, or use native extension
directories. Updating one component must not remove another or overwrite
third-party settings.

TraceDecay currently implements these guarantees itself. Agent Bundle should
make them a reusable framework capability after the host component compiler
can describe exact ownership.

Lifecycle

inspect observed state
  -> preview immutable mutation plan
  -> require exact confirmation digest
  -> backup owned/shared documents
  -> apply component transaction
  -> host-specific activation
  -> verify native registration and artifact bytes
  -> publish receipt

Supported operations:

  • install;
  • update;
  • repair;
  • uninstall;
  • rollback to the prior confirmed component set;
  • recover an interrupted journal.

Safety requirements

  • safe, canonical install roots with symlink/path-escape refusal;
  • content digests and ownership markers per artifact;
  • exact preview/apply revision pairing;
  • component-scoped backups and receipts;
  • atomic or journaled multi-file writes;
  • structured merges that preserve unrelated host keys;
  • host CLI registration where the host owns its registry;
  • competing-extension detection;
  • explicit manual-activation state where automation is unavailable;
  • no credentials in manifests, receipts, or logs.

Doctor

Doctor reports each component as installed, missing, repairable, deferred,
conflicted, unavailable, or corrupt. It verifies:

  • artifact content and provenance;
  • native host registration;
  • activation/trust state where observable;
  • protocol/runtime compatibility;
  • receipt and backup integrity;
  • stale or interrupted journal recovery.

Non-goals

  • Claiming installation merely because files were generated.
  • Replacing a shared host configuration wholesale.
  • Remotely distributed third-party bundles without a separate trust model.
  • Automatically trusting hooks or extensions on the user's behalf.

Acceptance criteria

  • Dry run opens no writer and reports exact planned paths and shared-config
    mutations.
  • Install and update preserve unrelated host configuration.
  • An interrupted multi-component install recovers or rolls back safely.
  • Repair restores owned artifacts without adopting foreign paths.
  • Uninstall removes only receipt-owned artifacts and registrations.
  • Doctor distinguishes activation deferred from installed-and-active.
  • At least two materially different host registration mechanisms pass real
    lifecycle tests.

Design references

Stack position

Full meta-framework stack

Activity

  1. added
    enhancement
    meta-framework
    host-integration
    on Aug 31, 2026
  2. ScriptedAlchemy commented on Sep 1, 2026

    @ScriptedAlchemy
    OwnerAuthor

    Stage 1 (read-only Doctor) — delivered vs deferred

    Per the G4 gate decision in #107 rev 2 (installer deferred; read-only Doctor only), stage 1 landed in PR #236 (merge cbbaf0e90c1303d037df9cdcbe1b2adff1076a5b).

    Delivered

    • agent-bundle doctor [--host <host>…] [--from <bundle-dir>] [--json] — additive CLI surface next to install, strictly read-only: doctor only ever lstats, readdirs, readFiles, and probes sockets. There is no --fix, no writer, and no mutation path; repair guidance is recovery text only.
    • Host probes with honest states: claude/codex bounded --version probes (the feat(claude): validate artifacts with host devtools #193 pattern — ENOENT is an info unavailable skip, a probe that starts but fails/times out is an error failed); Cursor via its pinned directory evidence (~/.cursor), since no Cursor version-probe contract is pinned.
    • Installed-bundle discovery — Cursor: full inventory of ~/.cursor/plugins/local using the pinned loader-manifest candidate order, with corrupt (symlinked entry, manifest-less or unparseable), and interrupted-install (.name.stage-* leftovers from feat(install): make host bundles directly installable #195's staged copies) findings. Claude/Codex: honestly unknown — the hosts own their registries and no read-only inventory verb is pinned.
    • Drift/broken-install detection against a built bundle (--from) — Cursor: installed / missing / drifted (tree-digest mismatch via feat(install): make host bundles directly installable #195's treeHash) / conflicted (version collision) / corrupt (unsafe tree). Claude: registration proof via the pinned claude --plugin-dir <dir> plugin list --json verb. Codex: unknown (no pinned read-only verb).
    • Runtime endpoint health — scans the event-runtime endpoint directory (derivation locked to events/ipc.ts by a regression test): stale-socket warnings, and claim locks interpreted per fix(events): reclaim provably-dead orphaned endpoint claims instead of failing permanently #229's owner-record semantics — invalid owner record or provably-dead owner → stale-lock warning (the runtime auto-reclaims provably-dead claims at next start); an owner that cannot be proven dead → reported live with an info note that the runtime fails closed rather than stealing claims. win32 endpoint enumeration is an honest skip.
    • Diagnostics AB7300–AB7315 with recovery text, registered in docs/diagnostics.md (also records feat(install): make host bundles directly installable #195's AB700x family, previously undocumented). Exit code is nonzero only on error-severity findings; honest skips and warnings never gate. Minor changeset included.

    Deferred (with reasons)

  3. ScriptedAlchemy commented on Sep 1, 2026

    @ScriptedAlchemy
    OwnerAuthor

    Host-side evidence for the shared-vs-per-host skills/ tree question (from #100 stage 3 real installs, #242)

    #108 left the layout decision inspect-visible (skillTreeLayout.decision: shared | per-host-required, feeding this issue). Real installs against Claude Code 2.1.257, codex-cli 0.147.0, and Cursor's documented local-plugin path now give host-side facts:

    1. Every host materializes a per-plugin tree; no host consumes a cross-plugin or cross-host shared skills/ root.
      • Claude: plugin install copies the whole bundle to <config>/plugins/cache/<marketplace>/<plugin>/<version>/, skills at <installPath>/skills/<name>/SKILL.md; plugin details inventories skills from that copy.
      • Codex: identical layout — <CODEX_HOME>/plugins/cache/<marketplace>/<plugin>/<version>/, including per-skill agents/openai.yaml sidecars.
      • Cursor: physical copy at ~/.cursor/plugins/local/<plugin>/ with the manifest pointing at skills: './skills/' relative to the plugin root.
    2. Skill identity is derived from the per-plugin tree, not a shared root: in a real Claude session, ${CLAUDE_SKILL_DIR} resolved to <bundle>/skills/<skill> of the loaded plugin (observed 2.1.257, opt-in session proof in feat(test): host-install proof level with real Claude, Codex, and Cursor install proofs (#100 stage 3) #242).
    3. When tokens are present, lowered SKILL.md content genuinely differs per host — Claude spellings are substituted, and AB3008 correctly refuses token-bearing skills for hosts with no equivalent. So a single shared tree cannot serve all hosts whenever any skill uses tokens or host extensions; byte-identical portable documents remain valid for shared.
    4. Lifecycle implications for this issue: skills are plugin-owned artifacts inside host-owned per-plugin install roots — install/update/uninstall transactions can treat skills/ as part of the owned component set with no shared-registry merge concerns; version collision semantics are already host-enforced via versioned cache directories (Claude/Codex) and refused fail-closed by the Cursor installer (AB7005).

    Net: the #108 per-host-required decision is confirmed host-side for any skill with tokens/extensions; shared remains honest only for byte-identical portable documents. The composite plugin target's install-time selection (this issue's scope) can rely on hosts isolating each plugin's tree.

  4. ScriptedAlchemy commented on Sep 2, 2026

    @ScriptedAlchemy
    OwnerAuthor

    Decision (2026-09-01): G4 stays — mutation lifecycle (repair/uninstall/rollback/receipts) remains deferred; doctor's read-only suggestions are the supported surface for now.

  5. ScriptedAlchemy commented on Sep 3, 2026

    @ScriptedAlchemy
    OwnerAuthor

    Status (2026-09-02): intentionally deferred by the maintainer — no lane is implementing this

    Per the owner decision recorded on 2026-09-01 ("G4 stays — mutation lifecycle (repair/uninstall/rollback/receipts) remains deferred; doctor's read-only suggestions are the supported surface for now"), this issue stays open and unimplemented on purpose. Nothing here was worked in the current wave beyond verification.

    Verified on origin/main (af1c18551)

    Still deferred (unchanged)

    Receipts/journal, update/repair/uninstall/rollback, format-preserving merges, any --fix flag, Claude/Codex installed-inventory discovery (no pinned read-only verb), and Workbench exposure of mutation (permanently out per G6). Revisit only when #100's ownership model is stable and two real consumers repeatedly need managed installs.

  6. ScriptedAlchemy commented on Sep 4, 2026

    @ScriptedAlchemy
    OwnerAuthor

    Closed by #452 — merged to main as e647336d7 (2026-09-04)

    Deferral reversal, stated plainly. The 2026-09-01 decision kept the mutation half of this issue behind the G4 gate (read-only Doctor landed in #236). On 2026-09-03 the maintainer asked that every open agent-bundle issue be fixed, which reverses that deferral. #452 ships the mutation half with every mutation opt-in (a separate uninstall verb; nothing runs on install or doctor), receipt-owned (only what the receipt records is ever removed), and fail-closed (missing/foreign/mismatched receipt, unconfirmed purge, unusable host inventory, dirty staged marketplace all refuse before any change).

    Item Status Evidence
    agent-bundle uninstall <host> — CLI, package-relative installer bin, emitted install.mjs --uninstall Done packages/agent-bundle/src/install/uninstall.ts, install-entry.ts, surface.ts; tests/uninstall.test.ts, tests/installer-entry.test.ts, tests/install-surface.test.ts
    Removes exactly receipt-owned files/dirs + host registrations (Claude marketplace/plugin, Codex plugin, Cursor local dir / marketplace staging) Done Host-install proofs: byte-identical isolated home for Cursor local + portable; zero Agent Bundle residue for Claude 2.1.257 / Codex 0.147.0 with every remaining entry classified as host bookkeeping
    --keep-data (default) / --purge-data --confirm-purge Done state/, Cursor PLUGIN_DATA, Claude plugins/data/<id> kept behind a remnant receipt or purged; AB7008 refuses an unconfirmed or shared purge; Codex's no-keep-data reality typed removed-by-host
    Refuse missing/foreign receipt unless --force Done AB7009 missing, AB7007 mismatch/dirty staged tree; foreign and other-plugin receipts refused even with --force
    --plan dry run with exact paths; idempotent Done Plan == result (files, directories incl. receipt-store pruning, host verbs) asserted in unit tests and proofs; rerun after uninstall is not-installed
    Trust/activation states in installer + doctor (placed → registered → enabled → active, typed unavailable) Done doctor.ts lifecycle, aggregated across Claude scopes; AB7330; dated lifecycle capability rows per host; adapter revisions advanced
    Receipts as single source of truth (format/2: version, hash, mode, scope, owned paths, registrations, hostDirectories, timestamps) with migration Done receipt.ts; store receipts <plugin>.<marketplace>.<scope>[.<project digest>].json; format/1 read with migratedFrom + AB7329, orphaned/unreadable store receipts AB7328; malformed receipts never crash
    Install rollback when the plugin install or receipt write fails after marketplace add Done install.ts; tests/install.test.ts rollback cases; AB7004 names the manual cleanup commands if rollback also fails
    Safety proofs (install → uninstall snapshot diff for claude/codex/cursor/portable, keep-data, foreign/missing refusal, plan no-op, packed tarball) Done tests/host-install-proof.test.ts (25 passed), tests/packed-host-install-proof.test.ts (6 passed) on 96d31e07b; CI Host install proofs green on 9e69e8ac9
    Docs + changeset Done docs/diagnostics.md, docs/framework-mode.md, package README, INSTALL.md template, site en+zh cli.mdx/installation.mdx; .changeset/101-managed-lifecycle.md

    Gates on the merged head (local + CI): typecheck, lint, unit (3169), route-unit, projection, build + integration (986), host-install proofs, packed proofs, docs site — all green. Codex reviewed rounds 1–6 (all threads fixed in code); the final three @codex review requests received no response, so the unreviewed SHAs are recorded in the PR body and the merge went on CI green per lane rules.

  7. chatgpt-codex-connector commented on Sep 4, 2026

    @chatgpt-codex-connector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhost-integrationmeta-framework

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions