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