@zktx.io/sui-mcp 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSES/@mysten-bcs-2.0.5-Apache-2.0.txt +205 -0
  3. package/LICENSES/@mysten-sui-2.17.0-Apache-2.0.txt +201 -0
  4. package/LICENSES/@mysten-utils-0.3.3-Apache-2.0.txt +205 -0
  5. package/LICENSES/fancy-canvas-2.1.0-MIT.txt +7 -0
  6. package/LICENSES/lightweight-charts-5.2.0-NOTICE.txt +2 -0
  7. package/README.md +288 -0
  8. package/dist/adapters/adapterLifecycleValidators.js +5 -0
  9. package/dist/adapters/adapterPromptSurfaces.js +60 -0
  10. package/dist/adapters/deepbook/deepbookHumanReviewProducer.js +178 -0
  11. package/dist/adapters/deepbook/deepbookQuotePolicy.js +112 -0
  12. package/dist/adapters/deepbook/deepbookReviewEvidence.js +507 -0
  13. package/dist/adapters/deepbook/deepbookReviewLifecycle.js +85 -0
  14. package/dist/adapters/deepbook/deepbookSwapIntent.js +79 -0
  15. package/dist/adapters/deepbook/deepbookTransactionMaterialProducer.js +254 -0
  16. package/dist/adapters/intentPlanFactories.js +51 -0
  17. package/dist/adapters/reviewAdapters.js +47 -0
  18. package/dist/core/action/adapterLifecycleValidation.js +12 -0
  19. package/dist/core/action/contractNameRegistry.js +151 -0
  20. package/dist/core/action/forbiddenFields.js +43 -0
  21. package/dist/core/action/humanReadableReviewEvidence.js +193 -0
  22. package/dist/core/action/humanReadableReviewProjectionVerifier.js +29 -0
  23. package/dist/core/action/ptbVisualizationProducer.js +71 -0
  24. package/dist/core/action/receiptPtbGraph.js +29 -0
  25. package/dist/core/action/reviewCheckResults.js +6 -0
  26. package/dist/core/action/reviewStateValidation.js +11 -0
  27. package/dist/core/action/reviewTimeSimulationEvidence.js +470 -0
  28. package/dist/core/action/schemas.js +491 -0
  29. package/dist/core/action/signableAdapterContract.js +998 -0
  30. package/dist/core/action/suiChainReceiptEvidence.js +106 -0
  31. package/dist/core/action/suiChainReceiptMapping.js +107 -0
  32. package/dist/core/action/suiChainReceiptReader.js +211 -0
  33. package/dist/core/action/suiChainReceiptVerifier.js +178 -0
  34. package/dist/core/action/swapHumanReadableReviewProjection.js +130 -0
  35. package/dist/core/action/swapQuotePolicyEvidence.js +271 -0
  36. package/dist/core/action/transactionFunding.js +244 -0
  37. package/dist/core/action/transactionObjectOwnershipEvidence.js +256 -0
  38. package/dist/core/action/transactionObjectOwnershipProducer.js +323 -0
  39. package/dist/core/action/types.js +33 -0
  40. package/dist/core/action/walletReviewContractAssembler.js +286 -0
  41. package/dist/core/activity/accountAssetTimeline.js +157 -0
  42. package/dist/core/activity/accountAssetTimelineUsdcReferences.js +120 -0
  43. package/dist/core/activity/activityStore.js +16 -0
  44. package/dist/core/activity/externalActivityCoverage.js +76 -0
  45. package/dist/core/activity/externalActivityTransactionStream.js +82 -0
  46. package/dist/core/activity/localDataService.js +296 -0
  47. package/dist/core/activity/localDataTypes.js +11 -0
  48. package/dist/core/activity/localDataValidation.js +439 -0
  49. package/dist/core/activity/schemaVersion.js +2 -0
  50. package/dist/core/activity/sqliteActivityStore.js +1068 -0
  51. package/dist/core/activity/sqliteActivityStoreRows.js +389 -0
  52. package/dist/core/activity/sqliteActivityStoreSchema.js +367 -0
  53. package/dist/core/activity/sqliteActivityStoreTypes.js +5 -0
  54. package/dist/core/activity/suiFunctionTarget.js +43 -0
  55. package/dist/core/activity/transactionActivityAccountEffects.js +186 -0
  56. package/dist/core/activity/transactionActivityAnalysis.js +295 -0
  57. package/dist/core/activity/transactionActivityClassifier.js +306 -0
  58. package/dist/core/activity/transactionActivityDetails.js +229 -0
  59. package/dist/core/activity/transactionActivityProtocolRules.js +218 -0
  60. package/dist/core/activity/transactionActivityScanPolicy.js +170 -0
  61. package/dist/core/activity/transactionActivityService.js +379 -0
  62. package/dist/core/activity/transactionActivityTypes.js +18 -0
  63. package/dist/core/eventlog/sink.js +35 -0
  64. package/dist/core/evidence/settlementFamilies.js +85 -0
  65. package/dist/core/evidence/userAnswerUse.js +1 -0
  66. package/dist/core/numeric/rawU64.js +63 -0
  67. package/dist/core/preferences/preferencesStore.js +26 -0
  68. package/dist/core/preferences/sqlitePreferencesRepository.js +136 -0
  69. package/dist/core/proposal/externalProposalReview.js +347 -0
  70. package/dist/core/proposal/schemas.js +208 -0
  71. package/dist/core/proposal/types.js +35 -0
  72. package/dist/core/read/amounts.js +14 -0
  73. package/dist/core/read/coinMetadata.js +60 -0
  74. package/dist/core/read/deepbookOfficialIndexerSource.js +373 -0
  75. package/dist/core/read/deepbookRawQuoteClient.js +86 -0
  76. package/dist/core/read/deepbookReadHelpers.js +321 -0
  77. package/dist/core/read/deepbookRegistry.js +157 -0
  78. package/dist/core/read/deepbookSourceOwners.js +159 -0
  79. package/dist/core/read/deepbookUsdcChartService.js +342 -0
  80. package/dist/core/read/intentEvidenceResponseFormatting.js +228 -0
  81. package/dist/core/read/readCardInputs.js +19 -0
  82. package/dist/core/read/readCardResult.js +40 -0
  83. package/dist/core/read/readResponseGuidance.js +402 -0
  84. package/dist/core/read/readService.js +1639 -0
  85. package/dist/core/read/readServiceTypes.js +88 -0
  86. package/dist/core/read/settlementParityFormatting.js +82 -0
  87. package/dist/core/read/walletReadHelpers.js +99 -0
  88. package/dist/core/review/reviewChecks.js +45 -0
  89. package/dist/core/review/reviewComputation.js +38 -0
  90. package/dist/core/review/reviewComputationResult.js +87 -0
  91. package/dist/core/session/cardSession.js +31 -0
  92. package/dist/core/session/cardSessionStore.js +204 -0
  93. package/dist/core/session/keyedRecordStore.js +18 -0
  94. package/dist/core/session/liveReviewSessionContract.js +3 -0
  95. package/dist/core/session/localSession.js +31 -0
  96. package/dist/core/session/privateReviewArtifacts.js +75 -0
  97. package/dist/core/session/reviewValidity.js +49 -0
  98. package/dist/core/session/sessionErrors.js +9 -0
  99. package/dist/core/session/sessionRecordStore.js +40 -0
  100. package/dist/core/session/sessionStore.js +655 -0
  101. package/dist/core/session/settingsSession.js +1 -0
  102. package/dist/core/session/settingsSessions.js +45 -0
  103. package/dist/core/session/sqliteCardStore.js +88 -0
  104. package/dist/core/session/sqliteSessionStore.js +213 -0
  105. package/dist/core/session/sqliteTransactionMaterialStore.js +64 -0
  106. package/dist/core/session/sqliteWalletWorkflowStore.js +821 -0
  107. package/dist/core/session/status.js +60 -0
  108. package/dist/core/session/transactionMaterialStore.js +221 -0
  109. package/dist/core/session/transactionRequest.js +72 -0
  110. package/dist/core/session/wait.js +79 -0
  111. package/dist/core/session/walletConnection.js +92 -0
  112. package/dist/core/session/walletRuntime.js +38 -0
  113. package/dist/core/session/walletWorkflow.js +608 -0
  114. package/dist/core/session/workflowState.js +80 -0
  115. package/dist/core/session/workflowView.js +150 -0
  116. package/dist/core/suiAddress.js +18 -0
  117. package/dist/core/suiEndpoint.js +72 -0
  118. package/dist/mcp/activeAccountResponse.js +24 -0
  119. package/dist/mcp/prompts.js +146 -0
  120. package/dist/mcp/registerTool.js +19 -0
  121. package/dist/mcp/resources.js +72 -0
  122. package/dist/mcp/responseGuidance.js +326 -0
  123. package/dist/mcp/result.js +17 -0
  124. package/dist/mcp/schemas.js +11 -0
  125. package/dist/mcp/server.js +32 -0
  126. package/dist/mcp/serverInfo.js +131 -0
  127. package/dist/mcp/toolErrors.js +118 -0
  128. package/dist/mcp/toolNames.js +58 -0
  129. package/dist/mcp/tools/account/index.js +44 -0
  130. package/dist/mcp/tools/action/prepareSuiActionReview.js +126 -0
  131. package/dist/mcp/tools/read/commonSchemas.js +43 -0
  132. package/dist/mcp/tools/read/deepbookReadTools.js +686 -0
  133. package/dist/mcp/tools/read/index.js +14 -0
  134. package/dist/mcp/tools/read/readToolHelpers.js +97 -0
  135. package/dist/mcp/tools/read/reviewActivityTools.js +179 -0
  136. package/dist/mcp/tools/read/serverStatusTools.js +100 -0
  137. package/dist/mcp/tools/read/transactionActivityOutput.js +371 -0
  138. package/dist/mcp/tools/read/transactionActivityTools.js +858 -0
  139. package/dist/mcp/tools/read/walletReadTools.js +734 -0
  140. package/dist/mcp/tools/session/executionResultTools.js +44 -0
  141. package/dist/mcp/tools/session/index.js +8 -0
  142. package/dist/mcp/tools/session/shared.js +36 -0
  143. package/dist/mcp/tools/session/statusTools.js +69 -0
  144. package/dist/mcp/tools/session/walletConnectionTools.js +69 -0
  145. package/dist/mcp/tools/settings/index.js +66 -0
  146. package/dist/mcp-app/account.html +3133 -0
  147. package/dist/mcp-app/account.notices.txt +973 -0
  148. package/dist/mcp-app/chart.html +3354 -0
  149. package/dist/mcp-app/chart.notices.txt +1194 -0
  150. package/dist/mcp-app/connect.html +3179 -0
  151. package/dist/mcp-app/connect.notices.txt +1012 -0
  152. package/dist/mcp-app/receipt.html +8430 -0
  153. package/dist/mcp-app/receipt.notices.txt +3549 -0
  154. package/dist/mcp-app/review.html +8430 -0
  155. package/dist/mcp-app/review.notices.txt +3549 -0
  156. package/dist/mcp-ui/contracts.js +31 -0
  157. package/dist/mcp-ui/readCards.js +28 -0
  158. package/dist/mcp-ui/tools.js +134 -0
  159. package/dist/review-app/brand-dark.svg +1 -0
  160. package/dist/review-app/brand-light.svg +1 -0
  161. package/dist/review-app/favicon.svg +1 -0
  162. package/dist/review-app/settings.css +1 -0
  163. package/dist/review-app/settings.js +1 -0
  164. package/dist/review-app/ui.css +809 -0
  165. package/dist/review-server/assets.js +48 -0
  166. package/dist/review-server/html.js +45 -0
  167. package/dist/review-server/http.js +47 -0
  168. package/dist/review-server/middleware/hostOrigin.js +48 -0
  169. package/dist/review-server/middleware/reviewToken.js +7 -0
  170. package/dist/review-server/reviewServerPolicy.js +1 -0
  171. package/dist/review-server/server.js +72 -0
  172. package/dist/review-server/settingsApi.js +158 -0
  173. package/dist/runtime/application.js +203 -0
  174. package/dist/runtime/config.js +97 -0
  175. package/dist/runtime/localSettingsService.js +198 -0
  176. package/dist/runtime/logger.js +66 -0
  177. package/dist/runtime/reviewDependencies.js +58 -0
  178. package/dist/runtime/reviewServerAcquire.js +93 -0
  179. package/dist/runtime/runtimeTermination.js +60 -0
  180. package/dist/runtime/shared/authenticatedFetch.js +127 -0
  181. package/dist/runtime/shared/control.js +93 -0
  182. package/dist/runtime/shared/dataAccess.js +66 -0
  183. package/dist/runtime/shared/mcpHttp.js +84 -0
  184. package/dist/runtime/shared/ownerLease.js +50 -0
  185. package/dist/runtime/shared/server.js +98 -0
  186. package/dist/runtime/shared/stdio.js +113 -0
  187. package/dist/runtime/smokeMainnetRead.js +391 -0
  188. package/dist/runtime/smokeMainnetReadAssertions.js +306 -0
  189. package/dist/runtime/smokeReview.js +40 -0
  190. package/dist/runtime/start.js +90 -0
  191. package/dist/runtime/suiEndpoint.js +97 -0
  192. package/dist/runtime/suiTransactionGraphqlMapping.js +200 -0
  193. package/dist/runtime/suiTransactionGraphqlQueries.js +231 -0
  194. package/dist/runtime/suiTransactionGraphqlSource.js +148 -0
  195. package/dist/runtime/walletConnectConfig.js +3 -0
  196. package/dist/runtime/walletConnectStorage.js +99 -0
  197. package/dist/runtime/walletConnectTransport.js +128 -0
  198. package/dist/runtime/walletSdkChild.js +3 -0
  199. package/dist/runtime/walletSdkChildRuntime.js +160 -0
  200. package/dist/runtime/walletSdkIpc.js +26 -0
  201. package/dist/runtime/walletSdkProcess.js +358 -0
  202. package/docs/AGENT_BEHAVIOR.md +524 -0
  203. package/docs/AGENT_DEVELOPMENT_POLICY.md +815 -0
  204. package/docs/FRONTEND_POLICY.md +534 -0
  205. package/docs/LOCAL_DB_ARCHITECTURE.md +381 -0
  206. package/docs/MCP_SETUP.md +742 -0
  207. package/docs/MCP_TOOLS.md +1318 -0
  208. package/docs/SDK_API.md +206 -0
  209. package/docs/SIGNABLE_ADAPTER_CONTRACT.md +396 -0
  210. package/docs/TRANSACTION_ACTIVITY_LOG.md +194 -0
  211. package/docs/UTILITY_INDEX.md +275 -0
  212. package/docs/WALLET_CONNECTION.md +238 -0
  213. package/docs/golden-scenarios/BEHAVIOR_MATRIX.md +166 -0
  214. package/docs/golden-scenarios/INTENT_EVIDENCE_GOLDEN_ANSWERS.md +161 -0
  215. package/docs/golden-scenarios/INTENT_EVIDENCE_MATRIX.md +259 -0
  216. package/package.json +79 -0
  217. package/protocols/deepbook-margin.md +15 -0
  218. package/protocols/deepbook-v3.md +24 -0
