Skip to content

(Discuss) compile-time deploy-safety lint, native to Quasar #186

@saicharanpogul

Description

@saicharanpogul

Hey team,

Wanted to surface this as a discussion rather than a PR — happy if the answer is "interesting but not now."

There's a structural advantage Quasar has over Anchor that I don't think is being exploited yet: the IDL is derived from your source AST at compile time. Anchor has to round-trip through target/idl/<program>.json to do anything shape-aware (linting, upgrade-safety checks, schema-version detection). Quasar could run the same lints during quasar build and surface findings as cargo diagnostics — earlier signal, no separate tool to install, no JSON-out-of-tree.

What's already there

I've been working on ratchet, a framework-neutral upgrade-safety + mainnet-readiness lint catalog that operates on a ProgramSurface IR. Two flavours of rule:

  • R-rules (16) — diff two builds, fire on changes that would corrupt on-chain state, break callers, or orphan PDAs.
  • P-rules (6) — preflight a single build, fire on patterns that make future upgrades materially harder.

solana-ratchet-quasar 0.3.2 parses Quasar's IDL JSON and lowers it into the same IR the Anchor adapter produces, so every rule fires identically. Embedded as a library in QEDGen/solana-skills#20 (merged yesterday) — so the IDL-path integration ships today.

R-rules (diff)                          P-rules (preflight)
R001  account-field-reorder             P001  account-missing-version-field
R002  account-field-retype              P002  account-missing-reserved-padding
R003  account-field-removed             P003  account-missing-discriminator-pin (Anchor-only)
R004  account-field-insert-middle       P004  event-missing-discriminator-pin   (Anchor-only)
R005  account-field-append              P005  account-name-collision
R006  account-discriminator-change      P006  instruction-missing-signer
R007  instruction-removed
R008  instruction-arg-change
R009  instruction-account-list-change
R010  instruction-signer-writable-flip
R011  enum-variant-removed-or-inserted
R012  enum-variant-append (additive)
R013  pda-seed-change
R014  instruction-discriminator-change
R015  account-removed
R016  event-discriminator-change

What native could look like

A Quasar proc-macro / build pass that builds ProgramSurface directly from the AST (skipping the JSON detour), then calls into solana-ratchet-core. Rough shape:

  • quasar build runs the rule set against the current source.
  • Findings surface as cargo diagnostics — error/warning configurable.
  • Diff mode (R-rules) compares against a checked-in quasar.lock snapshot of the last release's surface.
  • No external tool, no --quasar flag, no JSON detour. Just part of the build.

Quasar-specific calibration already in place

P003 / P004 are intentionally silenced when solana-ratchet-quasar produces the surface — Quasar requires devs to pin discriminators in source, so flagging the absence of a pin would be a category error. That calibration lives at the framework adapter, not in the core rule engine. If Quasar wanted Quasar-specific rules later (e.g. dynamic-type field ordering, per #141), they'd plug in the same way.

Open questions

  1. Would Quasar take a dependency on solana-ratchet-core, or prefer rules vendored in-tree?
  2. Failure-mode preference — error by default, warning, #[allow]-able per rule?
  3. Anything in the catalog that doesn't make sense for Quasar's model and should be dropped/reshaped at the adapter?
  4. Adjacent: Automatic account migration #158 (automatic account migration) is the fix side of the same upgrade-safety story — pair the two as one initiative or keep separate?

Not blocking on a yes — happy to leave this as a discussion. If there's interest I'd be glad to sketch a more concrete proposal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions