feat(core): declarative preflight policy gates in deploy() — part 1 of #156 - #170
Open
robercano-ghbot wants to merge 1 commit into
Open
feat(core): declarative preflight policy gates in deploy() — part 1 of #156#170robercano-ghbot wants to merge 1 commit into
robercano-ghbot wants to merge 1 commit into
Conversation
Adds an opt-in pre-broadcast safety phase: expectedChainId, minBalanceWei,
and maxGasPriceWei checks run against the live RPC/account BEFORE any
transaction is sent, aborting with a typed DeployError("PREFLIGHT_FAILED")
on failure. Effective policy is a per-field merge of DeploymentSpec.preflight
and DeployOptions.preflight; the phase is fully skipped (zero extra RPC
calls) when no policy is configured, keeping the happy path unaffected.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
robercano
approved these changes
Jul 29, 2026
robercano
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Part 1 of 2 for #156 — the
@redeploy/corehalf: a declarative preflight phase indeploy()that runs BEFORE any transaction is broadcast, so mainnet mistakes are caught pre-broadcast.The deploy-server interlock (simulate-first + structured SSE surfacing) lands in a follow-up PR stacked on this branch; merge this one first.
Design
PreflightPolicy { expectedChainId?, minBalanceWei?, maxGasPriceWei? }— declarable on the spec (DeploymentSpec.preflight) and/or passed viaDeployOptions.preflight. Effective policy = per-field merge (options override spec per field, via nullish-coalescing so an override can never remove a spec-mandated check).deploy/preflight.tsrunPreflight()performs only the checks whose fields are set:eth_chainIdequality, deployer balance ≥minBalanceWei(viaeth_getBalance), gas price ≤maxGasPriceWei(viaeth_gasPrice). Runs after validate/compile but strictly BEFOREignitionDeploy()— no tx can precede a failure.DeployError("PREFLIGHT_FAILED", …)carrying structuredpreflightFailures: PreflightFailure[]({ check, expected, actual, message }).eth_getBalance).preflightPolicySchema) validates spec-declared policies (positive-int chainId, decimal-bigint wei strings) → malformed becomesINVALID_SPEC.New public API
PreflightPolicy,PreflightFailure,PreflightCheck,runPreflight,preflightPolicySchema;DeployErrorCodegains"PREFLIGHT_FAILED";DeployError.preflightFailures;DeploymentSpec.preflight/DeployOptions.preflight.Gates (packages/core)
build / lint / typecheck / test / coverage — all green. 433/433 tests. Core coverage 93.59% stmts (threshold 80);
preflight.ts97.22%,schema.ts100%.Review
All four reviewer lenses (correctness, tests, security, performance) approved, high confidence.
Follow-up nit (non-blocking, deferred): harden
hexToBigIntto require a^0x[0-9a-fA-F]+$prefix so a non-conformant RPC returning a bare decimal/empty string fails closed on the gas-price ceiling. Not a real bypass for any conformant EIP-1193 provider; noted for a later hardening pass.Part of #156.
🤖 Generated with Claude Code