@@ -0,0 +1,815 @@
1
+ # Agent Development Policy
2
+
3
+ This document contains binding development, review, documentation, and
4
+ source-of-truth policies for coding agents working in this repository.
5
+
6
+ Read `AGENTS.md` first. Read this document whenever the task touches a boundary
7
+ listed under `Required Detailed Policies` in `AGENTS.md`. These rules are not
8
+ optional guidance and must not be weakened to make a task easier.
9
+
10
+ ## Repository Map
11
+
12
+ Target repository structure:
13
+
14
+ - `src/core/`: action-neutral intent, plan, review check, and result primitives.
15
+ - `src/core/evidence/`: natural-language intent evidence helpers and
16
+ evidence-boundary primitives.
17
+ - `src/adapters/`: protocol-specific adapter implementations. Shared review,
18
+ material, ownership, simulation, acceptance, and handoff contracts should stay
19
+ protocol-agnostic unless a concrete implementation proves otherwise. DeepBook
20
+ is the current signable swap adapter implementation; additional
21
+ protocol support must be added through adapter contracts rather than a
22
+ custom-only product path.
23
+ - `src/mcp/`: MCP server and tool definitions.
24
+ - `src/review-server/`: local review HTTP server and session APIs.
25
+ - `review-app/`: the Settings page and shared display helpers/styles.
26
+ - `src/mcp-ui/`: internal Account, Receipt, Chart, Connect and Review cards, their
27
+ common lifecycle and view code.
28
+ - `src/runtime/shared/`: authenticated server ownership and MCP forwarding.
29
+ - `registry/`: local policy, allowlists, aliases, and generated mainnet metadata.
30
+ - `protocols/`: AI-readable protocol notes.
31
+ - `scripts/`: utility scripts for state inspection, registry generation, and
32
+ reports.
33
+ - `docs/UTILITY_INDEX.md`: index of reusable utility scripts.
34
+ - `.WORK/`: local planning notes; ignored by Git.
35
+
36
+ Inspect the actual repository before assuming any path exists. If the
37
+ repository differs from this map, the repository is the current fact and this
38
+ section should be updated when the difference is intentional.
39
+
40
+ ## Communication Rules
41
+
42
+ - Answer with verified facts and concise conclusions.
43
+ - Do not waste tokens on excuses, filler, or unsupported speculation.
44
+ - Concise means selective, not truncated. Do not abbreviate content, terms, task
45
+ names, or status wording in documents, reports, or discussion when the
46
+ abbreviation can change, narrow, or obscure the meaning.
47
+ - State uncertainty plainly when evidence is incomplete.
48
+ - Separate facts, assumptions, and recommendations.
49
+ - When work is missing, incomplete, removed, weakened, or previously overstated,
50
+ state that concrete fact directly. Do not relabel it as alignment, cleanup,
51
+ simplification, consolidation, follow-up, or a harmless tradeoff when the
52
+ verified fact is that required behavior was not implemented or was narrowed.
53
+ - Use status labels and progress reports only when they name the actual state.
54
+ `blocked` must identify the blocking condition, `unverified` must identify the
55
+ missing verification, and a progress report must name completed subtasks and
56
+ remaining requirements. Do not use `partially complete` as a success state.
57
+ These labels and reports must not soften a defect, downplay a missed
58
+ requirement, or support a completion claim when completion criteria are unmet.
59
+ - A scoped unit of work has no partial-success state. Progress can be reported by
60
+ naming completed subtasks, but that progress is not task success. The unit
61
+ succeeds only when every required behavior is implemented, every required
62
+ cleanup is done, and every verification point passes. Otherwise report the
63
+ unit as not complete and name the concrete blocker, missing requirement,
64
+ failed check, or unverified requirement.
65
+ - Do not hide a defect to preserve momentum or protect prior work. If a previous
66
+ answer, plan, review, or commit claimed completion incorrectly, correct the
67
+ record explicitly.
68
+
69
+ ## Documentation Review
70
+
71
+ When editing `AGENTS.md`, `README.md`, files under `docs/`, files under
72
+ `protocols/`, or runtime-facing instruction and limitation text such as
73
+ `src/mcp/serverInfo.ts`, do a first-reader pass before calling the work complete.
74
+
75
+ Read the changed document as if you are a new agent or human with no prior
76
+ conversation context. Verify that it communicates:
77
+
78
+ - the product purpose or user problem the document supports;
79
+ - what is implemented, planned, unsupported, or intentionally out of scope;
80
+ - the authority and boundary of every tool, workflow, protocol term, number,
81
+ policy, or product claim it mentions;
82
+ - what the reader should do, and what they must not infer.
83
+
84
+ Separate current implementation, planned future capability, current-release not-yet-implemented behavior, and permanent no-goal statements. Do not place all four
85
+ categories under wording such as "not yet possible" or "planned boundary" when
86
+ that wording could make a permanent no-goal sound like a roadmap item, or make a
87
+ planned future capability sound permanently unsupported.
88
+
89
+ Public and runtime-facing documents must describe current product behavior,
90
+ current tool contracts, and current unsupported boundaries only. Do not include
91
+ implementation history, prior states, migration history, decision history,
92
+ planning rationale, or "why we changed this" notes in README, `docs/`,
93
+ `protocols/`, runtime instructions, MCP resources, tool descriptions, or
94
+ user-facing strings. Keep that history in ignored `.WORK` notes.
95
+
96
+ Two approved exceptions have a limited delivery purpose. README may carry a
97
+ factual package/repository transition notice tied to installation, distinguishing
98
+ planned destinations from completed publication. Reviewed English development
99
+ records may live under `submission/ethglobal-tokyo-2026/`, with translations and
100
+ retrospective summaries labelled as such. That directory is not product guidance,
101
+ is never registered as an MCP resource, and is excluded from npm packages. These
102
+ exceptions do not permit development history in other product/runtime documents
103
+ or change `.WORK`'s role as ignored working material.
104
+
105
+ If the intended meaning depends on prior chat, hidden context, vague shorthand,
106
+ or local assumptions, rewrite it.
107
+
108
+ Remove wording that is ambiguous, overly broad, contradictory, likely to make a
109
+ reader overclaim product support, skip required verification, or optimize for
110
+ size instead of quality.
111
+
112
+ Write and review documents so a third-party reader with no Sui MCP
113
+ background can understand and use the content without guessing.
114
+
115
+ Use ordinary industry terms when they exist. Do not introduce project-specific
116
+ terms, internal shorthand, or product labels when a plain description can say
117
+ the same thing. If such a term is unavoidable because it is an existing API
118
+ field, type name, command, or documented product surface, define it in plain
119
+ language at first use and state exactly what it does and does not mean.
120
+
121
+ Do not use words whose meaning can change based on when the reader sees them,
122
+ which previous conversation they remember, or which nearby paragraph they
123
+ connect them to. Replace context-dependent wording with explicit source, time,
124
+ state, actor, tool, field, and unsupported-use statements.
125
+
126
+ Do not rely on phrases that invite the reader or an AI client to fill gaps with
127
+ imagination, such as unexplained "policy", "boundary", "gate", "support",
128
+ "coverage", "readiness", "evidence", or "review" wording. Either replace the
129
+ phrase with a concrete description or define the exact source, allowed use, and
130
+ unsupported use.
131
+
132
+ For MCP-facing documentation and runtime guidance, assume the connected AI
133
+ client may follow wording literally. Prefer concrete tool names, response
134
+ fields, and allowed conclusions over abstract warnings. If the document says an
135
+ AI must not use a value for a conclusion, also identify the field that should be
136
+ used instead.
137
+
138
+ ## Documentation Ownership
139
+
140
+ Use this single responsibility schema when editing documentation:
141
+
142
+ | Document | Owns | Must not own or claim |
143
+ | --- | --- | --- |
144
+ | `README.md` | Public first-entry document for product purpose, current release boundary, setup path, and documentation map. | Detailed tool contracts, user-question workflows, internal planning history, or release-review matrices. |
145
+ | `AGENTS.md` | Root development contract and non-negotiable product boundaries for coding agents working in this repository. | User setup instructions, feature catalogs, runtime-only AI-client answer behavior, or long-form policy details. |
146
+ | `docs/AGENT_DEVELOPMENT_POLICY.md` | Detailed binding development, review, documentation, source-of-truth, and completion policies for coding agents. | User setup instructions, MCP API contracts, user-question playbooks, or runtime-only AI-client answer behavior. |
147
+ | `docs/MCP_SETUP.md` | Installation, MCP client connection, first-use flow, local settings, and troubleshooting. | Long API behavior rules, field contracts, response wording rules, or user-question playbooks. |
148
+ | `docs/MCP_TOOLS.md` | MCP API reference for tool contracts, response fields, statuses, follow-up fields, and output boundaries. | Installation procedures or user-question playbooks. |
149
+ | `docs/AGENT_BEHAVIOR.md` | Answer playbook for user-question flows, tool selection, and response wording. | Tool schemas, field contracts, response-field definitions, or install procedures. |
150
+ | `docs/WALLET_CONNECTION.md` | Approved wallet connections, active-account read context, private SDK persistence and the distinction between connection and per-transaction approval. | Login, authentication, custody, authority to approve a transaction, full review/API contracts or setup ownership. |
151
+ | `docs/TRANSACTION_ACTIVITY_LOG.md` | Local transaction activity storage, scan, and summary boundaries. | Complete wallet history, P&L, route recommendations, transaction-building input, signing data, or signing readiness. |
152
+ | `docs/UTILITY_INDEX.md` | Manual utility and source-checkout script boundaries, including the distinction between utilities, MCP tools, and packaged product commands. | Promotion of utility scripts as MCP tools, review-time simulation, packaged product commands, transaction builders, signing-readiness signals, or wallet authorization evidence. |
153
+ | `docs/LOCAL_DB_ARCHITECTURE.md`, `docs/SDK_API.md`, and other architecture or evidence notes | Specific implementation boundaries, pinned source facts, storage facts, and source-verification notes. | Future support presented as current product functionality. |
154
+ | `docs/FRONTEND_POLICY.md` | Review-app frontend implementation policy and local UI boundary rules for coding agents. | Backend API contracts, MCP tool contracts, or user setup flow ownership. |
155
+ | `docs/golden-scenarios/*.md` | Release-review scenario matrices, golden answer shapes, allowed conclusions, and forbidden conclusions. | MCP API contracts or replacement definitions for response fields. |
156
+ | `protocols/*.md` | Protocol references and promotion-gate research notes only. | Runtime registries, supported-protocol lists, live liquidity sources, route recommendations, signing-readiness signals, or support declarations. |
157
+ | `submission/ethglobal-tokyo-2026/` | Reviewed English development records for the approved external delivery. | Product rules, runtime guidance, MCP resources, or npm package contents. |
158
+ | `.WORK/` | Ignored local planning notes. | Product-facing rules unless moved into README, AGENTS, docs, protocols, tests, or code comments. |
159
+
160
+ Do not remove all repetition. These repeated boundaries are allowed when they
161
+ protect readers on separate surfaces:
162
+
163
+ - the top-level boundary against autonomous execution, private-key signing or
164
+ custody, venue ranking, route choice, silent settlement-token selection, fiat
165
+ cash-out, P&L and signing-readiness claims; user-approved wallet signing and
166
+ independently verified backend submission are distinct supported operations;
167
+ - the core answer path that `read.preview_intent_evidence.responseSummary` and
168
+ response-local `userAnswerUse.answerFields` identify fields for
169
+ USD-denominated coverage, balance-total, and shortfall answers;
170
+ - the safety rule that separate DeepBook quote outputs are price estimates and
171
+ must not be combined into payment coverage or shortfall conclusions.
172
+
173
+ Do remove or rewrite duplication when it creates conflicting authority:
174
+
175
+ - The API reference and answer playbook must not define the same tool contract
176
+ in different words. Tool contracts belong in the API reference; question flows
177
+ belong in the answer playbook.
178
+ - API field meanings must not be reinterpreted in prose. If a document says a
179
+ field cannot support a conclusion, it must name the response field that should
180
+ be used instead when one exists.
181
+ - Protocol Markdown must not read as a runtime registry, supported-protocol
182
+ list, live liquidity source, route recommendation source, or signing-readiness
183
+ signal.
184
+ - Setup documentation must not copy long API behavior rules. It should link to
185
+ the API reference and answer playbook after the first-use setup flow.
186
+
187
+ ## Instruction Surface Ownership
188
+
189
+ Keep development-time rules separate from MCP-injected agent guidance.
190
+
191
+ Development rule surfaces are for contributors and coding agents changing the
192
+ repository.
193
+
194
+ They include `AGENTS.md`, `docs/AGENT_DEVELOPMENT_POLICY.md`, implementation
195
+ notes under `docs/`, release-review matrices, protocol research notes, tests,
196
+ and ignored `.WORK/` planning notes.
197
+
198
+ They may define product invariants, implementation discipline, review criteria,
199
+ and release gates. Clients do not reliably read them at runtime.
200
+
201
+ MCP-injected or runtime-facing agent surfaces are what connected AI clients can
202
+ actually discover through the server.
203
+
204
+ They include:
205
+
206
+ - `SERVER_INSTRUCTIONS` in `src/mcp/serverInfo.ts`;
207
+ - MCP prompts in `src/mcp/prompts.ts`;
208
+ - tool schemas and descriptions;
209
+ - MCP resources registered from `src/mcp/resources.ts`.
210
+
211
+ Runtime-facing resources currently include:
212
+
213
+ - `README.md`;
214
+ - `docs/MCP_SETUP.md`;
215
+ - `docs/MCP_TOOLS.md`;
216
+ - `docs/WALLET_CONNECTION.md`;
217
+ - `docs/AGENT_BEHAVIOR.md`;
218
+ - `protocols/deepbook-v3.md`;
219
+ - `protocols/deepbook-margin.md`.
220
+
221
+ When a behavior must influence AI client answers, put the actionable guidance in
222
+ a runtime-facing surface and guard it with tests.
223
+
224
+ `AGENTS.md` and this detailed policy may require that such a runtime-facing rule
225
+ exists. They must not be the only places where an AI client is expected to learn
226
+ user-answer behavior.
227
+
228
+ Keep tool descriptions concise, literal, and instruction-free. Use server
229
+ instructions, resources, prompts, schemas, output fields, and tests for behavior
230
+ guidance.
231
+
232
+ ## Evidence Standard
233
+
234
+ Do not work from imagination or unchecked assumptions.
235
+
236
+ Before applying an external suggestion or plan:
237
+
238
+ - investigate the claim;
239
+ - check the current codebase, official docs, source code, or direct command
240
+ output;
241
+ - separate verified facts from assumptions;
242
+ - explain the evidence behind the recommendation;
243
+ - do not apply the suggestion blindly.
244
+
245
+ For Sui, DeepBook, MCP, wallet behavior, transaction building, SDK behavior, and
246
+ dependency behavior, prefer official documentation, source code, and local
247
+ inspection over memory.
248
+
249
+ When official docs and the pinned installed SDK disagree, implementation must
250
+ follow the pinned SDK/source actually used by this repository. Document the
251
+ discrepancy.
252
+
253
+ ## Planning And Scope
254
+
255
+ For non-trivial or boundary-changing work, compare alternatives before choosing
256
+ a direction.
257
+
258
+ Before implementation, identify:
259
+
260
+ - what prerequisite work should already exist;
261
+ - what must be inspected first;
262
+ - what alternative development directions are available;
263
+ - why the chosen direction is better for the current goal;
264
+ - what risks or scope traps should be avoided.
265
+
266
+ Plans must be grounded in confirmed objective facts. Distinguish current
267
+ implemented work from unimplemented expansion, and do not make unimplemented
268
+ possibilities look like supported functionality.
269
+
270
+ Before answering a status, planning, review-readiness, commit-readiness, or
271
+ next-task question, verify the same-turn disk facts that the answer depends on.
272
+ At minimum, inspect tracked status, unstaged/staged diff summary, changed file
273
+ names, untracked files, and the active roadmap or work note that owns the
274
+ canonical task name. Do not reuse a clean/dirty/tree-status statement from a
275
+ prior turn. If disk facts changed after a plan was written, treat the plan as
276
+ stale until reconciled.
277
+
278
+ For each specification-baseline requirement, identify the implementation surface
279
+ and verification point before claiming the plan is executable. During
280
+ implementation and final review, classify each baseline requirement as
281
+ implemented, missing, weakened, or unverified.
282
+
283
+ Do not silently drop, merge, rename, or weaken a baseline requirement because it
284
+ is inconvenient, cross-module, time-consuming, or already partly covered by docs
285
+ or tests.
286
+
287
+ Do not introduce generalized abstractions for aesthetics, symmetry, or future
288
+ possibilities before a concrete implementation proves that the verified boundary
289
+ needs them.
290
+
291
+ Do not use boundary control as an excuse to avoid necessary investigation. Do
292
+ not use broad investigation as an excuse to expand product authority, add
293
+ unrelated features, or delay a safe fix.
294
+
295
+ When a request points to a specific file, line, review comment, or symptom, do
296
+ not start by editing that spot. First inspect adjacent callers, callees,
297
+ schemas, docs, tests, user flows, failure modes, and shared invariants. If
298
+ inspection shows the pointed-at spot is the only affected boundary, state that
299
+ finding and keep the edit narrow.
300
+
301
+ ## Development Discipline
302
+
303
+ For every task:
304
+
305
+ 1. Inspect the current repository state first.
306
+ 2. Identify affected files, modules, interfaces, user flows, and docs.
307
+ 3. Check whether a source-of-truth implementation already exists before adding a
308
+ function, type, script, adapter, or registry entry.
309
+ 4. Reuse existing source-of-truth code when it exists. Do not create a parallel
310
+ helper with similar responsibility unless the existing source is demonstrably
311
+ wrong or too limited for the verified boundary.
312
+ 5. Add new code only when no suitable source exists or the existing source is
313
+ demonstrably insufficient.
314
+ 6. Do not duplicate existing logic, registries, or protocol metadata without a
315
+ clear reason.
316
+ 7. Make the quality-first complete change that satisfies the goal after the
317
+ affected boundary is understood.
318
+ 8. After the change, re-check every affected area.
319
+ 9. Run relevant checks, tests, builds, or manual verification when available.
320
+ 10. Fix errors or regressions caused by the change before calling the work
321
+ complete.
322
+
323
+ Function and program structure:
324
+
325
+ - Prefer simple, direct structure with locally understandable control flow and
326
+ only the moving parts justified by the verified boundary.
327
+ - Use existing source-of-truth modules and established infrastructure when they
328
+ already own the boundary.
329
+ - Add a helper or abstraction only when it names a real shared concept,
330
+ preserves an invariant, or removes meaningful repetition.
331
+ - Avoid premature class hierarchies, generic frameworks, new registries, plugin
332
+ layers, event buses, background schedulers, callback/subscription systems, or
333
+ other coordination machinery unless the current verified requirement needs
334
+ them, including failure paths, lifecycle cleanup, and observability.
335
+ - Simple never means hardcoded, temporary, case-specific, or test-only code.
336
+
337
+ ## Review Discipline
338
+
339
+ The goal of review is defect discovery, not praise or consensus. Do not defend
340
+ an implementation; verify whether code, docs, tests, and product boundaries
341
+ actually agree.
342
+
343
+ - Report findings only, in priority order.
344
+ - Each finding cites a file and line as evidence.
345
+ - Mark speculation as speculation when the claim is not directly confirmed by
346
+ code, tests, or pinned SDK source.
347
+ - Do not defer with "can be done later." If a defect can be fixed safely now
348
+ within the current affected boundary, classify it as fix-now.
349
+ - Do not rely on existing tests passing as proof of correctness.
350
+ - When a defect is found, expand the search to callers, callees, and adjacent
351
+ boundaries. Trace upstream until the shared rule, type, or invariant the
352
+ defect violates is identified.
353
+
354
+ ### Reduction Detection
355
+
356
+ When a change is framed as refactor, cleanup, alignment, simplification, or
357
+ documentation synchronization, check whether supported behavior, tool authority,
358
+ or a user-facing claim became smaller.
359
+
360
+ Inspect git history when tool names, response fields, status values, runtime
361
+ guidance, public docs, tests, golden scenarios, or supported-claim lists are
362
+ removed, renamed, or narrowed.
363
+
364
+ If history shows prior behavior, classify the current work as restoration,
365
+ replacement, or intentional removal before reviewing it as new functionality. Do
366
+ not accept "new feature" framing until the prior behavior has been accounted
367
+ for. If a removal is intentional, cite the user decision, issue, commit, or
368
+ source evidence that changed the requirement.
369
+
370
+ A passing test is not proof that the tested behavior is intended. For tests that
371
+ prevent unsafe or unsupported behavior, read the test body and state what it
372
+ prevents from returning before treating it as stale or necessary.
373
+
374
+ Documentation and tests can narrow together, so agreement between them is not
375
+ enough. Compare code, tests, docs, runtime outputs, and history across the same
376
+ boundary.
377
+
378
+ For `userAnswerUse` and golden-document tests, verify semantic polarity instead
379
+ of string presence alone. A test that reads a document fixture must distinguish
380
+ allowed-answer text from forbidden, diagnostic, or exclusion text, and it must
381
+ fail when required section markers are missing.
382
+
383
+ When findings reveal structural problems, describe how the feature would be
384
+ designed from scratch with no legacy constraints. Start from type dependencies
385
+ and explicit separation of boundaries and responsibilities.
386
+
387
+ ## Implementation Integrity
388
+
389
+ - Do not hardcode values to bypass real validation, live integration, registry
390
+ policy, or mainnet checks.
391
+ - Do not add temporary branches solely to satisfy one failing case.
392
+ - Do not manipulate tests, fixtures, generated files, snapshots, package
393
+ metadata, or source files just to make checks pass.
394
+ - Test doubles, fixtures, placeholders, and config constants are allowed only
395
+ when their scope is explicit and they are not presented as product
396
+ functionality.
397
+ - Do not fake liquidity, quotes, transactions, wallet state, package IDs, or
398
+ mainnet support.
399
+ - If technical debt remains, name it explicitly and explain why it is not being
400
+ removed now.
401
+ - Prefer removing avoidable debt in the same change when it is safe and within
402
+ the affected boundary.
403
+
404
+ ## Numeric, Financial, And Protocol Honesty
405
+
406
+ Numeric and unit safety:
407
+
408
+ - Treat raw token amounts, display amounts, decimals, slippage, bps, quote
409
+ quantities, min-out values, gas, and balance deltas as safety-critical data.
410
+ - Do not infer token decimals from token symbols, memory, UI convention, or
411
+ common ecosystem defaults. Use a verified source of truth such as pinned SDK
412
+ metadata or verified mainnet onchain metadata.
413
+ - Keep raw amounts as integer strings or `BigInt` values. Do not use floating
414
+ point `number` arithmetic for token balances or signable quantities.
415
+ - Keep display amounts presentation-only and label them as display data. Do not
416
+ feed display strings back into signing, quoting, or review-time simulation
417
+ without an explicit raw conversion step.
418
+ - Formatting may strip trailing fractional zeros for readability, but it must
419
+ not use exponent notation or silently round away raw precision.
420
+
421
+ Financial and protocol honesty:
422
+
423
+ - Treat every balance, quote, fee, rebate, stake, locked amount, price, route
424
+ quantity, and derived value as financial information. It must have a clear
425
+ source, unit, precision boundary, and product meaning.
426
+ - Derived numbers must be honest about how they were produced. Do not hide
427
+ rounding, precision loss, simulation assumptions, registry lookups,
428
+ display-only conversion, cache age, or unavailable raw amounts.
429
+ - Separate raw integers, display amounts, simulated values, indicative quotes,
430
+ cached registry metadata, and live onchain state in types, docs, and
431
+ user-facing explanations.
432
+ - Use protocol terms as the protocol defines them. For DeepBook and future DeFi
433
+ integrations, prefer the pinned SDK source, official protocol documentation,
434
+ verified smart contract source, or mainnet onchain evidence over invented
435
+ wording.
436
+ - Do not rename, reinterpret, or simplify protocol concepts in a way that
437
+ changes their meaning.
438
+ - If a protocol, SDK, or contract source does not define a term, quantity,
439
+ status, or behavior clearly enough, mark it as unsupported, unavailable, or
440
+ requiring verification. Do not fill the gap with imagination or confident
441
+ prose.
442
+
443
+ ## Stateful/API Change Protocol
444
+
445
+ For session, review, signing, MCP tool, HTTP endpoint, wallet, adapter, or other
446
+ stateful/API changes, do not start from the patch. Use this order:
447
+
448
+ 1. Define the boundary being changed.
449
+ 2. Write or inspect the relevant state and input combination table.
450
+ 3. Decide the canonical source of truth.
451
+ 4. Check response consistency across HTTP, MCP, store, browser, wallet, adapter,
452
+ and docs as applicable.
453
+ 5. Add or update tests for failure combinations.
454
+ 6. Make the change.
455
+ 7. Search for the same pattern with `rg` and inspect adjacent paths.
456
+ 8. Run the relevant full verification before calling the work complete.
457
+
458
+ For non-trivial changes, record the matrix in `.WORK/` notes, the task report,
459
+ or tests. Do not rely on unstated intent.
460
+
461
+ Avoid case-driven exception stacking. When a bug appears as a specific case,
462
+ first ask which general boundary rule it violates. Fix the shared rule, mapper,
463
+ type, or invariant when possible instead of adding a case-specific branch for
464
+ that one case.
465
+
466
+ Required invariants:
467
+
468
+ - Store methods own state transitions. HTTP and MCP layers should map store
469
+ results and errors, not reimplement transition rules.
470
+ - Public status fields must be derived through shared mapping code. Do not
471
+ hand-map equivalent status concepts separately in HTTP and MCP.
472
+ - Idempotency checks must compare all identity fields needed for correctness,
473
+ such as `reviewSessionId`, `planId`, status, and `txDigest`.
474
+ - A successful state-changing response must reflect the state actually stored
475
+ after the operation.
476
+ - Do not leak session or domain details before token validation. After token
477
+ validation succeeds, lifecycle and domain errors should be specific unless a
478
+ different security decision is documented in code or tests.
479
+
480
+ Failure combinations are boundary-specific. For session/review work, include
481
+ wrong token, missing session, wrong `planId`, expired session, finalized session,
482
+ duplicate request, conflicting duplicate request, and mismatched action data. For
483
+ other boundaries, define the equivalent negative combinations before editing.
484
+
485
+ ## Product Rules
486
+
487
+ - Treat AI reasoning and transaction authorization as separate concerns.
488
+ - Treat natural-language intent evidence and transaction construction as
489
+ separate concerns.
490
+ - Do not pass executable transaction bytes from the MCP layer as trusted signing
491
+ material.
492
+ - The review layer must regenerate and verify signable actions before wallet
493
+ signing.
494
+ - The review layer exists to explain execution before authorization, not to
495
+ guarantee safety.
496
+ - Review checks must use deterministic checks, not opaque AI risk scores.
497
+ - Use `Ready for your review`, `Review needs updating`, and `Review blocked` for review
498
+ display states. These labels describe review information, not permission to
499
+ request wallet approval or a guarantee of execution. Keep public state enums
500
+ unchanged when editing display labels. Avoid language that implies absolute safety.
501
+ - Keep unsupported actions clearly unsupported. Do not add unimplemented intent
502
+ types in code.
503
+ - Prefer read-only utilities before write actions when adding protocol coverage.
504
+ - Intent evidence reports are useful product outputs by themselves. Do not treat
505
+ transaction creation or signing as required for a feature to have value.
506
+ - Do not ask users to speak in contract, function, coin type, or raw amount
507
+ terms when a supported natural-language settlement asset group can be resolved
508
+ from pinned SDK registry evidence.
509
+ - Do not silently choose USDC, USDT, or another settlement token for a
510
+ USD-denominated user intent. Expose the supported settlement asset group
511
+ evidence and required user choices.
512
+ - USD-denominated evidence checks require a runtime-facing preflight contract.
513
+ AI-client guidance exposed through MCP instructions, resources, prompts, and
514
+ tests must require `read.get_server_status` before USD-denominated coverage,
515
+ balance-total, or shortfall answers.
516
+ - Ordinary MCP tools are evidence and card gateways. They may create review
517
+ sessions and return internal cards, but model calls must not authorize
518
+ signing or execution. Scoped app-only actions admit an exact user selection;
519
+ the backend performs wallet I/O and verifies each resulting signature.
520
+ - The local settings control panel is a review-server frontend mutator. MCP may
521
+ create a settings session URL and read current settings, but settings
522
+ mutations must happen through the local settings page after Host/Origin checks
523
+ and settings-token validation.
524
+
525
+ ## Network Policy
526
+
527
+ Product specs, public docs, UX copy, product-facing AI/tool responses,
528
+ registries, and signable actions are mainnet-only.
529
+
530
+ Allowed as product functionality:
531
+
532
+ - mainnet packages;
533
+ - mainnet token types;
534
+ - mainnet pools or markets;
535
+ - mainnet execution data.
536
+
537
+ Not allowed as product functionality:
538
+
539
+ - testnet-only actions;
540
+ - planned-mainnet actions;
541
+ - faucet-only assets;
542
+ - fake liquidity;
543
+ - demo-only flows.
544
+
545
+ Internal experiments may use testnet, but they must not appear in product docs,
546
+ registries, UX copy, product-facing AI/tool responses, or supported-action
547
+ lists. Agents may discuss testnet or WIP surfaces only as unsupported internal
548
+ context or direct analysis, never as available product functionality.
549
+
550
+ Do not silently substitute mainnet assets, pools, package IDs, or protocol
551
+ objects. Resolved assets, pools, packages, and functions must be shown
552
+ explicitly in the review layer.
553
+
554
+ Mainnet guards must verify both declared network configuration and the actual
555
+ connected chain identifier. Do not rely on a string literal such as
556
+ `network: "mainnet"` alone.
557
+
558
+ ## Registry And Generated Files
559
+
560
+ - Markdown files are explanatory references for AI and humans.
561
+ - JSON registries are local policy, allowlists, aliases, and known metadata.
562
+ - Prefer official SDKs, official RPC endpoints, official deployment registries,
563
+ or direct mainnet onchain inspection for live state.
564
+ - Do not treat local JSON as live liquidity, live balances, live quotes, or
565
+ final execution truth.
566
+ - Generated registry files should include generation source, network, timestamp,
567
+ and generator script when practical.
568
+ - Do not hand-edit generated files unless they are explicitly marked as manual.
569
+ - If generated registry data changes, update related docs or state why no doc
570
+ change is needed.
571
+
572
+ ## SDK And CLI Source Of Truth
573
+
574
+ Code must use the pinned SDK and verified mainnet sources before introducing
575
+ local logic:
576
+
577
+ - DeepBook mainnet asset and pool metadata comes from `@mysten/deepbook-v3`
578
+ `mainnetCoins` and `mainnetPools`.
579
+ - Display-to-raw conversions use pinned Sui SDK utilities such as `parseToUnits`
580
+ and `parseToMist` when applicable.
581
+ - Wallet coin balances come from Sui SDK `client.core.listBalances`.
582
+ - DeepBook quote evidence comes from the pinned DeepBook SDK quote path or the
583
+ existing SDK-backed simulation adapter.
584
+ - Do not reimplement SDK registries, parsers, quote APIs, or protocol math under
585
+ local helper names when the pinned SDK already owns that source of truth.
586
+ - Sui CLI can be used only as read-only/debug verification evidence through
587
+ reviewed allowlisted utilities. It is not runtime authority,
588
+ transaction-building input, signing material, signing readiness, or wallet
589
+ authorization evidence.
590
+
591
+ ## Review State Model
592
+
593
+ Keep account-independent planning separate from account-bound review.
594
+
595
+ - `ActionPlan`: proposal created before wallet connection.
596
+ - `ReviewState`: wallet/account-bound verification result.
597
+ - Adapters that need original user intent captured for local activity analysis
598
+ should put the sanitized intent object at `ActionPlan.adapterData.requestedIntent`.
599
+ - Adapter data and review evidence must never include session tokens, token
600
+ hashes, URL fragment tokens, private keys, transaction bytes, signatures,
601
+ seeds, or mnemonics.
602
+ - Do not put wallet-specific checks such as balances, gas result, transaction
603
+ simulation result, or before/after balances into account-independent plans.
604
+ - Do not assume wallet balances, gas availability, or coin selection before
605
+ wallet connection.
606
+ - Recompute account-bound checks after wallet connection in the review layer.
607
+ - Use full transaction simulation for review-time effects, gas, object changes,
608
+ and balance changes.
609
+ - For Sui SDK v2 code, review-time simulation uses the public Sui gRPC
610
+ `transactionExecutionService.simulateTransaction` with `checks: ENABLED`
611
+ and `doGasSelection: true`. Send the stored transaction BCS and require
612
+ identical returned BCS and an effects digest matching the stored material.
613
+ Mock-gas simulation and rewritten transactions are not review evidence.
614
+ - Treat dev-inspection/debug simulation as separate from review-time transaction
615
+ simulation; do not present debug inspection as signing readiness.
616
+
617
+ ## Session Store Rule
618
+
619
+ For the current implementation, the MCP layer and review layer must share the
620
+ same authoritative session store.
621
+
622
+ The shared runtime uses SQLite as the authoritative source for card and live
623
+ session state. Store methods commit admission, revision changes and results;
624
+ MCP, HTTP and View consumers do not keep independent copies of that state.
625
+ In-memory fixtures may model external dependencies in tests, but do not prove
626
+ SQLite admission, rollback or restart guarantees. Frame recreation and chat
627
+ navigation are not state transitions.
628
+
629
+ Execution results belong to an exact `reviewSessionId` and `attemptId`. A
630
+ review explicitly references its current attempt, and earlier attempts remain
631
+ readable history. Do not use ambiguous global "latest result" semantics.
632
+
633
+ Card permissions are short-lived, scoped to the card and target, and carried
634
+ only in host UI metadata. Reads never create approval, pairing or a signature
635
+ request. Frame recreation is not an input transition. Its state read may
636
+ reconcile existing deadlines and wallet records without starting a new
637
+ operation. Only the backend owns admission, request deadlines and chain
638
+ observation. Settings page tokens remain in URL fragments and authenticated HTTP headers, never query strings or logs.
639
+
640
+ ## Utility Script Rule
641
+
642
+ - Utility scripts should expose concrete reusable state inspection or reporting
643
+ functionality.
644
+ - Keep utility scripts separate from the core review and signing flow.
645
+ - Avoid hidden side effects.
646
+ - Document inputs, outputs, and assumptions in `docs/UTILITY_INDEX.md`.
647
+ - Prefer read-only utility scripts unless a write action is explicitly required.
648
+ - Sui CLI based utilities must allowlist concrete read or debug commands, record
649
+ the observed `sui --version`, and reject arbitrary shell commands, arbitrary
650
+ Move calls, package calls, key handling, signing, execution, or config
651
+ mutation unless a separate reviewed plan explicitly owns that write boundary.
652
+ - Treat Sui CLI replay, trace, and gas-profile output as development/debug
653
+ evidence. Do not present it as review-time simulation, transaction-building
654
+ input, signing material, signing readiness, or wallet authorization evidence.
655
+
656
+ ## MCP Tool Safety
657
+
658
+ - Tool names, descriptions, and schemas must be concise, literal, and
659
+ instruction-free.
660
+ - Use MCP-compatible tool names. Prefer dot prefixes such as
661
+ `read.list_deepbook_pools` over slash names.
662
+ - Do not include hidden instructions, prompt-like text, policy text, or
663
+ model-behavior requests in tool descriptions.
664
+ - Do not expose arbitrary shell execution, arbitrary Move calls, arbitrary
665
+ package calls, or private-key handling.
666
+ - Prefer purpose-specific tools with explicit schemas over broad free-form
667
+ tools.
668
+ - Validate tool inputs and outputs at the MCP server boundary.
669
+ - Review whether tool authority expanded whenever a tool schema or description
670
+ changes.
671
+ - Settings tools are session-gateway tools. They may create a local settings
672
+ page session or read current settings. They must not mutate settings directly,
673
+ execute transactions, sign, create custody, or produce signing material.
674
+ - For stdio MCP servers, stdout is reserved for valid MCP JSON-RPC messages.
675
+ Send logs to stderr or a file. Do not use `console.log` in stdio server code.
676
+ - Successful MCP tool output should use `structuredContent` plus a text JSON
677
+ fallback when the SDK supports structured output. MCP error responses use
678
+ `isError: true` with a text JSON fallback because the pinned SDK skips
679
+ output-schema validation for error results.
680
+
681
+ ## MCP API Response Clarity
682
+
683
+ Design and review MCP API responses as standalone evidence.
684
+
685
+ Assume a connected AI client, coding agent, reviewer, or human operator may see
686
+ one tool response without reading the rest of the repository, prior chat, or
687
+ another tool response.
688
+
689
+ Every public MCP response shape should make these points clear from that
690
+ response alone:
691
+
692
+ - what question or operation this response can support;
693
+ - what source produced the facts, including network, SDK, transport, snapshot
694
+ time, and unit source when relevant;
695
+ - which returned fields may be used in a user-facing answer;
696
+ - which returned fields are diagnostic, price-only, display-only, or otherwise
697
+ not answer amounts;
698
+ - which claims are unsupported by this response;
699
+ - whether any required user choice is still missing;
700
+ - whether a follow-up tool is required, and exactly which tool and field should
701
+ be used.
702
+
703
+ Keep API responsibilities isolated.
704
+
705
+ A field in one tool response must not require hidden knowledge of another tool
706
+ to understand its own meaning.
707
+
708
+ Cross-tool references are allowed only as explicit follow-up guidance, for
709
+ example: this quote result is a price estimate only; for payment amount or
710
+ shortfall answers, call `read.preview_intent_evidence` and use
711
+ `responseSummary`.
712
+
713
+ Do not make a different API response necessary just to understand whether the
714
+ current response is safe to use for a conclusion. If a response cannot support a
715
+ conclusion, say that in the response itself with a plain field name and a plain
716
+ reason.
717
+
718
+ For API implementation work:
719
+
720
+ - inspect every status branch, success branch, error branch, and optional field
721
+ in the affected response;
722
+ - prefer a small response-local summary or use-guidance object over scattered
723
+ negative flags when the result is meant to guide AI answers;
724
+ - keep raw facts, display amounts, price estimates, wallet-balance amounts,
725
+ transaction facts, and execution/session state in separate fields;
726
+ - use ordinary field names such as `amountsUsedForAnswer`,
727
+ `separateQuoteOutputs`, `canUseForPaymentAnswer`, or
728
+ `requiredPaymentAnswerField` when those names describe the behavior directly;
729
+ - avoid field names whose meaning depends on product memory, such as unexplained
730
+ `contract`, `coverage`, `gate`, `readiness`, `evidence`, or `support` wording.
731
+
732
+ For API review work, block or fix the change when:
733
+
734
+ - the response can be misunderstood after being copied without surrounding
735
+ documentation;
736
+ - the response mixes price estimates, wallet balances, transaction facts, or
737
+ execution state into one conclusion without naming which fields are used;
738
+ - the response tells an AI client not to use a value but does not identify the
739
+ field that should be used instead;
740
+ - the response points to another tool without explaining what the current tool
741
+ result does and does not mean by itself;
742
+ - the response requires prior chat, hidden product vocabulary, or a separate
743
+ document to avoid an unsafe user-facing answer.
744
+
745
+ ## Review Server Safety
746
+
747
+ - Bind the local review server to `127.0.0.1`.
748
+ - Use a dynamic port unless a fixed port is explicitly required.
749
+ - Implement Host and Origin checks in the review server itself.
750
+ - Do not treat Host or Origin checks as authentication. Settings APIs must validate their session token; internal app actions
751
+ must validate their scoped UI permission and stored target/revision.
752
+ - Do not use MCP SDK host validation helpers as a substitute for review server
753
+ authentication.
754
+
755
+ ## Dependency Policy
756
+
757
+ - Pin Sui, DeepBook, MCP, and wallet-related dependencies to explicit versions
758
+ during active development.
759
+ - Commit the lockfile.
760
+ - Do not upgrade SDKs casually.
761
+ - When changing the published package or MCP server release version, update all
762
+ release metadata in the same change: `package.json`, root/package entries in
763
+ `package-lock.json`, and `server.json` top-level and package versions.
764
+ - Before completing a release-version change, search committed repository
765
+ surfaces excluding `node_modules/`, `dist/`, `.git/`, and `.WORK/` for the old
766
+ release version and classify any remaining matches as dependency versions,
767
+ fixture data, or stale release metadata.
768
+ - When changing an SDK or wallet-related dependency version, update pinned
769
+ version documentation such as `docs/SDK_API.md` when that dependency is listed
770
+ there.
771
+ - If an SDK is upgraded, re-run adapter, review, signing, and
772
+ registry-generation checks.
773
+
774
+ ## Completion Criteria
775
+
776
+ Work is complete only when:
777
+
778
+ - the requested change is implemented;
779
+ - the affected boundary still looks robust when reviewed again from product
780
+ purpose, code paths, user flows, tests, and documentation;
781
+ - affected code, docs, interfaces, and user flows have been reviewed after the
782
+ change;
783
+ - relevant checks, tests, builds, or manual verification have been run when
784
+ available;
785
+ - errors introduced by the change have been fixed;
786
+ - remaining limitations are explicitly documented;
787
+ - for non-trivial work, the final review compares the completed work against the
788
+ specification baseline;
789
+ - every baseline requirement is implemented and verified, or named directly as a
790
+ missing planned requirement;
791
+ - passing tests, reduced scope, or internal consistency of a smaller
792
+ implementation does not replace baseline comparison;
793
+ - final repository status is checked, including untracked files;
794
+ - unexpected files are classified or cleaned up before final response;
795
+ - if previous progress was overstated, the final response corrects the record.
796
+
797
+ ## Quality direction
798
+
799
+ Quality work continues along three areas; progress in all three matters, and
800
+ work that advances more than one at once is preferred over work that advances
801
+ only one in isolation:
802
+
803
+ - Intent, evidence, and answer quality: understand the request, route it to the
804
+ right tool (prompt surfaces, `userAnswerUse` response guidance), and answer
805
+ only from verified mainnet evidence, including saying plainly when a question
806
+ cannot be answered from the returned evidence.
807
+ - Protocol breadth: additional protocol adapters registered through the
808
+ descriptor contract; protocol names appear in public docs only after a
809
+ concrete support decision. When several protocols support an action, the bare
810
+ action prompt asks the user to choose instead of routing silently.
811
+ - Execution-trust foundation: what the user reviewed is exactly what gets
812
+ signed, under any wallet and any signing speed — the review-session state
813
+ machine, atomic per-review-revision admission, verified sign-only wallet
814
+ responses, bounded local waits with late-callback guards, scoped UI permission, runtime lifecycle
815
+ stability, and packaging and runtime operability.