Skip to content

feat(cli): a4 program account decode, in production or a dev environment - #477

Merged
adiman9 merged 9 commits into
mainfrom
feat/program-account-decode
Oct 31, 2026
Merged

adiman9 merged 9 commits into
mainfrom
feat/program-account-decode

Conversation

@adiman9

@adiman9 adiman9 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

a4 program account decode <address> [--program <alias|package>] [--account <Type>] [--dev [--env <name|id>] [--project <dir>]]: decode one account through Program Read for the program's installed release.

How it reads

  • Production (default): reads the raw account through the managed Solana gateway (a read session from the program's chain binding), then decodes it through hosted Program Read with a read session for the program's binding and release.
  • Dev (--dev): reads the account from the environment's fork (getAccountInfo, the way a4 dev talks to the environment), resolves the program's binding and release to the environment's Program Read endpoint and release (POST /api/dev/environments/:env/resolve, so an environment release override applies), mints the read session with environment set, and decodes there: the output shows the fork's values. A refused resolve prints its code and fix.
  • Program: --program is an arete.toml program alias or a registry package; without it, the account's owner looked up in the registry (an owner the registry doesn't list is an error telling you to pass --program).
  • Account type: --account, else the IDL account whose discriminator starts the data, else the IDL's only account; ambiguity or no match asks for --account.
  • --json prints {address, program, programId, account, programReleaseHash, environment, value}.

Seam for the environment switch

Production vs dev is chosen in one function (read_target). --dev selects the environment today; when the SDKs' environment switch lands, it is read there so this command follows it. --env / --project without --dev are refused.

Also adds EnvApi::resolve to arete-mcp.

Tests

Unit tests: discriminator matching and --account, owner mismatch message, raw account parsing from the chain read and from getAccountInfo, resolve answer → endpoint/release and refusal fix, decode URL, --env needing --dev.

  • Ran locally: nothing (the shared machine was too loaded to compile). CI only: build, clippy and tests, green.
  • Dev mode runs the environment calls on a runtime it owns and makes the blocking registry, session and Program Read calls after it returns. With --project, aliases come from that project's arete.toml.
  • Not exercised end to end against a live environment (the decode-fork condition needs a deployed environment and dev Program Read).

Open question

Without --program in production, the owner is read through the first registry program's gateway binding (the managed gateway reads any account). Fine if every program's chain binding names the same gateway, which is how installs look today.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issues were found.

Summary

Adds a4 program account decode for production accounts and dev forks.

  • The CLI decodes one account through its installed program release.
  • Dev reads decode account values from the selected environment's fork.

No new actionable issues were found. All five previous threads were rechecked. adiman9 documented that override-only types need --account when the installed IDL cannot identify them.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Account address] --> B{Dev mode?}
  B -->|No| C[Read through managed gateway]
  B -->|Yes| D[Read from environment fork]
  C --> E[Resolve program and installed release]
  D --> E
  E --> F[Check account owner]
  F --> G{Dev mode?}
  G -->|No| H[Hosted Program Read]
  G -->|Yes| I[Resolve environment endpoint and served release]
  I --> J[Environment Program Read]
  H --> K[Print decoded value]
  J --> K
Loading

Reviews (7) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread cli/src/commands/program_decode.rs Resolved
Comment thread cli/src/commands/program_decode.rs Resolved
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
arete-docs Ready Ready Preview Oct 31, 2026 1:43am UTC

Request Review

# Conflicts:
#	rust/arete-mcp/src/dev_env.rs
Comment thread cli/src/commands/program_decode.rs Resolved
An environment can serve another release of a program than the installed
one. The account type was chosen from the installed IDL before that release
was known, so an account type the served release adds could not be decoded,
even when named with --account.

Choose the type after resolving. With another release served, --account goes
to the environment to check, and the installed IDL's only account is no
longer assumed for data it does not match.
Comment thread cli/src/commands/program_decode.rs Resolved
An arete.toml alias kept only its package name and read the package's current
install, ignoring the version requirement and arete.lock. A project pinned to
an older release could get another IDL and Program Read release than its SDK.

Resolve the alias as a4 install does, with its requirement and locked release.
An account's owner uses the same route when the project depends on it.
Comment thread cli/src/commands/program_decode.rs Resolved
A lock older than arete.toml can name the account's owner under an alias that
now resolves to another package. Use the project's install only when it is the
owner's program; otherwise look the owner up in the registry.
@adiman9
adiman9 merged commit 27e8354 into main Oct 31, 2026
35 checks passed
@adiman9
adiman9 deleted the feat/program-account-decode branch October 31, 2026 02:04

This branch was successfully deployed

1 active deployment
Preview — 50cd5ca5 Deployed Oct 31, 2026 by vercel[bot]
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