# Package changes

> Adding, updating or removing what your wallet is allowed to do, in plain words first, then how the agent checks curator-signed packages, composes a new permission root and takes it through your signature to activation.
>
> Describes Orbit 0.1.8. Web page: https://dialectic-orbit-docs.vercel.app/0.1.8/using/package-changes/

This page covers changing what your wallet is allowed to do: adding a package, updating or removing one, or changing an optional setting such as Gas Top Up, Token Transfers or the list of perp markets. The first part is in plain words; the rest is the agent's workflow.

## In plain words

Your wallet keeps an exact list of what your agent may do there, called its permissions. That list is built from **packages**: bundles of actions (for example a savings vault, or a set of swaps) that Dialectic, as curator, has signed.

- **Your agent can prepare a change, never make it.** It can look at packages, check them, and install them on your computer, but none of that changes your wallet. Only a transaction you approve with your approval keys does.
- **Before asking you, Orbit tests the change.** It tries every new position on a copy of the network, opening and closing it, and checks that everything you already have stays exactly the same.
- **You approve one transaction.** Your agent shows you what is added, removed or kept, and any setting it carries. You approve it in the Safe app, or sign it in chat. Several changes can go into one approval.
- **Removing a package** that still holds money asks you first what should happen to those positions.

Approving a package allows all of its positions on that network, inside your rules.

## For agents: changing the permission root

This part is for agents changing what a Safe is allowed to do. As of Orbit 0.1.8.

