@zktx.io/sui-mcp 0.6.0 → 0.6.1

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