5d661ed. bun run check:docs fails the build when a file,
symbol, test or CI job named below no longer exists, when a test it names is skipped, or when two rows share an id.
It checks names, not meaning: it cannot tell whether a symbol still holds the rule or a test still asserts it. That
stays a review question.
How to read a row
- Enforced by names a file and, after
#, the symbol it declares that holds the rule. - Proved by names a test file and, after
#, the exact name passed totest(), or a CI job in.github/workflows/ci.yml. - Status is one of:
- Enforced: a test or CI job fails if the rule breaks.
- Enforced, with a residual: the rule is tested, but the guarantee is narrower than it first reads; the residual is stated and linked.
- Partly enforced: one half of the rule is tested and the other is not; the row says which.
- Design intent: the code is written this way, but no test or job would catch a change.
Transaction construction and verification
| Id | Invariant | Enforced by | Proved by | Status |
|---|---|---|---|---|
| INV-01 | The transaction builder is a pure module: state in, unsigned operations out, no network access. | apps/api/src/lib/stellar/tx-builder/close-operations.ts#assembleCloseOpsTagged | None. The builder’s unit tests (apps/api/tests/unit/closeOperations.test.ts) run it offline, but nothing fails if it gains a network import | Design intent |
| INV-02 | Every close round reads the account live, immediately before building, and never builds from indexer data alone: the round cross-checks the enumerated account (sequence, sub-entry count, XLM balance, signers, thresholds) and every enumerated trustline, pool share, offer and data entry against one batched RPC read and refuses any difference as state_changed; one account read may span at most two ledgers, and one that does not settle is answered as 409 state_changed on the account route too. The web states a refused plan in plain language and refreshes it. | apps/api/src/close/close.service.ts#transactions, apps/api/src/lib/close-api/build-transactions.ts#buildCloseTransactions, apps/api/src/lib/close-api/state-drift.ts#confirmLedgerState, apps/api/src/lib/close-api/state-drift.ts#findStateDrift, apps/api/src/lib/stellar/account-state.ts#MAX_SNAPSHOT_LEDGER_SPAN, apps/api/src/lib/stellar/live-ledger.ts#readLiveLedger | apps/api/tests/unit/close-controller.test.ts#"T15 a domain error is rethrown for the filter to map", apps/api/tests/adversarial/sponsoring-accounts.test.ts#"build-transactions refuses a sponsorship the live re-read marks unaffordable, before any round", apps/api/tests/unit/state-drift.test.ts#"a newer sequence on the ledger refuses the round with state_changed 409 and no transaction", apps/api/tests/unit/state-drift.test.ts#"a different sub-entry count refuses the round with state_changed", apps/api/tests/unit/account-snapshot-window.test.ts#"reads that still span too many ledgers on the second try are refused as a changed account", apps/api/tests/unit/account-controller.test.ts#"an account that kept changing during the read is a 409 state_changed, not a 500", apps/api/tests/unit/account-state.test.ts#"a sha256_hash signer stays in the state and agrees with the ledger", apps/web/tests/unit/plan-state-changed.test.tsx#"a state_changed from the final plan says so and refreshes, the same as needs_decisions", apps/web/tests/unit/plan-state-changed.test.tsx#"a state_changed from the analyze plan says the account changed and how to retry", apps/api/tests/unit/state-drift.test.ts#"a trustline whose live balance differs is drift", apps/api/tests/unit/state-drift.test.ts#"a removed offer is drift", apps/api/tests/unit/state-drift.test.ts#"a changed data entry is drift", apps/api/tests/unit/state-drift.test.ts#"a changed signer set is drift", apps/api/tests/unit/state-drift.test.ts#"chunks the keys beyond the limit", apps/api/tests/unit/step-engine.test.ts#"filterExistingClaimableBalances › a failed read throws instead of assuming every balance exists" | Enforced, with a residual: the cross-check compares what the build depends on (existence, the XLM and trustline balances, limits, trustline authorization, offer amounts and assets, data values, signers, thresholds); an offer’s price is not compared, and an entry added after the read is caught only through the sub-entry count |
| INV-44 | With more than one provider configured, one account read stays on one provider: only an outage or a non-conforming response moves to the next, a lagging provider ends as a 503 and never as state_changed, a later provider’s 404 is unavailable while a primary’s stays account not found, the issuance read never fails over, and a failed sendTransaction is never sent again, only looked up by hash. | apps/api/src/lib/stellar/provider-failover.ts#withHorizonFailover, apps/api/src/lib/stellar/provider-failover.ts#isRetryableProviderFailure, apps/api/src/lib/stellar/rpc.ts#pinRpcProvider, apps/api/src/lib/stellar/account-state.ts#readAccountStateFrom, apps/api/src/lib/close-api/state-drift.ts#confirmLedgerState, apps/api/src/lib/close-api/issuance-preflight.ts#assessIssuance, apps/api/src/lib/stellar/submit.ts#submitAndWait | apps/api/tests/unit/provider-failover.test.ts#"a snapshot is one provider's: a partial read on A never counts in B's span", apps/api/tests/unit/provider-failover.test.ts#"lag across every provider is unavailable, never state_changed", apps/api/tests/unit/provider-failover.test.ts#"a state change seen by a fresh provider is terminal: the next one is never asked", apps/api/tests/unit/provider-failover.test.ts#"a fallback's 404 is unavailable, never account-not-found", apps/api/tests/unit/provider-failover.test.ts#"a primary's 404 is the answer and the next provider is never asked", apps/api/tests/unit/provider-failover.test.ts#"issuance never fails over: a primary outage with no pin refuses, and no fallback is asked", apps/api/tests/unit/state-drift.test.ts#"a drift the RPC has not reached yet is a 503, not a change of state", apps/api/tests/unit/rpc-failover.test.ts#"a failed send is never replayed: one send anywhere, one by-hash look at the next provider" | Enforced, with a residual: a one-entry list keeps its historical behavior, including a lagging lone provider answering state_changed |
| INV-03 | verify() rejects any operation it cannot describe. | apps/web/lib/stellar/verify.ts#assertCloseIntent | apps/web/tests/unit/verify.test.ts#"fails closed on an operation type the switch does not recognize at all", apps/web/tests/unit/verify.test.ts#"rejects a real transaction carrying an unrecognized operation", apps/web/tests/unit/verify-conformance.test.ts#"refuses the vector that carries an operation it cannot describe" | Enforced |
| INV-04 | verify() takes the destination, the memo and the user’s per-asset choices from the user’s own inputs, never from the API response. | apps/web/lib/stellar/verify.ts#assertCloseIntent | apps/web/tests/unit/verify.test.ts#"rejects a merge to an unexpected destination", apps/web/tests/unit/verify.test.ts#"rejects a memo the user did not set" | Enforced, with a residual: other expected values come from the API’s own account read and plan, which the user reviews but did not type: the native balance the mediator forward is held to, transfer floors, the account’s signers and thresholds, a DeFi exit’s position contracts and tokens, and the quotes swap and conversion minimums are taken from (threat model, Section 11) |
| INV-05 | A SetOptions operation never adds a signer or raises a threshold. | apps/web/lib/stellar/verify.ts#assertCloseIntent | apps/web/tests/unit/verify.test.ts#"rejects a set_options that adds or empowers a signer", apps/web/tests/unit/verify.test.ts#"rejects a set_options that raises the high threshold" | Enforced, with a residual: that a removed signer exists is checked against the API’s read (threat model, Section 11) |
| INV-35 | Each transaction of a close is signed and submitted against the signers and thresholds read for its round, as changed by the transactions confirmed before it. | apps/web/hooks/useCloseExecution.ts#useCloseExecution, apps/web/lib/stellar/signature-weight.ts#applyConfirmedSetOptions | apps/web/tests/unit/use-close-execution.test.tsx#"useCloseExecution › a round is judged against the signers and thresholds read for that round", apps/web/tests/unit/use-close-execution.test.tsx#"useCloseExecution › a later transaction in the round is signed against the signers an earlier one left" | Enforced. The round’s signers come from the API’s own read, as the signers verify() checks against do |
| INV-51 | For a close no single key of the account can sign (normalizesSignersFirst: the master key carries weight and no ed25519 key alone reaches the highest threshold), signer normalization is the first transaction of the close and holds only the signer removals and the threshold reset: never a merge, a conversion, a transfer or any other operation. The API emits it only while no later refusal is already known from the state it reads (a Soroban fee budget, a claim reserve, a balance that cannot be left or has no destination), and the plan lists and counts it first. | apps/api/src/lib/stellar/tx-builder/index.ts#normalizesSignersFirst, apps/api/src/lib/close-api/build-transactions.ts#buildCloseTransactions, apps/api/src/lib/close-api/plan-response.ts#toExecutionBreakdown | apps/api/tests/unit/normalization-first.test.ts#"its first transaction removes the other signers and resets the thresholds, and nothing else", apps/api/tests/unit/normalization-first.test.ts#"once normalization lands, the exit is the next round and the account needs only the master key", apps/api/tests/unit/normalization-first.test.ts#"a fee budget the Soroban rounds cannot meet", apps/api/tests/unit/plan-transaction-count.test.ts#"a multisig exchange close reports its normalization, the claim, the cleanup and the transfer" | Enforced, with a residual: a later round can still be refused after normalization lands, for a quote that drifted, a route that was lost, a transfer destination that became unusable or an exit whose simulation fails, and the account then stays open under the master key alone, as the plan step says |
| INV-06 | Every operation is sourced from the account being closed, except the exchange forward, whose source must be the account the merge pays into. | apps/web/lib/stellar/verify.ts#assertCloseIntent | apps/web/tests/unit/verify.test.ts#"rejects a merge not sent by the account being closed", apps/web/tests/unit/verify.test.ts#"rejects an exit sourced from another account", apps/web/tests/unit/verify.test.ts#"every operation must act for the account being closed" | Enforced |
| INV-07 | A payment is only the mediator forward or the payment the user chose for that asset: a transfer to the account they named for at least the balance shown, or a return to the issuer of an asset they chose to return. Neither a classic transfer nor a Soroban token transfer goes to an address the exchange registry lists, a return to the issuer excepted: the plan cards refuse one, the close stops before the next round when the registry lists one after the review, and verify() refuses one. | apps/web/lib/stellar/verify.ts#assertCloseIntent, apps/web/lib/api/close-decisions.ts#chosenTransfers, apps/web/lib/plan/transfer-destination.ts#isUsableTransferDestination, apps/web/lib/plan/transfer-destination.ts#refusedTransferAsset | apps/web/tests/unit/verify.test.ts#"rejects a payment to an unexpected address", apps/web/tests/unit/verify.test.ts#"a payment for an asset with no transfer chosen is rejected", apps/web/tests/unit/verify.test.ts#"a return to the issuer passes only for an asset the user chose to return", apps/web/tests/unit/verify.test.ts#"a classic transfer to a listed exchange is refused, even one other than the close destination", apps/web/tests/unit/verify.test.ts#"a token transfer to a listed exchange is refused", apps/web/tests/unit/verify.test.ts#"a return to an issuer the registry lists still passes", apps/web/tests/unit/transfer-destination-refusal.test.tsx#"a transfer to a listed exchange is not an answer, for a classic asset or a token", apps/web/tests/unit/use-close-execution.test.tsx#"listed after a round was submitted, the next round is never fetched" | Enforced, with a residual: the balance shown comes from the API’s account read (INV-04) |
| INV-08 | A classic conversion sells only an asset the user chose to convert, at most once per transaction, pays the account itself, settles in XLM, and accepts at least the minimum the plan showed beside that asset, less 1% for the market to move; for an asset only an exit pays in, which has no amount to quote, it carries a positive minimum. The API refuses to build a conversion whose route no longer clears that minimum. | apps/web/lib/stellar/verify.ts#assertCloseIntent, apps/web/lib/api/close-decisions.ts#chosenClassicConversions, apps/api/src/lib/close-api/build-transactions.ts#buildCloseTransactions | apps/web/tests/unit/verify.test.ts#"rejects a conversion that pays out of the account", apps/web/tests/unit/verify.test.ts#"rejects a conversion that would not settle in XLM", apps/web/tests/unit/verify.test.ts#"a classic conversion sells only an asset the user chose to convert", apps/web/tests/unit/verify.test.ts#"a classic conversion accepts at least the minimum the plan showed", apps/api/tests/unit/buildCloseTransactionsDisposition.test.ts#"close build › a conversion is refused when the route no longer clears the minimum the plan showed" | Enforced, with two residuals: the quote comes from the API’s plan, and what an exit pays in is held only to a positive minimum, or to the floor quoted for the part already held |
| INV-09 | A destination that needs a memo, by the exchange registry on the close’s network or by its own config.memo_required data entry (SEP-29), cannot be merged into, forwarded to or sent a transfer without one. A registry entry marked testnet-only sets no memo rule on mainnet, where the address is held to its own data entry like any unlisted one. | apps/web/lib/stellar/verify.ts#assertCloseIntent, apps/api/src/lib/close-api/memo-rules.ts#requestMemoProblem, apps/api/src/lib/close-api/memo-rules.ts#envelopeMemoProblem, apps/api/src/lib/close-api/transfer-destinations.ts#validateTransferDestinations, apps/web/lib/exchange-registry/index.ts#lookupExchange | apps/web/tests/unit/verify.test.ts#"rejects a missing memo when the destination requires one (even if the user left it blank)", apps/api/tests/unit/close-controller.test.ts#"T4 an exchange that needs a memo refuses a close without one", apps/api/tests/unit/close-controller.test.ts#"T4b a destination that requires a memo on-chain refuses a close without one", apps/api/tests/unit/mediator-controller.test.ts#"S11a a forward to a listed exchange without a memo is not co-signed", apps/api/tests/unit/mediator-controller.test.ts#"S12a a forward to an account that requires a memo on-chain needs one", apps/api/tests/unit/transfer-destinations.test.ts#"a destination that requires a memo on-chain is a blocker", apps/api/tests/unit/close-controller.test.ts#"an account whose own data entry requires a memo, for a classic asset and for a token", apps/api/tests/unit/close-api-token-decisions.test.ts#"the plan blocks a token sent to a listed exchange or to an account that requires a memo", apps/web/tests/unit/exchange-registry-network.test.ts#"on testnet the stand-in's id memo is required", apps/api/tests/unit/exchange-registry-validation.test.ts#"is invisible to every mainnet lookup" | Enforced, with a residual: verify() takes the requirement from the registry only, so the account’s own data entry is enforced by the API (close/transactions, the transfer checks and the mediator co-sign) and not by the browser. A transfer outside the merge is refused outright to any listed exchange (INV-07) |
| INV-50 | The transaction that delivers the balance (the merge, or the mediated merge and forward) carries exactly the memo the user confirmed, in the type they confirmed (the registry’s for a listed exchange, the user’s choice for any other destination), or no memo when none was set; every other transaction of a close carries no memo. | apps/web/lib/stellar/verify.ts#assertMemo, apps/web/lib/plan/memo-field.ts#confirmedMemo | apps/web/tests/unit/verify.test.ts#"an unlisted destination refuses an id memo when the user chose text", apps/web/tests/unit/verify.test.ts#"a merge without the memo the user set is refused", apps/web/tests/unit/verify.test.ts#"a merge carrying a memo when the user set none is refused, in either type", apps/web/tests/unit/verify.test.ts#"a transaction without a merge carries no memo, even the one the user set", apps/web/tests/unit/verify.test.ts#"a listed exchange that does not require a memo holds an optional memo to the registry type", apps/web/tests/unit/verify.test.ts#"the mediated merge and forward carries the memo in the registry type", apps/web/tests/unit/memo-field.test.ts#"confirmedMemo uses the registry type for a listed exchange, whatever was stored" | Enforced, with a residual: a per-asset transfer outside the merge carries no memo of its own, so it is credited only by a destination that does not key deposits on a memo; the API and the browser refuse one to a listed exchange (INV-07), and the API alone refuses one to an account whose config.memo_required data entry is set |
| INV-10 | A DeFi exit calls only contracts listed in the account’s analysis or the bundled registry, only that protocol’s exit function, pays a bounded fee, and authorizes nothing that pays an account other than the one being closed or a contract other than the one it calls; through a contract the bundled registry does not name, it may touch only the tokens the account read lists as that position’s own, never XLM or a classic asset the read lists; through a contract the registry names, it may spend those only as a plain transfer into the pool called, of a token the read shows a Blend borrow in there; and none is accepted while the read names XLM, a held classic asset or a listed Soroban balance as a position’s share token, or XLM or a held classic asset as its debt token. Every call authorized below the root, at any depth, is a token call, apart from Soroswap’s router paying the removed amount of LP share into its pair, as the only call under a removal that pays the account. A Blend submit names only the account as from, spender and to and carries only withdraw and repay requests, and a claim pays only the account. | apps/web/lib/stellar/verify.ts#assertCloseIntent, apps/web/lib/stellar/exit-expectations.ts#exitExpectations | apps/web/tests/unit/verify.test.ts#"rejects an exit sub-invocation that spends a token's allowance to a third-party spender", apps/web/tests/unit/verify.test.ts#"rejects an exit sub-invocation calling a function on a token that no exit legitimately needs", apps/web/tests/unit/verify.test.ts#"rejects an exit whose fee is far above what any exit costs", apps/web/tests/unit/verify.test.ts#"an exit through a contract outside the bundled registry may not touch XLM or a classic asset", apps/web/tests/unit/verify-against-registry.test.ts#"a Blend repay and withdraw that pays USDC into YieldBlox V2 passes", apps/web/tests/unit/verify.test.ts#"a transfer from the account into the pool holding the debt passes", apps/web/tests/unit/verify.test.ts#"with no debt in the read, the refusal says to run the analysis again", apps/web/tests/unit/verify.test.ts#"a repay and a withdrawal may share one submit", apps/web/tests/unit/verify.test.ts#"a sub-invocation on a contract outside the account's tokens is refused, whatever it calls", apps/web/tests/unit/verify.test.ts#"rejects a read naming a listed Soroban balance as the position's share token" | Enforced, with a residual: the analysis that lists the contracts comes from the API, an exit through a contract outside the registry may still move or burn the tokens the read names as that position’s own, a classic asset is protected only when the read lists its trustline (XLM always is), and the amount an exit moves is not checked by the browser (threat model, Section 11) |
| INV-11 | A DeFi position or plan step that cannot be closed safely surfaces as a blocker with an explanation, never silently skipped. | apps/api/src/lib/defi-exits/run-exit.ts#runExitAdapter, apps/api/src/lib/stellar/tx-builder/index.ts#buildPlan | apps/api/tests/unit/exit-adapter-harness.test.ts#"a network failure while reading is a blocker, not an exception", apps/api/tests/unit/buildPlan.test.ts#"buildPlan › a stale defiPositions result surfaces as a blocker" | Partly enforced: DeFi exits and the cited plan blocker are tested; other plan steps rely on their own tests and review |
| INV-12 | A DeFi exit blocker reaches the user in plain language, with no raw host error or SDK code. | apps/api/src/lib/defi-exits/run-exit.ts#runExitAdapter | apps/api/tests/unit/exit-adapter-harness.test.ts#"blocker messages are plain language - no raw host errors reach the user" | Enforced. Other user-facing errors are plain language by review, not by a test |
| INV-13 | An exit is never built against contract code the registry has not verified for that network and protocol. A contract’s code is its Wasm hash and how the instance reaches it: an instance that takes its code from a CAP-85 external reference matches only an entry pinning that exact owner and tag, with the hash re-read from the owner’s tag entry on every resolution, and never falls back to a hash-only match. The owner’s own code is verified on every testnet direct read, because it can repoint every pool that references it: an owner upgrade halts the read like a router change. | apps/api/src/lib/contract-registry/index.ts#resolveCode, apps/api/src/lib/contract-registry/index.ts#codeMatchesEntry, apps/api/src/lib/stellar/contract-instance.ts#readLiveCodeIdentity, apps/api/src/lib/defi-exits/run-exit.ts#runExitAdapter | apps/api/tests/unit/exit-adapter-harness.test.ts#"a step against a contract the registry does not know halts, even when the pool is known", apps/api/tests/unit/exit-adapter-harness.test.ts#"a hash the registry knows only on another network is unknown here", apps/api/tests/unit/aquarius-exit-adapter.test.ts#"another owner's tag naming the same hash is unknown code", apps/api/tests/unit/aquarius-exit-adapter.test.ts#"the pinned hash carried inline, without the pinned reference, is unknown code", apps/api/tests/unit/contract-instance.test.ts#"nothing is cached: a repointed tag is seen on the very next resolution", apps/api/tests/unit/testnet-direct-read.test.ts#"the release owner is verified on every read and adds no positions of its own" | Enforced |
| INV-14 | The registries fail closed once past their validity date: no exit is built, and no exchange close is accepted. | apps/api/src/lib/contract-registry/index.ts#isRegistryFresh, apps/api/src/lib/exchange-registry/index.ts#isRegistryFresh, apps/api/src/lib/defi-exits/run-exit.ts#runExitAdapter | apps/api/tests/unit/fixtures/exit-adapter-harness.ts#"halts when the registry is past its verification window", apps/api/tests/unit/contract-registry.test.ts#"is fail-closed past validUntil", apps/api/tests/unit/close-controller.test.ts#"T8 an exchange close is refused once the registry has expired" | Enforced |
| INV-40 | A token swap may authorize, below its own call, only paying in at most the amount it sells of the token it sells, to a contract, plus swap calls on contracts that are none of the account’s tokens. An xBull swap’s spent and bought tokens are read from its route through a bundled copy of the router’s asset table, never from the API; an index the copy does not hold is refused. | apps/web/lib/stellar/verify.ts#assertSwapAuthorizesOnlyItsInput, apps/web/lib/stellar/verify.ts#readXBullRoute, apps/web/config/xbull-asset-map.json | apps/web/tests/unit/verify.test.ts#"a swap may authorize only paying in the token it sells, from this account, up to the amount it sells", apps/web/tests/unit/verify.test.ts#"rejects a strict_send swap whose route names an index the bundled table does not hold, or breaks between hops", apps/web/tests/unit/verify-against-registry.test.ts#"a swap the Soroswap aggregator really built passes the anchor, and only for the token and floor chosen" | Enforced, with a residual: the pools a route passes through are not pinned, and the bundled table must be re-read when xBull adds assets |
| INV-37 | A merge proceeds past an open DeFi position only when the user explicitly chose to leave that position behind and its exit cannot be built for a reason that puts it beyond what the tool can exit; an exit that builds is always run, and a failed read, an expired registry or an unsafe position is never offered for leaving. | apps/api/src/lib/defi-exits/exit-round.ts#buildExitRound, apps/api/src/lib/defi-exits/plan-exits.ts#planExitSteps, apps/api/src/lib/defi-exits/run-exit.ts#runExitAdapter | apps/api/tests/unit/leave-unexitable-positions.test.ts#"without the choice, the build refuses before any merge is offered", apps/api/tests/unit/exit-round.test.ts#"a blocker that is not leave-eligible still refuses the round", apps/api/tests/unit/exit-round.test.ts#"a left-behind target whose exit builds after all is exited, not left", apps/api/tests/unit/exit-adapter-harness.test.ts#"a network failure, an expired registry or an unsafe position never is" | Enforced, with a residual: the browser does not see positions when it verifies the merge, so this holds at the API; archived position data is restored by the exit itself, and an exit that cannot carry that restore is one that cannot be built (threat model, Section 11) |
| INV-36 | A Soroban token swap accepts at least the floor the plan carried, and never a floor more than 1% under the quote the user was shown beside it; a swap with no quote to compare against is refused. | apps/web/lib/stellar/verify.ts#swapFloor, apps/web/lib/stellar/verify.ts#assertCloseIntent | apps/web/tests/unit/verify.test.ts#"a swap floor sits no more than 1% under the quote the user was shown, whatever floor the plan carried", apps/web/tests/unit/verify.test.ts#"rejects a swap that would accept less XLM than the minimum the user was shown" | Enforced, with a residual: the quote itself comes from the API’s plan |
| INV-34 | A fee is paid from XLM above the reserve and offers, or by a sponsor that accepts the transaction, or the build is refused; a Soroban round also reserves later fees. With no fee sponsor configured, the plan and every round of the build reserve the close’s own fees up front, including a base reserve and two operations for each trustline a claim round opens. With one, they reserve up front the fees of every transaction of the classic rounds still ahead that the sponsor’s rule refuses, and the build pays those, and what later rounds need, before it pays any fee the sponsor would. | apps/api/src/lib/close-api/build-transactions.ts#buildCloseTransactions, apps/api/src/lib/close-api/build-transactions.ts#packCloseTransactions, apps/api/src/lib/kill-switches/blockers.ts#killSwitchBlockers, apps/api/src/lib/close-api/sponsored-fees.ts#packFees, apps/api/src/lib/close-api/sponsored-fees.ts#projectClassicFees | apps/api/tests/unit/close-fee-coverage.test.ts#"exchange cleanup › refused before anything is built when the merge after it could not be paid", apps/api/tests/unit/sponsored-fee.test.ts#"packCloseTransactions › a chunk the sponsor would not accept is refused rather than flagged", apps/api/tests/unit/kill-switch-parity.test.ts#"the plan and the build report the same blocker", apps/api/tests/unit/close-fee-parity.test.ts#"the build refuses before the claim round with the plan's code and amount", apps/api/tests/unit/close-fee-parity.test.ts#"the plan and the build report the same code and amount", apps/api/tests/unit/close-fee-parity.test.ts#"with a Soroban round ahead, the plan and the build report the same code and amount", apps/api/tests/unit/close-fee-parity.test.ts#"a claim round ahead is sponsored so the close keeps the XLM it needs", apps/api/tests/unit/sponsored-fees.test.ts#"succeeds exactly when the spare covers the fees no sponsor pays, and wherever greedy packing did" | Enforced, with residuals: later Soroban rounds count at the plan’s estimate, and with a fee sponsor the refused transactions are projected from the state the plan saw, while the sponsor’s daily budget refuses only at submission (threat model, Section 11) |
| INV-32 | verify() refuses a transaction with no upper time bound, or one valid more than 15 minutes past verification. The API gives every swap it offers the 300 second expiry the rest of the close carries, and refuses one valid more than 360 seconds out. An allowance revocation is held to the same 15 minute window. | apps/web/lib/stellar/verify.ts#assertExpiresSoon, apps/api/src/lib/close-api/token-conversion-round.ts#withCloseExpiry, apps/api/src/lib/close-api/token-conversion-round.ts#assertConversionShape, apps/api/src/lib/close-api/xbull-conversion-round.ts#assertXBullConversionShape, apps/web/lib/stellar/verify-revoke-allowance.ts#verifyRevokeAllowanceTransaction | apps/web/tests/unit/verify.test.ts#"a transaction without an upper time bound is refused", apps/web/tests/unit/verify.test.ts#"a transaction may stay valid for at most fifteen minutes from verification", apps/api/tests/unit/token-conversion-round.test.ts#"is refused with the expiry the provider gave it", apps/api/tests/unit/xbull-conversion-round.test.ts#"refuses a swap that stays valid for longer than a close transaction" | Enforced, with a residual: the browser measures the window against its own clock |
| INV-33 | A classic close transaction pays at most 1,000 stroops per operation in network fees, ten times the base fee the builder sets; a Soroban call pays at most 1 XLM. | apps/web/lib/stellar/verify.ts#assertClassicFee, apps/web/lib/stellar/verify.ts#assertCloseIntent | apps/web/tests/unit/verify.test.ts#"a classic close may pay up to ten times the base fee per operation", apps/web/tests/unit/verify.test.ts#"rejects an exit whose fee is far above what any exit costs" | Enforced |
| INV-59 | A classic liquidity pool withdrawal names only a pool the account read shows the account holding shares in, at most once per transaction, for exactly those shares, with each minimum at least 98% and at most 101% of what that read’s reserves give, and above zero while they give any; a pool share trustline is removed only for such a pool, its id derived from the asset pair and fee the operation itself carries. The API builds each minimum 1% under the pool’s reserves read when the round is built. | apps/web/lib/stellar/verify.ts#assertPoolWithdrawal, apps/web/lib/stellar/verify.ts#assertPoolLine, apps/api/src/lib/stellar/tx-builder/pool-withdrawal.ts#poolWithdrawalMinimum | apps/web/tests/unit/verify.test.ts#"a pool the account holds no shares in is refused", apps/web/tests/unit/verify.test.ts#"the lower bound sits at 98% of what the reserves give, to the stroop", apps/web/tests/unit/verify.test.ts#"a share line removal must name a held pool through its own asset pair and fee", apps/api/tests/unit/pool-withdrawal.test.ts#"withdraws at the live reserves, alone, before the close disposes of what arrives" | Enforced, with a residual: the shares and reserves come from the API’s own account read, so a wholly hostile API that keeps that read consistent with its transactions is not caught |
| INV-60 | A sponsorship revoke of any kind (account, asset trustline, pool share trustline, offer, data entry, signer) names only an entry the account read lists in sponsoredEntries, matched by kind, owner and key (the asset, the pool id, the offer id, the data name, the signer’s strkey), at most once per transaction; without that list every revoke is refused. Each key comes from the operation’s own XDR: a data name that is not valid UTF-8 names no entry, and a revoke of a claimable balance’s or a liquidity pool’s sponsorship stays an unrecognized operation. The API finds pool share lines from the ledger entry’s own sponsor, since Horizon reports none on a pool share balance, treats an unreadable sponsor as an incomplete enumeration, and revokes a line only when its owner can hold its 2 base reserves. | apps/web/lib/stellar/verify.ts#assertSponsoredEntryRevoke, apps/web/lib/stellar/verify.ts#revokedEntryKey, apps/web/lib/stellar/intent/serialize.ts#revokedDataName, apps/web/lib/stellar/intent/serialize.ts#revokedSignerKey, apps/api/src/lib/stellar/pool-share-sponsors.ts#readPoolShareSponsors, apps/api/src/lib/stellar/sponsorship-reconcile.ts#RESERVES_PER_ENTRY | apps/web/tests/unit/verify.test.ts#"a revoke naming a different pool for a sponsored owner is refused", apps/web/tests/unit/verify.test.ts#"a revoke on another account's own, unsponsored line is refused", apps/web/tests/unit/verify-revoke-sponsorship.test.ts#"is refused for the same entry on another account", apps/web/tests/unit/verify-revoke-sponsorship.test.ts#"is refused when it names the same entry twice", apps/web/tests/unit/verify-revoke-sponsorship.test.ts#"verify › a listed key of another kind does not admit a revoke", apps/web/tests/unit/verify-revoke-sponsorship.test.ts#"verify › a data name that is not valid UTF-8 names no entry and is refused", apps/api/tests/unit/sponsorship-io.test.ts#"enumerateSponsoredEntries › a sponsored T or X signer is revoked under the strkey the read lists", apps/api/tests/unit/pool-share-sponsors.test.ts#"readPoolShareSponsors › a provider that sends no extXdr fails the read instead of reading unsponsored", apps/api/tests/unit/sponsorship-affordability.test.ts#"assessSponsorshipAffordability › a pool share line is unaffordable when its owner can hold only 1 base reserve more" | Enforced, with a residual: the list of sponsored entries comes from the API’s own account read, so a wholly hostile API that keeps that read consistent with its transactions is not caught |
| INV-61 | A served exchange registry may add an exchange that needs the mediated shape only when its signature verifies under a registry key pinned in the release, is not older than the registry bundled with the client, has not passed its validUntil and is not dated more than a day ahead; a missing, truncated, forged, stale or otherwise failing signature leaves the registry stricter-only, exactly as unsigned. A signed registry only adds exchanges: it cannot change a bundled entry, its memo type or its network scope. The signature gates the shape; it does not vouch for the account a mediated close merges into. | apps/web/lib/exchange-registry/signature.ts#verifyRegistrySignature, apps/web/lib/exchange-registry/merge.ts#resolveServedRegistry, apps/web/lib/exchange-registry/trust-roots.ts#REGISTRY_SIGNING_KEYS, apps/web/lib/stellar/verify.ts#registryView | apps/web/tests/unit/exchange-registry-signature.test.ts#"refuses a signature by a key that is not pinned", apps/web/tests/unit/exchange-registry-signature.test.ts#"a document older than the bundled one is refused", apps/web/tests/unit/exchange-registry-signature.test.ts#"is stale once validUntil has passed", apps/web/tests/unit/exchange-registry-signed.test.ts#"a failed verification leaves exactly the unsigned result", apps/web/tests/unit/exchange-registry-signed.test.ts#"a bundled address is never a mediated addition, whatever the signed copy says", apps/web/tests/unit/verify.test.ts#"an added exchange that needs the intermediary is accepted through the mediated shape", apps/web/tests/unit/verify.test.ts#"the same snapshot without a signature keeps the stricter-only behavior", apps/web/tests/unit/verify.test.ts#"keys named on the input are not read", apps/web/tests/unit/exchange-registry-signing-keys.test.ts#"verifies under the pinned keys for the committed registry, as of the day it was issued", packages/verify/tests/signed-registry-input.test.ts#"signed by a key of the caller's choosing, with keys named on the input, still refuses the hand-off" | Enforced, with one residual: the signature does not vouch for the mediator account (threat model, Section 5) |
The two server-side signing keys
| Id | Invariant | Enforced by | Proved by | Status |
|---|---|---|---|---|
| INV-15 | The mediator is a structural conduit: the browser accepts the hand-off only for a destination its bundled exchange registry lists as needing it on the close’s network (an entry marked testnet-only is unlisted on mainnet), and only when the account the merge pays into forwards the balance to the user’s address, and it refuses a merge straight into a destination the registry lists as needing it; both are derived from the registry the browser holds, never passed in by the caller (a served registry snapshot a caller passes is merged stricter-only and can add refusals; without a signature that verifies under the pinned keys it never adds the hand-off, with one it can add the hand-off for an address it adds and nothing else, see INV-61; and it never changes the network a bundled entry applies on); the API co-signs only that shape. | apps/web/lib/stellar/verify.ts#assertMergeShape, apps/web/lib/exchange-registry/index.ts#mediatorAllowedFor, apps/web/lib/exchange-registry/index.ts#requiresMediatorForAddress, apps/web/lib/exchange-registry/merge.ts#tightenedOver, apps/web/lib/stellar/verify.ts#assertForwardCarriesTheBalance, apps/api/src/mediator/mediator-signing.service.ts#MediatorSigningService | apps/web/tests/unit/verify.test.ts#"a mediated close passes without the client knowing the intermediary's address", apps/web/tests/unit/verify.test.ts#"rejects an intermediary that forwards dust and keeps the balance", apps/web/tests/unit/verify.test.ts#"rejects a mediated close whose balance was never read, whatever it forwards", apps/web/tests/unit/verify.test.ts#"a served registry entry cannot make the mediated hand-off reachable for a new address", apps/web/tests/unit/verify.test.ts#"a direct merge into an exchange the registry lists as needing the intermediary is refused, memo and all", apps/web/tests/unit/verify.test.ts#"a direct merge into such an exchange is refused whatever the caller says about the intermediary", apps/web/tests/unit/verify.test.ts#"a pre-authorized direct merge into an exchange that needs the intermediary is refused", apps/api/tests/unit/mediator-controller.test.ts#"S5a a single operation is refused", apps/api/tests/unit/mediator-controller.test.ts#"S10 co-signs with the mediator key and changes nothing else", apps/web/tests/unit/exchange-registry-network.test.ts#"a relay close to the stand-in with its id memo is accepted on testnet", apps/web/tests/unit/exchange-registry-network.test.ts#"the same relay close is refused on mainnet", apps/web/tests/unit/exchange-registry-network.test.ts#"a served snapshot that drops the scope does not open the relay on mainnet" | Enforced, with two residuals: the forward window S4a.Elevation.1 (threat model, Section 5), and the balance the forward is held to comes from the API’s account read (INV-04) |
| INV-16 | The fee-bump sponsor pays only for a wind-down transaction that acts for a single account. | apps/api/src/fee-bump/fee-bump-validation.ts#isAllowedWindDownOperation, apps/api/src/fee-bump/fee-bump-validation.ts#actsForOneAccount | apps/api/tests/unit/fee-bump-validation.test.ts#"refuses opening or raising a trustline, not just removing one", apps/api/tests/unit/fee-bump-validation.test.ts#"refuses a transaction bundling an operation for a different account, even a wind-down-shaped one" | Enforced, with a residual: a merge’s or a strict-send payment’s destination is not pinned (threat model, Section 11) |
| INV-17 | The mediator and fee-bump secrets live only in the API’s environment and never reach the browser. | apps/api/src/lib/stellar/mediator-server.ts, apps/api/src/lib/stellar/fee-account.ts | None | Design intent. The web reads none of these variables, but nothing fails if it starts to |
| INV-38 | The mediator and the fee-bump sponsor sign only an envelope that has not expired and expires within MAX_SIGNED_VALIDITY_SECONDS (the 300-second build window plus 30 seconds of clock slack). | apps/api/src/lib/stellar/validity-window.ts#validityProblem | apps/api/tests/unit/mediator-controller.test.ts#"S13a an envelope that never expires is not co-signed", apps/api/tests/unit/mediator-controller.test.ts#"S13b an envelope valid for longer than one built now is not co-signed", apps/api/tests/unit/mediator-controller.test.ts#"S13c an expired envelope is not co-signed", apps/api/tests/unit/fee-bump-controller.test.ts#"refuses an inner transaction that never expires", apps/api/tests/unit/fee-bump-controller.test.ts#"refuses an inner transaction valid for longer than an envelope built now", apps/api/tests/unit/fee-bump-controller.test.ts#"refuses an inner transaction that has already expired" | Enforced |
| INV-39 | The fee-bump sponsor signs only the next transaction of an existing account, pays at most MAX_FEE_BUMP_STROOPS per transaction, and stays within a daily budget per network, per source account, per API key and in total. | apps/api/src/fee-bump/sponsorship-budget.ts#SponsorshipBudget, apps/api/src/lib/stellar/account-sequence.ts#readAccountSequence | apps/api/tests/unit/sponsorship-budget.test.ts#"allows spend up to each limit and refuses the stroop beyond it", apps/api/tests/unit/sponsorship-budget.test.ts#"limits a key across sources and the total across keys", apps/api/tests/unit/fee-bump-controller.test.ts#"refuses with 429 once a scope's daily budget is spent, and signs nothing", apps/api/tests/unit/sponsorship-budget.test.ts#"each network keeps its own budget", apps/api/tests/unit/fee-bump-controller.test.ts#"refuses a transaction that is not the source account's next one" | Enforced, with a residual: the budget is held in the API process, so a restart starts the day’s budget again |
Boundaries between the apps
| Id | Invariant | Enforced by | Proved by | Status |
|---|---|---|---|---|
| INV-18 | The web builds no transactions: it only parses, verifies, signs and submits what the API built. | apps/web/eslint.config.mjs#txConstruction, apps/web/eslint.config.mjs#operationBuilders, apps/web/eslint.config.mjs#appZones, scripts/check-docs-claims.ts#checkWebBuildsNoTransactions | .github/workflows/ci.yml#check, .github/workflows/ci.yml#docs-claims, scripts/check-docs-claims.test.ts#"a web file that builds a transaction is reported, in any of the usual forms", apps/web/tests/unit/boundary-lint.test.ts#"building a transaction fails lint in every shipped folder", apps/web/tests/unit/boundary-lint.test.ts#"an import of apps/api or apps/playground source fails lint, by path or by alias" | Enforced, with a residual: the lint rules match the Stellar SDK’s builders by name (TransactionBuilder, the operation builders, the raw XDR envelope and operation constructors), so code that reaches one through an untyped indirection passes; the source check is a second heuristic. lib/cosign/merge.ts is the one file allowed to re-wrap a reviewed body with signatures |
| INV-19 | The playground never imports the API’s or the web’s source; it closes through the SDK. | apps/playground/eslint.config.mjs#appZones, scripts/check-docs-claims.ts#checkPlaygroundImports | .github/workflows/ci.yml#check, .github/workflows/ci.yml#docs-claims, scripts/check-docs-claims.test.ts#"a playground import from the api or web source is reported", apps/playground/tests/unit/boundary-lint.test.ts#"an import of apps/web or apps/api source fails lint" | Enforced |
| INV-20 | The playground checks every transaction with the web’s trust anchor (@lumenwipe/verify), held to its session record, before signing. | apps/playground/lib/verify.ts#verifyDemolishTransaction, apps/playground/lib/verify-soroban.ts#assertSorobanTransaction, apps/playground/lib/allowances.ts#revokeRecordedAllowance, apps/playground/lib/verify-revoke.ts#assertRevokeTransaction, apps/playground/lib/verify-feebump.ts#assertSponsoredEnvelope, apps/playground/lib/verify-mediator.ts#assertExchangeTransaction, apps/playground/lib/verify-mediator.ts#assertCosignedEnvelope, apps/playground/lib/verify-mediator.ts#assertDeliveredOnLedger | apps/playground/tests/unit/verify.test.ts#"every transaction verifies against its session", apps/playground/tests/unit/verify.test.ts#"removing a signer the session did not record is refused", apps/playground/tests/unit/verify.test.ts#"an asset from an issuer outside the session is refused, even paid to its issuer", apps/playground/tests/unit/verify.test.ts#"a merge that is not the final operation is refused", apps/api/tests/unit/playground-recipe.test.ts#"the playground recipes build the transactions in apps/playground's fixture", apps/playground/tests/unit/verify.test.ts#"a transfer to anyone but the recipient is refused, the issuer and the sink included", apps/playground/tests/unit/verify.test.ts#"a conversion of more than the demo holds is refused", apps/api/tests/unit/playground-dispositions-recipe.test.ts#"the dispositions recipes build the transactions in apps/playground's fixture", apps/playground/tests/unit/verify.test.ts#"a claim of a balance the session did not record is refused", apps/playground/tests/unit/verify.test.ts#"a revoke of an entry the session did not record is refused", apps/api/tests/unit/playground-claims-recipe.test.ts#"the claims and sponsoring recipes build the transactions in apps/playground's fixture", apps/playground/tests/unit/verify-soroban.test.ts#"a session whose selection seeds no protocol has every call refused by its Soroban module", apps/playground/tests/unit/verify-soroban.test.ts#"a contract the pinned row does not let a call be made to is refused", apps/playground/tests/unit/verify-soroban.test.ts#"a recipient other than the demo is refused", apps/playground/tests/unit/verify-soroban.test.ts#"the tokens named must be exactly the pinned pair's, in either order", apps/playground/tests/unit/verify-soroban.test.ts#"a call the Soroban module accepts still has to pass the shared verifier", apps/playground/tests/unit/verify-soroban.test.ts#"exitContracts: the router and the pair, only when the selection seeds the pool", apps/playground/tests/unit/playground-token.test.ts#"a transfer to any address but the pinned admin is refused", apps/playground/tests/unit/playground-token.test.ts#"an authorization that reaches below the transfer is refused, even into the token", apps/playground/tests/unit/playground-token.test.ts#"a session that leaves the token has the transfer refused by both checks", apps/playground/tests/unit/verify-revoke.test.ts#"a spender the session did not record is refused", apps/playground/tests/unit/verify-revoke.test.ts#"a non-zero amount is refused, as is an amount of another integer type", apps/playground/tests/unit/allowances.test.ts#"the shared anchor refuses what gets past the playground's check, with its own code", apps/playground/tests/unit/verify-feebump.test.ts#"is accepted only in a session that selected the sponsored fee, with a fee account", apps/playground/tests/unit/verify-feebump.test.ts#"a fee source other than the configured one is refused, even signed by itself", apps/playground/tests/unit/verify-feebump.test.ts#"an outer fee above the API sponsor's own cap is refused", apps/playground/tests/unit/verify-feebump.test.ts#"an inner transaction that breaks a normal rule is refused, sponsored or not", apps/playground/tests/unit/fee-bump-round.test.ts#"an envelope that fails its check is never submitted", apps/api/tests/unit/playground-fee-policy.test.ts#"the fee sponsor's policy is the one in apps/playground's fixture", apps/playground/tests/unit/exchange-close.test.ts#"a forward to another address is refused, even the relay's own", apps/playground/tests/unit/exchange-close.test.ts#"a forward below the recorded balance less 0.01 XLM is refused, and one at exactly that floor is accepted", apps/playground/tests/unit/exchange-close.test.ts#"a forward sent by another account than the one the merge paid into is refused", apps/playground/tests/unit/exchange-close.test.ts#"a text memo of the same digits is not the id memo", apps/playground/tests/unit/exchange-close.test.ts#"a merge straight into the stand-in is refused, alone or after a cleanup", apps/playground/tests/unit/exchange-close.test.ts#"a dropped signature is refused", apps/playground/tests/unit/exchange-close.test.ts#"the floor is the balance the playground read, never the API's figure", apps/api/tests/unit/playground-exchange-recipe.test.ts#"the exchange recipe builds and co-signs the transactions in apps/playground's fixture" | Enforced |
| INV-21 | The SDK is published without bundling the Stellar SDK. | scripts/check-docs-claims.ts#checkSdkDoesNotBundleStellarSdk | .github/workflows/ci.yml#docs-claims, scripts/check-docs-claims.test.ts#"an SDK that depends on or imports the Stellar SDK is reported" | Enforced |
Keys, confirmation and the page in the browser
| Id | Invariant | Enforced by | Proved by | Status |
|---|---|---|---|---|
| INV-22 | LumenWipe does not store, log or transmit the user’s secret key: the secret-key mode holds it only in memory and wipes it on completion, abort, navigation away or “Forget key”. | apps/web/lib/stellar/signer.ts#SecretKeySigner, apps/web/hooks/useActiveSigner.ts#useActiveSigner | apps/web/tests/unit/execution-wizard.test.tsx#"execution-wizard › an entered secret key reaches no React state and no store", apps/web/tests/unit/execution-wizard.test.tsx#"execution-wizard › Forget key drops the held key signer", apps/web/tests/unit/execution-wizard.test.tsx#"execution-wizard › leaving the screen drops the held key signer", apps/web/tests/unit/execution-wizard.test.tsx#"execution-wizard › a finished close drops the held key signer", apps/web/tests/unit/execution-wizard.test.tsx#"execution-wizard › a multisig pause drops the held key signer", apps/web/tests/unit/secret-key-input.test.tsx#"nothing is logged or persisted" | Partly enforced: the screen keeps the key out of React state and the store and drops it on Forget key, navigation away, completion and each multisig pause, all tested; that nothing is transmitted is checked by code reading in the threat model, Section 2 |
| INV-23 | Nothing is built or signed before the user confirms the whole plan on the review page, and nothing is saved for resumption before that confirmation. | apps/web/lib/plan/confirm-plan.ts#goToReview | apps/web/tests/unit/confirm-plan.test.ts#"goToReview sets phase to PREFLIGHT_COMPLETE, never STEP_EXECUTING", apps/web/tests/unit/confirm-plan.test.ts#"goToReview navigates to /review, never directly to /execute" | Partly enforced: the navigation to review is tested; that /execute refuses a direct visit and that nothing is saved before confirmation is design intent |
| INV-41 | The first build after the review carries the reviewed plan’s hash, and the API builds it only while the account’s sequence number and the answers still match those the plan was built from; a later round, after a transaction of the close confirmed, carries none and is hashed from its own state. | apps/api/src/close/close.service.ts#transactions, apps/api/src/lib/close-api/plan-response.ts#computePlanHash, packages/sdk/src/close-engine.ts#runClose, apps/web/hooks/useCloseExecution.ts#useCloseExecution | apps/api/tests/unit/close-controller.test.ts#"a hash the account no longer matches is a 409 state_changed and nothing is built", apps/api/tests/unit/close-controller.test.ts#"a multi-round close: round two is hashed from its own state and a legitimate change between rounds is no 409", packages/sdk/tests/close-engine.test.ts#"runClose › sends the reviewed plan hash until a transaction confirms, then never again", apps/web/tests/unit/use-close-execution.test.tsx#"useCloseExecution › the reviewed plan hash is sent until a transaction confirms, then cleared" | Enforced, with a residual: the hash covers the source, destination, answers and source sequence only, so a third-party change that does not move the sequence (an incoming payment, an offer being filled, a new claimable balance) leaves it unchanged; the round’s own RPC cross-check (INV-02) and verify() bound what such a change can do |
| INV-45 | A close is reported complete only from a confirmed by-hash answer for the hash the client computed from the exact final envelope it signed, with its own network passphrase, on a transaction it parsed as a merge of that account. A hash only the API returned, a covers claiming a merge, close/status reporting closed, and account_not_found alone never complete a close. | packages/sdk/src/close-engine.ts#submitUntilSettled, packages/sdk/src/close-engine.ts#resolveSubmission, apps/web/lib/stellar/submission.ts#submissionHash, apps/web/lib/stellar/submission.ts#mergesAccount | packages/sdk/tests/unit/close-reconcile.test.ts#"another transaction's hash never confirms, even when a lookup agrees with the API", packages/sdk/tests/unit/close-reconcile.test.ts#"a transaction the client did not parse as a merge never explains a missing account", apps/web/tests/unit/use-close-execution.test.tsx#"useCloseExecution › an API answering with another transaction's hash never completes", apps/web/tests/unit/use-close-execution.test.tsx#"useCloseExecution › covers claiming a merge on a transaction with none never closes the account", apps/web/tests/unit/use-close-execution.test.tsx#"useCloseExecution › past the give-up deadline a merged account stays plain language, never complete" | Enforced, with a residual: the browser reaches the chain only through the API, so the answer that a hash is confirmed comes from the API. The client-computed hash binds that answer to the transaction the user signed, and does not make it an independent witness: an API that lies about a lookup can still report a close that did not happen. Same limit as INV-04, see the threat model. A compromised API answering 422 or failed also clears the hash and can read as safe to retry; the next round re-reads live state, and the sequence number lets only one transaction of that sequence land. |
| INV-46 | While a hash is unresolved, nothing tells the user it failed or that retrying is safe, and a failed lookup or a 5xx settles nothing. Giving up needs the transaction past its time bounds plus a margin by both the client clock and the ledger close time, and only returns to a fresh round from a live read. | packages/sdk/src/close-engine.ts#isSubmitRefused, packages/sdk/src/close-engine.ts#resolveSubmission, apps/web/hooks/useCloseExecution.ts#useCloseExecution, apps/web/lib/utils/user-error.ts#closeRetryIsSafe | apps/web/tests/unit/use-close-execution.test.tsx#"useCloseExecution › a failed lookup or a 503 while reconciling stays unconfirmed", apps/web/tests/unit/use-close-execution.test.tsx#"useCloseExecution › a refused transaction that carried a preimage never reads as safe", packages/sdk/tests/unit/close-reconcile.test.ts#"a client clock running far ahead cannot give up while the ledger is behind", apps/web/tests/unit/execution-wizard.test.tsx#"execution-wizard › an unknown outcome shows the hash and a check, never failed or a retry" | Enforced |
| INV-47 | One API submit sends to one provider only, with no failover, and sends again only after that node answered TRY_AGAIN_LATER, which means it did not take the transaction. Anything else is a by-hash read, and the budget never abandons a send in flight. The client resends only the same bytes it already signed, never asks for a signature, co-sign or sponsorship again, and a refresh keeps the hash, covers and deadline alone, so it can only look up. The hash is written durably before the first send, and a failed write stops the send. While a hash is unresolved, every close page for that account and run itself offer only that lookup, a session holding it cannot be dismissed, an allowance revoke for that account is refused, so no second transaction of the same sequence is signed, and an envelope with no upper time bound is never sent, so a record can always expire. | apps/api/src/lib/stellar/submit.ts#submitAndWait, packages/sdk/src/close-engine.ts#submitUntilSettled, apps/web/lib/session/store.ts#saveUnconfirmed | apps/api/tests/unit/submit-reconcile.test.ts#"the next provider gets exactly one by-hash read and no send", apps/api/tests/unit/submit-reconcile.test.ts#"a send that outlives the budget is awaited, then answered as pending", packages/sdk/tests/unit/close-reconcile.test.ts#"a timeout then a confirmed resend finishes, sending the same bytes", apps/web/tests/unit/session-unconfirmed.test.ts#"a refresh keeps the hash, the covers and the deadline, and nothing else" | Enforced |
| INV-42 | The web attaches a hash(x) preimage only to a transaction that removes that same signer, judged on the decoded envelope. | apps/web/lib/stellar/signing-guards.ts#assertPreimageRemovesItsSigner, apps/web/hooks/useCloseExecution.ts#useCloseExecution | apps/web/tests/unit/signing-guards.test.tsx#"a preimage is never attached to a claim round, whatever the round says it covers", apps/web/tests/unit/signing-guards.test.tsx#"a paused exit round refuses the preimage and stops instead of carrying it", apps/web/tests/unit/signing-guards.test.tsx#"a transaction removing a different hash(x) signer does not admit this preimage", apps/web/tests/unit/signing-guards.test.tsx#"a preimage is accepted on the normalization that removes its own signer" | Enforced, with a residual: the guard lives in the web, so an SDK integrator must apply it in its own signing path, and the preimage is in the envelope sent to the API and public once any transaction carrying it reaches the ledger, even a failed one, or to anyone who reads the envelope before it lands |
| INV-43 | The web submits a transaction that removes signers and has no account_merge only when the envelope carries the master key’s signature and a set_options lowering every threshold to 1 or below, checked once the weight is met. A close that merges in the same transaction can be signed by co-signers alone. | apps/web/lib/stellar/signing-guards.ts#assertMasterSignsSignerRemoval, apps/web/hooks/useCloseExecution.ts#useCloseExecution | apps/web/tests/unit/signing-guards.test.tsx#"a removal of signers with no merge, signed by co-signers alone, is not submitted", apps/web/tests/unit/signing-guards.test.tsx#"a removal with no merge and no threshold reset is not submitted, even signed by the master key", apps/web/tests/unit/signing-guards.test.tsx#"the same removal is submitted once the master key has signed it", apps/web/tests/unit/signing-guards.test.tsx#"a close that merges in the same transaction still works with co-signers alone", apps/web/tests/unit/signing-guards.test.tsx#"a multisig round short of its weight stays resumable, and no check fires before it is met" | Enforced, with a residual: the guard lives in the web, so an SDK integrator must apply it in its own submit path, and a user’s own pre-authorized transaction is not held to it |
| INV-52 | With transactionHash, the SDK close engine pins each transaction’s hash right after verify passes, refuses with ApprovedHashMismatchError and nothing submitted any resumed or signed envelope whose transaction does not hash to it, and lets a resumed round reach prepare without a signer call only when its xdr hashes to the hash pinned at verify time and the weight it carries already meets what it needs. | packages/sdk/src/close-engine.ts#resumeRound, packages/sdk/src/close-engine.ts#assertApproved | packages/sdk/tests/pinned-approved-hash.test.ts#"pinned hash › a paused round carries the hash of the verified xdr, taken after verify", packages/sdk/tests/pinned-approved-hash.test.ts#"pinned hash › a resumed round at full weight goes to prepare with no signer call", packages/sdk/tests/pinned-approved-hash.test.ts#"pinned hash › a resumed round below weight still asks the signer", packages/sdk/tests/pinned-approved-hash.test.ts#"pinned hash › a resumed envelope with another body hash is refused before anything", packages/sdk/tests/pinned-approved-hash.test.ts#"pinned hash › a pinned round resumed without transactionHash is refused", packages/sdk/tests/pinned-approved-hash.test.ts#"pinned hash › a signer that returns another body is refused, fresh and resumed", packages/sdk/tests/pinned-approved-hash.test.ts#"pinned hash › an unpinned resume at full weight still calls the signer" | Enforced, with a residual: the hash is checked on the envelope handed to prepare, so a prepare that co-signs or fee-bumps must keep that transaction itself (the web’s does, by inner hash); the weight a resumed round carries is the caller’s own count, and the network still enforces it; a run without transactionHash keeps the unpinned behavior |
| INV-24 | A destructive choice reaches the API only as the user’s own acknowledgement for that exact destination or account, and the tool never submits on its own. | apps/web/lib/api/close-decisions.ts#destinationAcknowledgementToDecisions | apps/web/tests/unit/close-decisions.test.ts#"destinationAcknowledgementToDecisions › does not carry an acknowledgement to a different destination", apps/web/tests/unit/close-decisions.test.ts#"destinationAcknowledgementToDecisions › emits nothing when nothing was acknowledged" | Partly enforced: how acknowledgements are carried is tested; that every submission and the merge’s full-screen confirmation wait for a user action is design intent |
| INV-25 | The API reports whether a destination exists and whether it needs the mediator or a memo, so the client can ask before it builds anything. | apps/api/src/mediator/mediator-signing.service.ts#MediatorSigningService | apps/api/tests/unit/mediator-controller.test.ts#"C1 a listed exchange reports the mediator and memo requirements", apps/api/tests/unit/mediator-controller.test.ts#"C2b an unlisted address that requires a memo on-chain reports it", apps/api/tests/unit/mediator-controller.test.ts#"C3 an unlisted missing address is reported as to-be-created" | Partly enforced: the destination check is tested; showing the full address before the merge is design intent |
| INV-48 | No cached response becomes an input to a signed or verified value: the destination check may refuse a close and supplies nothing to it, path quotes are never stored, and every cached route is keyed by network and listed with its reason. | apps/web/lib/plan/destination-check.ts#destinationRefusal, apps/web/lib/api/proxy.ts#proxy | apps/web/tests/unit/cached-response-boundary.test.ts#"only the gate and its route read the destination check", apps/web/tests/unit/cached-response-boundary.test.ts#"the signing path cannot reach the gate", apps/web/tests/unit/cached-response-boundary.test.ts#"the gate returns only a refusal", apps/web/tests/unit/cached-routes.test.ts#"every cached route is documented", apps/web/tests/unit/destination-check.test.tsx#"two answers that both pass leave the same store and the same plan request" | Enforced, with a residual: the scans see the web source as written, and close/plan and account still feed verify() by design, uncached (INV-04) |
| INV-49 | A Soroban token conversion whose quote is flagged (a price impact above 5%, an impact that could not be measured, or a quote more than 10% above the other provider’s) is never the recommended option or the default, and the plan stays blocked while it is answered convert without a confirmation naming the same floor as the convert answer. | apps/api/src/lib/close-api/multi-source-conversion.ts#quoteFlags, apps/api/src/lib/close-api/decisions.ts#deriveTokenDecisionPoints, apps/api/src/lib/close-api/decisions.ts#isConversionImpactAcknowledged, apps/api/src/lib/close-api/decisions.ts#conversionImpactBlockers | apps/api/tests/adversarial/high-impact-token-conversion.test.ts#"a far-too-large xBull quote with no impact field is flagged and never recommended", apps/api/tests/unit/close-api-token-decisions.test.ts#"a flagged quote is offered but never recommended, and is not the default", apps/api/tests/unit/close-api-token-decisions.test.ts#"a confirmation counts only for the exact floor the latest convert answer carries", apps/api/tests/unit/close-api-token-decisions.test.ts#"the plan gates a flagged conversion on its confirmation, and marks a token past the quote limit" | Enforced, with a residual: the confirmation is a plan and interface gate; close/transactions does not re-check it, and the pinned floor the checkbox names is what bounds the swap (INV-36) |
| INV-26 | In production, marketing pages run only inline scripts whose exact SHA-256 hashes were computed from that page’s build output, plus same-origin script files, among them the pinned copy of Umami’s tracker, and reach no third-party origin except Umami’s collector, only on a page carrying the Umami tag with its redaction; app and sign-in routes, and a 404, keep the per-request nonce policy unchanged, allowing only scripts carrying the nonce and those they load (strict-dynamic). Neither policy allows unsafe-inline or unsafe-eval in script-src. | apps/web/proxy.ts#proxy, apps/web/scripts/marketing-csp.mjs#run, apps/web/scripts/marketing-csp.mjs#checkOutput | apps/web/tests/unit/proxy.test.ts#"the network, sign-in and 404 paths keep the nonce policy byte for byte", apps/web/tests/unit/marketing-csp.test.ts#"check mode fails on a page that runs a script its entry does not hash", apps/web/tests/unit/proxy-matcher.test.ts#"skips every prerendered marketing page and its RSC payload, so a new post or Spanish page needs its line", apps/web/tests/unit/marketing-csp.test.ts#"a policy only in the routes manifest does not count once the adapter wrote its output", apps/web/tests/unit/marketing-csp.test.ts#"Umami's own script, or any lookalike of it, fails the build: only the pinned copy runs", apps/web/tests/unit/umami-tracker-pin.test.ts#"the pinned Umami tracker is exactly the reviewed copy, named by its own hash", apps/web/tests/unit/marketing-csp.test.ts#"an Umami tag that keeps the query or fragment, or has no redaction hook, fails the build", apps/web/tests/unit/root-document.test.ts#"only the marketing root layouts mount Umami" | Enforced, with a residual: the marketing policy is written after next build into the Build Output config Vercel’s build adapter produced (.next/output/config.json), or for next start into Next’s routes manifest, so it depends on those formats; the build fails if any marketing page is left without a policy that hashes all its inline scripts, and the web vercel build (adapter) CI job checks the finished Vercel output |
| INV-53 | The cosign station never submits a transaction, and sends the API only the network and the account address; the request, the response and the signer are kept nowhere but in the page’s own state. | apps/web/components/cosign/CosignStation.tsx#CosignStation | apps/web/tests/unit/cosign-station.test.tsx#"sends the API only the network and the account, and stores nothing" | Enforced, with a residual: the test pins the requests and storage writes of one full import and signature; a later change that adds a request elsewhere on the page is caught only if it runs on that path |
| INV-54 | A cosign artifact carries exactly its six fields: no expectations, hash, fingerprint or URL. A request carries no signatures, and a station’s response carries only the signature of the key that signed on it. | apps/web/lib/cosign/artifact.ts#parseCosignArtifact, apps/web/lib/cosign/artifact.ts#serializeCosignArtifact, apps/web/lib/cosign/station-checks.ts#responseFromSigned | apps/web/tests/unit/cosign-artifact.test.ts#"round-trips and writes exactly the six fields", apps/web/tests/unit/cosign-artifact.test.ts#"never adds a field the input carries", apps/web/tests/unit/cosign-artifact.test.ts#"refuses to write a request that carries signatures", apps/web/tests/unit/cosign-artifact.test.ts#"returns a valid artifact or throws CosignArtifactError, for random and truncated input", apps/web/tests/unit/cosign-station-checks.test.ts#"drops a signature from another key that the signer added" | Enforced |
| INV-55 | The hub never uses a received transaction body: it takes from a cosign response only signatures that verify over the hash pinned when it verified the round, each for exactly one ed25519 signer of the round and not already collected, and attaches a set in which every signature is needed, so none can go unused in any order the network counts them. It re-reads the account’s signers live before preparing that round. | apps/web/lib/cosign/merge.ts#verifyResponse, apps/web/lib/cosign/merge.ts#minimalSignatureSet, apps/web/lib/cosign/merge.ts#assertStillSignable | apps/web/tests/unit/cosign-merge.test.ts#"judges a response by the hash pinned at verify time, not by the round's envelope", apps/web/tests/unit/cosign-merge.test.ts#"refuses a signature made for another network", apps/web/tests/unit/cosign-merge.test.ts#"refuses a signature whose hint names two signers", apps/web/tests/unit/cosign-merge.test.ts#"refuses a duplicate key, in the response or already collected", apps/web/tests/unit/cosign-merge.test.ts#"every set it returns meets the weight and needs every signature", apps/web/tests/unit/use-close-execution-cosign.test.tsx#"merged responses resume through the engine with no signer and submit the minimal set", apps/web/tests/unit/use-close-execution-cosign.test.tsx#"signers that changed since the build stop the cosigned round before anything is sent", apps/web/tests/unit/use-close-execution-cosign.test.tsx#"a run with the master key on a merged round still re-reads the signers before sending" | Enforced, with a residual: a response is a bearer authorization until the transaction’s maxTime, so anyone holding enough of them can submit it outside LumenWipe; the hub then finds it by its inner hash (apps/web/tests/unit/use-close-execution-cosign.test.tsx#"a cosigned round already confirmed elsewhere is found by its inner hash", apps/web/tests/unit/use-close-execution-cosign.test.tsx#"a merged round whose sequence was used is looked up by its inner hash before reporting") |
| INV-56 | A device signs a received transaction only after verify() and the approved-hash check pass on that device: the station verifies with preAuthorized: false, against the account the cosigner typed and its own live read, and only signer normalization that removes every other signer of the account; the hub exports only a round it pinned at verify time that is such a normalization. | apps/web/lib/cosign/station-checks.ts#checkRequest, apps/web/lib/cosign/station-checks.ts#assertSignerNormalization, apps/web/lib/cosign/merge.ts#cosignExport | apps/web/tests/unit/cosign-station-checks.test.ts#"refuses with verify()'s own message when verify() refuses", apps/web/tests/unit/cosign-station-checks.test.ts#"refuses a request for another account than the one typed", apps/web/tests/unit/cosign-station-checks.test.ts#"refuses a partial removal that would leave another signer in control", apps/web/tests/unit/cosign-station-checks.test.ts#"refuses a signed transaction that is not the one approved", apps/web/tests/unit/cosign-merge.test.ts#"is not offered for a round that removes only some of the other signers" | Enforced |
Supply chain
| Id | Invariant | Enforced by | Proved by | Status |
|---|---|---|---|---|
| INV-27 | A high or critical dependency advisory that is not allowlisted with a reason fails CI, and every CI install uses the lockfile as is. | scripts/audit-gate.ts#main, .github/workflows/ci.yml#audit | scripts/audit-gate.test.ts#"fails on a high or critical advisory that is not allowlisted", .github/workflows/ci.yml#audit | Partly enforced: the advisory gate is tested; that every install passes --frozen-lockfile is design intent |
| INV-28 | No dependency that needs dynamic code execution runs in the production web app. | apps/web/proxy.ts#proxy | None | Design intent: a production policy without unsafe-eval (INV-26) would block it at runtime, and nothing checks for it at build time |
Public endpoints
| Id | Invariant | Enforced by | Proved by | Status |
|---|---|---|---|---|
| INV-29 | The public deep health check and dependency view report each dependency as a fixed status with its latency, never upstream error text, a provider URL or a credential; the detail goes to the server log with the provider reduced to its host. | apps/api/src/health/health.controller.ts#HealthController | apps/api/tests/unit/health-controller.test.ts#"a failed RPC probe reports only a fixed status and latency, never the upstream error text", apps/api/tests/unit/health-controller.test.ts#"the upstream detail is logged with the provider reduced to its host", apps/api/tests/unit/dependency-probes.test.ts#"the route exposes only the fixed fields, whatever the providers answered" | Enforced |
| INV-31 | The public close statistics count a transaction only when the network confirms it as a successful account merge, the API itself built it for that network, and it was not counted before; a failed read or decode counts nothing. | apps/api/src/stats/stats.service.ts#StatsService, apps/api/src/stats/merge-verification.ts#verifyMerge, apps/api/src/close/close.service.ts#CloseService | apps/api/tests/unit/stats-service.test.ts#"writes nothing for a confirmed merge this API did not build", apps/api/tests/unit/stats-service.test.ts#"counts a verified close once, however many times it is reported", apps/api/tests/unit/merge-verification.test.ts#"does not count a transaction whose envelope cannot be read", apps/api/tests/unit/close-controller.test.ts#"T13c the hash of every built transaction that merges the account is noted for the counter" | Enforced |
API access
| Id | Invariant | Enforced by | Proved by | Status |
|---|---|---|---|---|
| INV-30 | The API counts a request against an API key only once the key resolves; any other request is counted against its client IP, taken from the last X-Forwarded-For entry, and key-store lookups are bounded by a separate per-client budget. | apps/api/src/auth/rate-limiter.ts#RateLimiter, apps/api/src/auth/api-key-directory.ts#ApiKeyDirectory, apps/api/src/configure-app.ts#TRUSTED_PROXY_HOPS | apps/api/tests/unit/rate-limiter.test.ts#"invented bearers from one client share that client's IP budget", apps/api/tests/unit/rate-limiter.test.ts#"once the client's lookup budget is spent, an unknown key costs no store read", apps/api/tests/unit/api-key-directory.test.ts#"the unknown-key cache never holds more than its cap, dropping the oldest first", apps/api/tests/e2e/unauthenticated-throttle.e2e.test.ts#"only the last X-Forwarded-For entry identifies the client" | Enforced, with a residual: one hop is correct only while nothing sits in front of Cloud Run’s own front end (threat model, Section 10) |
| INV-57 | A contract account gets a key-management session only when an enforcing simulation of the challenge’s web_auth_verify call succeeds on every configured RPC provider, each showing the attested web authentication contract and the server account, for a challenge this server issued to that account on that network less than five minutes ago, used once, whose account entry carries a credential kind the table of supported kinds reads (legacy or v2 address credentials; delegated-signers and source-account credentials are refused by name). | apps/api/src/integrator/contract-auth.ts#readSignedContractChallenge, apps/api/src/integrator/contract-auth.ts#verifyOnEveryProvider, apps/api/src/integrator/contract-auth.ts#isReady, apps/api/src/integrator/contract-auth.ts#unsupportedCredentialKind, apps/api/src/integrator/used-challenge-store.ts#FirestoreUsedChallengeStore | apps/api/tests/unit/contract-auth.test.ts#"the session needs every provider: one refusal refuses even when the first agrees", apps/api/tests/unit/contract-auth.test.ts#"a forged authorization is refused: signed by a key the account does not accept", apps/api/tests/unit/contract-auth.test.ts#"an account signed by its own key signs in, simulated in enforcing mode", apps/api/tests/unit/contract-auth.test.ts#"a challenge issued for the other network is refused", apps/api/tests/unit/contract-auth.test.ts#"a web authentication contract that is not the attested build is never simulated", apps/api/tests/unit/integrator-controller.test.ts#"a replayed authorization is refused", apps/api/tests/unit/contract-auth.test.ts#"every credential kind the SDK knows is either read or refused by name", apps/api/tests/unit/contract-auth.test.ts#"a delegated entry under a legacy base and under a V2 base both read as refused", apps/api/tests/unit/integrator-controller.test.ts#"a delegated credential is refused by name before anything is read, and the challenge stays usable" | Enforced, with a residual: the verdict is the providers’ simulation, so providers that all lie together can grant a session, and an account whose __check_auth accepts anyone can be signed in as by anyone (threat model, Section 10) |
| INV-58 | A wallet (G…) gets a key-management session only for a challenge this server issued to that address less than five minutes ago, signed by that address under SEP-53, used once: a second exchange is refused, a failed signature consumes nothing, and a store that cannot answer refuses. | apps/api/src/integrator/wallet-auth.ts#verifyChallenge, apps/api/src/integrator/integrator.controller.ts#session, apps/api/src/integrator/used-challenge-store.ts#FirestoreUsedChallengeStore | apps/api/tests/unit/wallet-auth.test.ts#"rejects a message whose salt was edited or removed", apps/api/tests/unit/wallet-auth.test.ts#"rejects an expired challenge", apps/api/tests/unit/integrator-controller.test.ts#"a second exchange of the same signed challenge is refused", apps/api/tests/unit/integrator-controller.test.ts#"a concurrent double exchange yields one session", apps/api/tests/unit/integrator-controller.test.ts#"a failed signature does not consume the challenge", apps/api/tests/unit/integrator-controller.test.ts#"the claim names the signed challenge and expires with it", apps/api/tests/unit/integrator-controller.test.ts#"a store that cannot answer gives a 503, never a session" | Enforced |
Keeping this page true
A new close operation, signing key, adapter or app boundary adds or changes its row here in the same pull request, following the maintenance rule in the threat model, Section 13. Runbun run check:docs before pushing; CI runs it on every pull request.