What the Safe can do is exactly its signed permission root: a merkle root of instructions the makinaX module accepts (`allowedInstrRoot`). Orbit composes a new root locally from installed, curator-signed packages, proves it on a fork, and the owner sets it with one Safe transaction. Nothing on chain changes until the owner executes it. Orbit has no protocol-specific logic: trust comes from the curator's signature on the package and the module's on-chain checks. For how the root works, see [Permissions and limits](https://dialectic-orbit-docs.vercel.app/0.1.8/concepts/permissions-and-limits/).

## Reading the catalog

| Tool | Use |
|---|---|
| `list_packages` | Browse (filters: `strategy_type`, `asset`, `chain`, `tier`). Every manifest's curator signature is verified at fetch; failures appear under `rejected` and can never be installed. Retired packages are under `no_longer_offered` (never offer them; Safes that have them keep working). Installed packages show `update_available` |
| `get_package` with `package_id` (`<curator>/<package>`) | The full verified manifest: positions per network, feed, runtime requirements, bridges, subscription terms, recommended mandate |
| `audit_package` with `package_id` | An evidence-based audit of the package's claims (`depth: "standard"` by default, `"deep"` for minutes of extra probes) |
| `package_health` with `safe` | Ongoing health of every installed package: feed audit and position probes. Cheap; put it in digests |

### A package listed under `rejected`

An entry under `rejected` is one this Orbit could not accept. Each entry has a `reason`; `get_package`, `audit_package` and `install_package` for it fail with the same refusal. Never install or offer it until it leaves `rejected`.

- **The reason names a newer Orbit** (`orbit_update_required`), or an integration source or field this Orbit does not recognise: newer package versions can need a newer Orbit. Tell the owner the package needs an Orbit update, then upgrade (see [Updates](https://dialectic-orbit-docs.vercel.app/0.1.8/using/updates/#for-agents-update-steps)) and call `list_packages` again.
- **Any other reason** (a signature or curator-key failure, a catalog that was busy): relay it as given. A busy catalog says so and clears on a later call.

A rejected newer version does not affect what is installed: a Safe that installed an earlier version keeps using it. The curator-side detail, including the Hyperliquid perps case, is on [Packages for curators](https://dialectic-orbit-docs.vercel.app/0.1.8/contributing/packages-for-curators/#newer-packages-and-older-orbits).

### Reading an audit

`audit_package` checks claims, not operability. The fork test at `compose_root` (opening and closing every new position on real bytecode) is the authority.

- `verified`: no check failed. `not_run`, `no_identity_check` ("no extra identity check for this kind of venue"), `not_checked_here` and `self_issued` are information to mention, not reasons to refuse.
- `partially_verified`: a check could not complete (`unverified`, not a failure), or an info-severity check failed (for example `does_not_compose`). Read the issues per layer.
- Phrases such as "at this audit depth" or "runtime requirements not probed" describe what the audit did not run. They are not security findings.
- A real reason to hold back: a failed check (`package_health` `audit_state` `hard_issues` or `warnings` other than advisories), or a failed check that keeps `audit_package` at `partially_verified`.

Is a verified package safe? "Verified" means its claims checked out (signature, venue identity, feed health, fit). It does not audit the venue's contracts or predict market risk. The owner's limits bound how much value moves through any package.

## Installing a package

`install_package` with `safe` and `package_id` records the package on this Orbit for that Safe, audits it at the standard tier (`deep_audit: true` for the full one), and starts its data feed when supported.

- Local only: nothing is installed on chain and no authority is granted. It also needs no owner signature.
- Installing the same `package_id` again replaces the local record with the catalog's current signed version (an update of the local copy, still not on chain).
- A paid package is refused until the plan is confirmed for this exact Safe; relay the refusal, carry on, offer the upgrade (see [Billing and renewal](https://dialectic-orbit-docs.vercel.app/0.1.8/using/billing-and-renewal/)).
- If a curator credential must be bought, the answer says so: `get_credential_quote`, owner's yes, `acquire_credential`. Installing never authorizes that spend.
- Afterwards: `verify_setup` and `package_health`.

Approving a package allows all its positions on that network. Name them to the owner from the composition's diff.

## Composing a new root: `compose_root`

`compose_root` with `safe` builds the new root from the persisted composition plus the packages you name, then proves it.

```json
{"tool": "compose_root",
 "args": {"safe": "<base-safe>",
          "add_packages": [{"package_id": "dialectic/orbit-basic"}],
          "keep_existing": true}}
```

| Argument | Meaning |
|---|---|
| `add_packages` | Omit to compose every installed package. An explicit list is honoured exactly, including `[]`. `position_ids` within an entry composes part of a package |
| `keep_existing` | Default `true`: existing positions are carried and proven byte-identical |
| `remove_position_ids`, `exclusion_reasons` | Drop positions, and say why |
| `accept_changed_existing` | Deliberate migrations only: proceed although kept positions changed |
| `accept_inoperable` | Proceed although a **new** position failed its open/close fork test |
| `include_requirements` | Default `true`: missing runtime-requirement settings ride the same batch |
| `bridge_loss_cap_bps` | Owner override, a map from `bridge_id` to basis points (`{"1": <bps>}` for Across). A bare number is refused |
| `module_cooldown_seconds` | The owner's wait between actions, one of the options in the `module_cooldown_choice_needed` refusal's `options_seconds`; only when the owner chose it. As of 0.1.8, first setup and adding a network set the wait from the care level (or copy the source Safe's), so this is needed on a permissions update only when the module still has no wait. The applied wait is in `get_module_state` → `cooldowns_s` |
| `gas_top_up_revision`, `erc20_allowlist_revision`, `perp_market_revision` | The exact draft revisions shown to the owner |

For later edits, pass only the edited package in `add_packages` with `keep_existing: true`.

### What it checks

1. **Live-root continuity.** The local rootfile must equal the module's live `allowedInstrRoot()`; a mismatch blocks composition. It fails closed without a reachable network connection.
2. **Preservation.** Every kept position's instructions must be byte-identical to the current root's, else it is blocked naming the position.
3. **Fork proof (write builds).** On a fork as the Safe: set the new root, then account for every position, and open and close every new one. Any failure means no artifact.

### Reading the answer

- `root_diff`: `added`, `removed`, `kept` (and the sentence `kept_unchanged`), `changed` (with `what`), `relabeled` (names a package declares that the root does not use; existing positions keep their names, `kept_existing_name`), `old_root`, `new_root`.
- `settings_review.owner_text`: show it word for word with every compose and batch.
- `root_unchanged: true, settings_only: false`: the package's positions are already in the live root, so it is already in force. Installing it was the whole change: there is nothing to sign and no finalize step.
- `root_unchanged: true, settings_only: true`: only settings are missing. The owner signs a settings-only module batch, which never changes the root and needs no activation. `next_action.args` is the exact `update_checkout_draft` call (then `prepare_checkout`); pass it as given. Before the module exists (first setup), those settings go into the setup approval (`generate_onboarding_batch`) instead of Pending changes.
- A changed root: a reviewed batch (`reviewed_batch`, `tx_builder_json`) and a `next` that names the route.
- Paid positions with no active mandate: the answer says the owner signs limits in the same sitting.

### Inoperable positions

A new position that fails its fork test on every attempt is refused: "don't authorize a position you can't operate". `accept_inoperable: true` is a general `compose_root` override for a **new** position whose open leg failed the fork test. It cannot override:

- a position that opens but cannot **close** (authorizing an entry you cannot reverse is a fund trap);
- an unstable fork harness, which is not a finding about the position: re-run `compose_root`;
- a GS104 revert (the fork is modelling a Safe whose module is not yet enabled), which is reported as unverified rather than as a failed position.

Checkout refuses `accept_inoperable` as well; it is a `compose_root` argument only.

Orbit has no notion of market hours. A position that fails to open on the fork for any reason, including a market that was closed at the time, is treated the same way. Whether to authorize a position that could not be shown to open is the owner's decision: explain what failed, and pass `accept_inoperable` only on their word.

## Two routes to the owner

A change that alters the root is in force only after four steps: install, compose, the owner's executed batch, and finalize (`finalize_root_update` on route A, `finalize_checkout` on route B), which activates the reviewed rootfile locally. Until finalize runs, actions refuse with `library_out_of_date`. Never treat settings confirmation, download or a pending execution as activation.

### Route A: the reviewed batch from `compose_root`

`compose_root` returns a reviewed batch. Hand it over as its `next` says: under owner export attach `tx_builder_json`; otherwise `propose_reviewed_batch` with `reviewed_batch.safe_tx_hash`. Do not run `generate_onboarding_batch` or `run_quick_setup` for it (those are for first setup; executing another batch first makes this one stale). When the owner says it is executed: `finalize_root_update`, then `verify_setup` (`root_matches`).

### Route B: Pending changes (checkout)

Pending changes collects several changes (permission root, module settings, a subscription) into one owner batch.

1. `get_checkout_draft` with `safe`: the current draft and its `revision`.
2. `update_checkout_draft` with `safe`, `expected_revision` and a `change` (`add`, `replace` or `remove` one intent). A permission change is an intent of kind `permission_root` with `package_ids`, and optionally `remove_package_ids`, `update: true`, the draft revisions, `module_cooldown_seconds`, and the confirmation lists below.
3. `prepare_checkout` with `safe`: one owner batch, revalidated and fork-simulated.
4. Hand it over: `propose_checkout` (Safe app queue; needs a registered proposer) or `get_checkout_export` (owner export). The owner approves and executes it in the Safe app.
5. `get_checkout_status` until it confirms the exact execution; `approvals` and `ready_to_run` are for display.
6. `finalize_checkout`, which activates the bound rootfile locally (module-only batches need no activation), then `close_checkout`.

`get_change_plan` lists the steps in the order they must happen; follow it. To change intents after a review was prepared, `replace_checkout_review` (it never revokes a transaction already exported, proposed or signed).

## Updating a package

1. `install_package` again for the package (the newer signed version is now installed locally; `list_packages` showed `update_available`).
2. Stage the Safe's `permission_root` item with that id in `package_ids` and `update: true`.
3. If refused with `positions_changed`, show the owner the listed positions (`data.changed`). Once they confirm, restage with those ids in `confirm_changed_positions`.
4. `prepare_checkout`, owner executes, finalize.

## Removing a package

Stage the Safe's `permission_root` item with `remove_package_ids`. Its positions (those no remaining package also governs) leave the root, and the package is removed from this Orbit once the change is finished.

- **Refused while positions hold value.** `positions_hold_value` lists positions with any non-zero value (`data.positions`). Show them to the owner. Exit them first, or, once the owner confirms ("I'll handle these positions myself"), restage with their ids in `confirm_positions_with_value`.
- `removal_needs_no_signature` (from `prepare_checkout`): none of the removed packages' positions are in the Safe's permissions, **and** the change carries nothing else (no added package, including a plan payment's package that needs the root, and no gas, transfer, market list or wait change). Nothing on the Safe would change: use `remove_package` instead, which is local and needs no batch. If anything else is in the change, the removal composes normally.
- `remove_package` alone is local: it stops the feed and drops the local record, but the root stays as the owner signed it, and the package's rules and last curator status keep applying to its positions until the owner signs a root without them.
- To move to a package that declares the same positions, install the new one first; removing the old one then keeps those positions for the new package.

## Settings drafts

Optional settings are saved as drafts, shown to the owner, and approved when the owner signs the batch that carries them. There is no separate chat confirmation.

| Setting | Read | Save | Skip | Compose with |
|---|---|---|---|---|
| Gas Top Up | `get_gas_top_up` (`chain`, `safe`) | `save_gas_top_up_draft` (`chain`, `values` in native decimal units) | `skip_gas_top_up` | `{"package_id": "dialectic/gas-top-up"}` in `add_packages` and `gas_top_up_revision` |
| Token Transfers | `get_erc20_allowlist` (`chain`, `safe`) | `save_erc20_allowlist` (`chain`, `entries`: token/recipient pairs; `get_token_info` checks a token first) | `skip_erc20_allowlist` | the Token Transfers package in `add_packages` and `erc20_allowlist_revision` |
| Perp markets | `get_perp_permissions`, `search_perp_markets` | `save_perp_markets` (`safe`, `baseline_root`, `markets`: the complete list of exact `MarketRef` values; optional `with_signer`) | `skip_perp_markets` | the whole perps package, `perp_market_revision`, `keep_existing: true`, no `position_ids` |

The Gas Top Up and Token Transfers saves require `chain`; they also take `safe` (when the network has more than one), `expected_safe` and `expected_revision` from the current read, and the last two are required once a Safe exists. `save_perp_markets` takes no `expected_safe` or `expected_revision`: its guard is `baseline_root`, the exact verified `active.root` the list was built from.

**Gas Top Up changes need the Gas Top Up package in `add_packages`.** Orbit binds the Gas Top Up draft only when that package's positions are part of the compose. A compose with an explicit `add_packages` list that leaves out `dialectic/gas-top-up` carries no gas change, and the answer does not say the saved draft was left out. A gas change without the reviewed revision is refused ("Gas Top Up revision differs from the reviewed draft").

An empty list in a save proposes removing that setting's permissions; a skip keeps whatever is active. A saved draft is not active.

Token Transfers fix the token and the recipient; the amount stays the agent's choice and is repeatable unless another enforced limit bounds it. Owner-added transfer targets (`add_owner_target`) also enter the root only at the next compose the owner signs, and need a `caps.per_target` entry in the mandate or they are refused at execution.

## Activation steps

Some packages declare one-time steps that must run after the owner's root is active (for example adding Orbit's Hyperliquid signer after the first deposit). `run_activation_steps` with `safe`, `expected_safe`, `expected_chain_id` sends each due step once. Each step is a fixed permission already in the approved root; the owner signs nothing more. Per step `state`: `sent`, `already_sent`, `waiting_for_precondition`, `waiting_for_gas`, `paused`, `failed`, `refused`, `not_in_root`.

## Common refusals

| Refusal | Meaning |
|---|---|
| Live root mismatch (BLOCKED) | The local rootfile is not the live root's preimage; resolve before composing |
| Kept position changed (BLOCKED) | A package changed an existing position; deliberate migrations only |
| Inoperable new position | It failed its fork test; `accept_inoperable` only for positions that will not open, and only on the owner's word |
| `module_cooldown_choice_needed` | The module has no wait between actions yet. Ask the owner; offer only `options_seconds`; `next_action` says where to pass the answer (`preset` or `module_cooldown_seconds`). Never choose for them |
| `positions_hold_value` | Removal of positions that still hold value |
| `positions_changed` | An update changes existing positions |
| `network_busy` with `retry: true` | Call the same thing again |
| `mandate_required` | Paid positions need signed limits first |
| `library_out_of_date` | The owner executed a root change that Orbit has not finalized yet: `finalize_root_update` or `finalize_checkout` |

`plan_change_needed` is not a refusal: it is a `stage` in a successful `submit_plan_move_signature` answer (see [Billing and renewal](https://dialectic-orbit-docs.vercel.app/0.1.8/using/billing-and-renewal/#moving-to-the-next-plan)).

## Pitfalls seen in real agents

- Changing Gas Top Up values and composing with another package only: the gas change was silently not part of the root.
- Treating `install_package` as granting authority. Only the owner's executed root does.
- Reading audit notes about depth as security findings and refusing a verified package.
- Proposing a second batch while the first waited at the same nonce, which made one of them stale.
