@zktx.io/sui-mcp 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +6 -6
  2. package/dist/adapters/deepbook/deepbookTransactionMaterialProducer.js +3 -3
  3. package/dist/core/activity/localDataService.js +71 -52
  4. package/dist/core/activity/localDataValidation.js +1 -3
  5. package/dist/core/activity/sqliteActivityStore.js +24 -16
  6. package/dist/core/activity/sqliteActivityStoreSchema.js +83 -12
  7. package/dist/core/preferences/sqlitePreferencesRepository.js +5 -3
  8. package/dist/core/session/cardSession.js +1 -1
  9. package/dist/core/session/cardSessionStore.js +53 -3
  10. package/dist/core/session/sessionStore.js +0 -17
  11. package/dist/core/session/settingsFileIdentity.js +11 -0
  12. package/dist/core/session/settingsFileProtocol.js +25 -0
  13. package/dist/core/session/settingsFileStore.js +346 -0
  14. package/dist/core/session/settingsInputError.js +34 -0
  15. package/dist/core/session/settingsOperation.js +224 -0
  16. package/dist/core/session/settingsPreparationSql.js +15 -0
  17. package/dist/core/session/settingsWorkflow.js +1219 -0
  18. package/dist/core/session/sqliteSessionStore.js +0 -40
  19. package/dist/core/session/sqliteSettingsWorkflowStore.js +463 -0
  20. package/dist/core/session/sqliteWalletWorkflowStore.js +164 -41
  21. package/dist/core/session/status.js +2 -2
  22. package/dist/core/session/walletConnection.js +27 -8
  23. package/dist/core/session/walletWorkflow.js +73 -15
  24. package/dist/core/session/workflowState.js +16 -8
  25. package/dist/core/session/workflowView.js +18 -2
  26. package/dist/mcp/responseGuidance.js +10 -5
  27. package/dist/mcp/serverInfo.js +3 -4
  28. package/dist/mcp/toolNames.js +2 -2
  29. package/dist/mcp/tools/account/index.js +1 -19
  30. package/dist/mcp/tools/read/readToolHelpers.js +5 -4
  31. package/dist/mcp/tools/session/executionResultTools.js +2 -2
  32. package/dist/mcp/tools/session/shared.js +1 -0
  33. package/dist/mcp/tools/session/statusTools.js +4 -3
  34. package/dist/mcp/tools/settings/index.js +8 -28
  35. package/dist/mcp-app/account.html +14 -14
  36. package/dist/mcp-app/account.notices.txt +1 -1
  37. package/dist/mcp-app/chart.html +9 -9
  38. package/dist/mcp-app/chart.notices.txt +1 -1
  39. package/dist/mcp-app/connect.html +14 -14
  40. package/dist/mcp-app/connect.notices.txt +1 -1
  41. package/dist/mcp-app/receipt.html +1298 -1463
  42. package/dist/mcp-app/receipt.notices.txt +226 -1204
  43. package/dist/mcp-app/review.html +1298 -1463
  44. package/dist/mcp-app/review.notices.txt +226 -1204
  45. package/dist/mcp-app/settings.html +3133 -0
  46. package/dist/mcp-app/settings.notices.txt +973 -0
  47. package/dist/mcp-ui/contracts.js +8 -2
  48. package/dist/mcp-ui/readCards.js +1 -1
  49. package/dist/mcp-ui/tools.js +33 -2
  50. package/dist/review-server/server.js +5 -51
  51. package/dist/runtime/application.js +41 -14
  52. package/dist/runtime/localSettingsService.js +26 -2
  53. package/dist/runtime/shared/authenticatedFetch.js +6 -2
  54. package/dist/runtime/shared/control.js +5 -6
  55. package/dist/runtime/shared/http.js +14 -0
  56. package/dist/runtime/shared/mcpHttp.js +9 -4
  57. package/dist/runtime/shared/server.js +1 -1
  58. package/dist/runtime/smokeMainnetRead.js +0 -1
  59. package/dist/runtime/walletConnectStorage.js +2 -4
  60. package/dist/runtime/walletSdkChildRuntime.js +2 -1
  61. package/dist/runtime/walletSdkIpc.js +2 -1
  62. package/dist/runtime/walletSdkProcess.js +3 -2
  63. package/docs/AGENT_BEHAVIOR.md +44 -10
  64. package/docs/AGENT_DEVELOPMENT_POLICY.md +16 -12
  65. package/docs/FRONTEND_POLICY.md +105 -28
  66. package/docs/LOCAL_DB_ARCHITECTURE.md +143 -20
  67. package/docs/MCP_SETUP.md +99 -39
  68. package/docs/MCP_TOOLS.md +273 -24
  69. package/docs/SDK_API.md +51 -10
  70. package/docs/UTILITY_INDEX.md +9 -6
  71. package/docs/WALLET_CONNECTION.md +30 -9
  72. package/package.json +13 -7
  73. package/dist/core/activity/schemaVersion.js +0 -2
  74. package/dist/core/session/keyedRecordStore.js +0 -18
  75. package/dist/core/session/settingsSession.js +0 -1
  76. package/dist/core/session/settingsSessions.js +0 -45
  77. package/dist/review-app/brand-dark.svg +0 -1
  78. package/dist/review-app/brand-light.svg +0 -1
  79. package/dist/review-app/favicon.svg +0 -1
  80. package/dist/review-app/settings.css +0 -1
  81. package/dist/review-app/settings.js +0 -1
  82. package/dist/review-app/ui.css +0 -809
  83. package/dist/review-server/assets.js +0 -48
  84. package/dist/review-server/html.js +0 -45
  85. package/dist/review-server/http.js +0 -47
  86. package/dist/review-server/middleware/reviewToken.js +0 -7
  87. package/dist/review-server/settingsApi.js +0 -158
@@ -21,9 +21,10 @@ Target repository structure:
21
21
  protocol support must be added through adapter contracts rather than a
22
22
  custom-only product path.
23
23
  - `src/mcp/`: MCP server and tool definitions.
24
- - `src/review-server/`: local review HTTP server and session APIs.
25
- - `review-app/`: the Settings page and shared display helpers/styles.
26
- - `src/mcp-ui/`: internal Account, Receipt, Chart, Connect and Review cards, their
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
27
28
  common lifecycle and view code.
28
29
  - `src/runtime/shared/`: authenticated server ownership and MCP forwarding.
29
30
  - `registry/`: local policy, allowlists, aliases, and generated mainnet metadata.
@@ -517,10 +518,11 @@ other boundaries, define the equivalent negative combinations before editing.
517
518
  sessions and return internal cards, but model calls must not authorize
518
519
  signing or execution. Scoped app-only actions admit an exact user selection;
519
520
  the backend performs wallet I/O and verifies each resulting signature.
520
- - The local settings control panel is a review-server frontend mutator. MCP may
521
- create a settings session URL and read current settings, but settings
522
- mutations must happen through the local settings page after Host/Origin checks
523
- and settings-token validation.
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.
524
526
 
525
527
  ## Network Policy
526
528
 
@@ -635,7 +637,7 @@ only in host UI metadata. Reads never create approval, pairing or a signature
635
637
  request. Frame recreation is not an input transition. Its state read may
636
638
  reconcile existing deadlines and wallet records without starting a new
637
639
  operation. Only the backend owns admission, request deadlines and chain
638
- observation. Settings page tokens remain in URL fragments and authenticated HTTP headers, never query strings or logs.
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.
639
641
 
640
642
  ## Utility Script Rule
641
643
 
@@ -668,8 +670,8 @@ observation. Settings page tokens remain in URL fragments and authenticated HTTP
668
670
  - Validate tool inputs and outputs at the MCP server boundary.
669
671
  - Review whether tool authority expanded whenever a tool schema or description
670
672
  changes.
671
- - Settings tools are session-gateway tools. They may create a local settings
672
- page session or read current settings. They must not mutate settings directly,
673
+ - Settings tools are card gateways. They may create an internal Settings card
674
+ or read current settings. They must not mutate settings directly,
673
675
  execute transactions, sign, create custody, or produce signing material.
674
676
  - For stdio MCP servers, stdout is reserved for valid MCP JSON-RPC messages.
675
677
  Send logs to stderr or a file. Do not use `console.log` in stdio server code.
@@ -747,8 +749,10 @@ For API review work, block or fix the change when:
747
749
  - Bind the local review server to `127.0.0.1`.
748
750
  - Use a dynamic port unless a fixed port is explicitly required.
749
751
  - Implement Host and Origin checks in the review server itself.
750
- - Do not treat Host or Origin checks as authentication. Settings APIs must validate their session token; internal app actions
751
- must validate their scoped UI permission and stored target/revision.
752
+ - Do not 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.
752
756
  - Do not use MCP SDK host validation helpers as a substitute for review server
753
757
  authentication.
754
758
 
@@ -1,11 +1,19 @@
1
1
  # Frontend Policy
2
2
 
3
- Account, Receipt, Chart, Connect and Review use internal MCP Apps cards.
4
- Settings remains a local session-token page. Cards display backend-validated
3
+ Account, Receipt, Chart, Connect, Review and Settings use internal MCP Apps cards.
4
+ There is no external Settings page. Cards display backend-validated
5
5
  facts and forward explicit user selections through scoped app-only tools. They
6
6
  never hold transaction bytes/signatures or call a wallet, Sui RPC, Indexer or
7
7
  local HTTP endpoint directly. Direct NFT image loading is the display exception.
8
8
 
9
+ All six cards use the same product UI and interaction rules across desktop
10
+ Hosts. Equivalent validated data, authority, time, theme and viewport produce
11
+ the same information, labels, controls and recovery flow. Qualified transport
12
+ formats are normalized at the common integration boundary; Host names do not
13
+ select product features or grant authority. Native window chrome and file
14
+ pickers belong to the Host. Actual delivery remains a required integration
15
+ check; a common error screen does not establish working file delivery.
16
+
9
17
  ## Display and review facts
10
18
 
11
19
  Show what is happening, the relevant asset flow, whether an action is available,
@@ -307,20 +315,95 @@ same View and opened Details during unchanged state reads; disposed callbacks
307
315
  cannot alter its replacement. Normal display changes do not postpone required
308
316
  backend state reads.
309
317
 
310
- For a stopped/unresponsive connection service, explain the actual operational
311
- path: fully quit all apps using Sui MCP, then reopen them. Closing a peer
312
- or window alone may not stop the shared owner. Do not promise that restart
313
- removes remote sessions or confirms an interrupted disconnect. Normal QR or
314
- initialization is not diagnosed as failure by a timer. An uncertain command
315
- first offers the same-request status check; the model cannot act for the user.
316
- Historical service-recovery cards retain their own recorded result and no new
317
- input. Their service outcome never implies connection approval, remote removal
318
- or a transaction outcome.
318
+ Connection-service recovery belongs to Settings/Troubleshooting and requires
319
+ explicit user preparation/confirmation of the affected SDK run and requests.
320
+ Connect/Review explain that path when recovery is relevant; they do not host
321
+ service-restart controls. Normal QR approval or initialization is not a failure
322
+ diagnosis. An uncertain command first offers its same-request status check.
323
+ If the parent/Settings is unavailable or a parent endpoint/installation change
324
+ must apply, explain full exit/reopen of all participating apps. Child restart
325
+ never implies remote disconnection, connection approval or chain outcome.
326
+
327
+ Settings separates ordinary Read address, Local records and Troubleshooting
328
+ from Advanced endpoint controls. Show operation impact and errors in the body;
329
+ technical values use the existing Details disclosure. Each card owns one
330
+ operation and its stored result. Preview, Back, chat navigation and state reads
331
+ do not apply settings, create another file or restart the SDK. A valid sealed
332
+ upload remains available for a new Preview after preparation invalidation;
333
+ explicit file change uses the backend selection action. Validation rejection
334
+ retains the actual current card and a usable correction/selection path.
335
+
336
+ Local records offers Download backup as one explicit action. Snapshot creation
337
+ and verification are internal progress, without a separate creation or
338
+ confirmation page. New downloads use one private temporary snapshot. A supported
339
+ download does not publish a permanent server backup. Other Settings choices do not appear on
340
+ its progress or result page. File delivery uses the standard Host-mediated
341
+ request, without hiding the action according to a Host name or download
342
+ advertisement. Missing card authority still prevents actions.
343
+
344
+ If that actual `ui/download-file` request returns method-not-found (-32601),
345
+ the same snapshot is saved once in the Sui MCP backup folder. The initial choice
346
+ explains this conditional destination. A verified local result shows Backup
347
+ saved with a readable, selectable Folder and File name. It offers no second
348
+ download action. Missing advertisement, cancellation, denial, invalid parameters,
349
+ timeouts and errors from other methods do not select this path. Application
350
+ names do not select either path.
351
+
352
+ An earlier possibly handled attempt requires Save a local copy before local
353
+ saving, with a warning that another copy may exist. A local save in progress
354
+ offers status observation, not another save, Host retry or cancellation. A
355
+ confirmed failure with no publication can offer Retry save within the original
356
+ period; an uncertain result offers only Check status. State, authority, expiry,
357
+ navigation and controls use the same current projection. Recorded saving and
358
+ temporary cleanup remain separate facts, including when cleanup fails.
359
+
360
+ Results distinguish snapshot preparation, Host-reported delivery, temporary
361
+ cleanup and actual user file storage. Suggested file name is not a confirmed
362
+ save location. Host acknowledgment ends server retention but is not proof of a
363
+ saved file; isError does not classify cancellation, denial or failure. Lost
364
+ responses are unconfirmed. An explicit retry uses the same verified snapshot
365
+ within its fixed transfer period and warns when a prior request may already
366
+ have been handled. Frame recreation and state reads never download again.
367
+ Cancel download ends further transfer and cleans the temporary snapshot; it
368
+ cannot close a Host dialog or delete a saved user file. A new frame needs an
369
+ explicit retry, and a server restart ends the old transfer. An already-admitted
370
+ local save may be settled by verifying its existing artifact after restart;
371
+ recovery never creates a missing backup or restores old input permission.
372
+
373
+ The backend owns a thirty-minute transfer period starting when the snapshot is
374
+ physically ready, separately from the original card-input deadline. Reads and
375
+ retries do not extend it. The View consumes relative remaining time without
376
+ extending a confirmed deadline. Permission, operation, file, attempt and current
377
+ state are checked before delivery. The elapsed time of the authenticated
378
+ pre-delivery read, including a coalesced read, reduces the remaining period; a
379
+ delayed reply cannot grant a fresh transfer period. A corrupt or unavailable snapshot sends no
380
+ bytes to the Host. A local save admitted before the deadline finishes its file work and result
381
+ settlement; the verified final backup is not subject to the private-file TTL.
382
+ Existing saved backup results retain their recorded facts;
383
+ their public files are not removed by temporary cleanup.
384
+
385
+ Incomplete cleanup offers Check status for the same operation. Cleanup includes
386
+ settlement of that operation's ended I/O reservation and waits for its actual
387
+ file reads/writes to end. A stored result remains readable while settlement is
388
+ retried; it does not release another operation's running I/O. Reading a recorded
389
+ Host report resolves a lost reply without sending the file again.
319
390
 
320
391
  Local-data counts describe the backend state at the time they are read. A later
321
392
  replacement warning must not use a stale count, especially zero, as an assurance
322
393
  that no unconfirmed transaction records will be deleted. Warn that replacement
323
394
  can remove those records and cannot cancel a transaction on Sui.
395
+ The private connection-service journal remains; Reset does not claim that the
396
+ SDK is empty or grant a new pairing. Connect controls use backend
397
+ `manageableConnectionIds`, separately from `usableConnectionId`. Unrecorded SDK
398
+ presence uses conditional Settings recovery guidance after registration ends,
399
+ without a synthetic target or global recovery controls in Connect.
400
+
401
+ Endpoint confirmations name Sui node (gRPC) or Activity data (GraphQL), show the
402
+ stored value before the change and the exact value to store. Their result labels
403
+ the effective value and source at save time. Explain an active environment
404
+ override in the body: restart alone will not apply the stored value while that
405
+ override remains. Do not substitute a current configuration read for the saved
406
+ result or copy default URLs into the View.
324
407
 
325
408
  ## Internal Read Cards
326
409
 
@@ -338,7 +421,7 @@ Receipt input values and their PTB graph use a typed UI-only metadata channel bo
338
421
 
339
422
  Internal cards provide no clipboard actions, copy buttons, or clipboard fallback controls. Preserve readable facts and ordinary text selection; where a PTB graph is shown, preserve its name/address controls and pan/zoom. NFT images retain no-referrer behavior and a failed-image placeholder. Theme follows the host. Card view cleanup ends timers, subscriptions and rendering observers without cancelling an already admitted server operation.
340
423
 
341
- All five cards, including Review management, adapt to the embedded frame width.
424
+ All six cards, including Review management, adapt to the embedded frame width.
342
425
  Forms wrap, narrow fact rows stack their label above the value, and long addresses,
343
426
  amounts, names and records remain readable without widening the document. QR,
344
427
  chart and PTB drawing areas stay within the card; resizing changes presentation
@@ -446,9 +529,9 @@ Frontend labels stay in English. Localization must preserve protocol names, toke
446
529
 
447
530
  ## Shared UI And Design Principles
448
531
 
449
- The card views and remaining Settings page share one design-token set and one set of atomic UI
532
+ The card views share one design-token set and one set of atomic UI
450
533
  components: vanilla TypeScript DOM helpers in `review-app/src/ui` plus the shared
451
- stylesheet `review-app/public/ui.css`, served at `/review-assets/ui.css`. There is
534
+ stylesheet `review-app/public/ui.css`, bundled into each self-contained card HTML. There is
452
535
  no React, Vue, Svelte, or client router. Views compose the shared atoms and keep
453
536
  only their own layout, container, third-party-sizing, and composition CSS. The
454
537
  shared atoms are addressed by `ui-` prefixed classes that only the shared
@@ -462,7 +545,7 @@ The shared UI follows these durable principles:
462
545
  clearly-signaled async lock. Status and errors are conveyed as text, not color
463
546
  alone.
464
547
  2. One consistent system: cards share one lifecycle, one component set, and the
465
- same element positions. Cards and token pages have no cross-page navigation.
548
+ same element positions. Cards have no cross-page navigation.
466
549
  3. Cards show the current step and next permitted action without permanently
467
550
  listing every earlier step. A completed transaction leads with its observed
468
551
  result; stored request state is not a second outcome. Settings preview and
@@ -479,28 +562,22 @@ The shared UI follows these durable principles:
479
562
  enough detail to diagnose afterward.
480
563
  7. Restraint: each page shows only the information it needs, with generous spacing.
481
564
  8. Information depth by importance: each page ranks its information and renders the
482
- user task first and most prominent. Internal cards are one document: plain sections, rows and whitespace replace nested cards. Supplementary facts use one closed Details slide with plain sections inside, never nested disclosures. Do not repeat summary values or status in another panel. Review and Receipt place the correct transaction graph above their concise decision/result. Important errors and costs remain visible. Settings retains its page layout.
483
-
484
- Theme: cards follow the host; the remaining Settings page has a theme toggle. A shared theme helper stores
485
- only the theme value (`light` or `dark`) under one fixed storage key; it never
486
- reads or writes a token, session id, wallet account, or any other state. The
487
- theme is the `data-theme` attribute on the document root and is applied through
488
- CSS variables with no inline styles, so it works under the strictest page CSP.
565
+ user task first and most prominent. Internal cards are one document: plain sections, rows and whitespace replace nested cards. Supplementary facts use one closed Details slide with plain sections inside, never nested disclosures. Do not repeat summary values or status in another panel. Review and Receipt place the correct transaction graph above their concise decision/result. Important errors and costs remain visible. Settings uses the same plain sections/rows and one Details disclosure.
489
566
 
490
- Icons are SVG files or inline SVG, never an icon font or a CDN. The favicon
491
- (`favicon.svg`) and the theme-specific brand marks (`brand-light.svg`,
492
- `brand-dark.svg`) are served from `/review-assets/`; the header shows the brand
493
- mark for the active theme.
567
+ All cards follow Host light/dark theme through the document's `data-theme`
568
+ attribute and shared CSS tokens. They do not persist a separate theme choice.
569
+ Use inline SVG icons or bundled assets, never an icon font/CDN or retired
570
+ `/review-assets/` route.
494
571
 
495
572
  ## Navigation
496
573
 
497
- Read cards open from purpose-specific MCP tools. They contain their own result and error states and do not link to removed Account, Receipt, Chart, home or HTML not-found pages. Cards and the Settings page have no cross-page navigation or linked brand exit.
574
+ Read cards open from purpose-specific MCP tools. They contain their own result and error states and do not link to removed Account, Receipt, Chart, home or HTML not-found pages. Cards have no cross-page navigation or linked brand exit.
498
575
 
499
576
  ## Security
500
577
 
501
578
  Tokens must not be accepted in query strings. Wallet addresses must not be written to local event logs in plaintext. Private keys, signatures, transaction bytes, and arbitrary Move calls must not appear in frontend state.
502
579
 
503
- Cards bundle script/style locally with the declared Host CSP and no external execution chunks. The Settings page uses local assets and Host/Origin/session-token checks. App-only tools require scoped UI permission, target and revision checks.
580
+ Cards bundle script/style locally with the declared Host CSP and no external execution chunks. There is no external page/asset or HTTP mutation fallback. Shared private HTTP transport retains Host/Origin and transport authentication checks. App-only tools require scoped UI permission, target and revision checks.
504
581
 
505
582
  Wallet and review screens must be keyboard reachable and screen-reader labeled. Status and error changes must be exposed as text, not color alone.
506
583
 
@@ -10,7 +10,7 @@ The process that binds the configured loopback port initializes these local comp
10
10
 
11
11
  - a local SQLite store;
12
12
  - a mainnet guard for the configured Sui gRPC endpoint;
13
- - the local review HTTP server on `127.0.0.1`;
13
+ - the shared private HTTP transport on `127.0.0.1`;
14
14
  - authenticated internal MCP sessions, reached by each client through a stdio forwarder.
15
15
 
16
16
  The GraphQL endpoint is also mainnet-guarded when it is saved through settings, imported from a local-data backup, or first used by Sui activity tools.
@@ -33,7 +33,7 @@ User-requested bounded transaction scans can store normalized facts only when a
33
33
 
34
34
  The default Sui mainnet gRPC and GraphQL endpoints are stored in the local SQLite settings table on first run.
35
35
 
36
- To inspect settings or change local data, ask your AI client to create a Sui MCP local settings session and open the returned settings URL in the same machine's system browser.
36
+ To inspect settings or change local data, ask for the internal Settings card. Ordinary MCP creates an unsubmitted card or reads settings; scoped app-only preparation/confirmation owns changes. No external page or Settings HTTP API remains.
37
37
 
38
38
  Endpoint changes apply after the MCP server restarts.
39
39
 
@@ -105,7 +105,10 @@ The following live session tables hold runtime session state in the shared datab
105
105
  - `live_private_review_artifacts`: per-session private review evidence (the transaction-material handle, its digest commitment, and derived evidence), cascade-deleted with its review session.
106
106
  - `live_transaction_materials`: locally built unsigned transaction bytes stored as a BLOB behind a redacted handle, with a TTL; retained for the admitted request. Terminal request cleanup removes only material still owned by that revision, preserving newer preparation. Owner replacement deletes old private material while retaining immutable review and chain-result evidence.
107
107
  - `live_wallet_connections`: verified connection facts, private topic and callback state.
108
- - `live_settings_sessions`: short-lived Settings page authority.
108
+ - `live_read_cards`: public card state with private permission hash, scope, operation and CAS revision.
109
+ - `settings_operations`: one draft/upload/preparation/admission/result identity per Settings card, with owner/data epoch, user-data revision, fingerprint and SDK supersession/checkpoint facts. A download stores its typed snapshot lifetime and per-attempt delivery reports in private `preparation_json`, separately from the immutable result. Updating delivery never reserializes a terminal `result_json`.
110
+ - `settings_files`: private file identity, original operation, upload/export role, generated paths, lengths/hash, chunk reservation and seal/invalidation/cleanup state. `cleanup_operation_id` separately names the operation responsible for cleanup; replacement can transfer that responsibility without changing the file identity, public path or input eligibility.
111
+ - `settings_control`: current data epoch/user-data revision, one final-operation slot, one file-I/O reservation and the SDK input block owner. These are semantic state/authority facts, not release-version counters.
109
112
 
110
113
  These live tables are distinct from the append-only review evidence tables above: the evidence tables remain the durable activity/audit record, while the live tables hold the in-flight session state that the review server serves.
111
114
 
@@ -132,13 +135,92 @@ update triggers reject revision-unaware writers: inserts must use
132
135
  `revision = 0` and the current write-contract marker, and updates must increase
133
136
  the revision by exactly one and keep the current write-contract marker.
134
137
 
135
- Logical local data reset is the local settings page action that clears stored product state through the runtime without requiring manual database-file deletion. Replace-only import is the settings page import path that replaces local product state from a validated backup. When no unsettled financial request prevents replacement, both logical local data reset and replace-only import clear `coin_metadata_cache`, card records, live review/wallet/settings sessions, private review artifacts and transaction material in the same SQLite transaction. A rollback preserves the existing data and permissions. No separate HTTP cleanup call owns permission invalidation. Clearing active account context does not clear it because coin metadata is account-independent.
136
-
137
- Non-terminal review session expiry is recorded lazily when the session is read or mutated after its TTL. There is no background expiry worker.
138
+ Reset/import are explicitly confirmed Settings operations. They validate the
139
+ current backup shape and imported mainnet endpoints, check current prepared
140
+ impact and reject unsettled wallet/transaction work. One SQLite transaction
141
+ replaces user data, clears coin metadata and other live authorities, advances
142
+ data epoch and preserves the applying operation's read-only card/result. It
143
+ never recreates that result from a callback after deleting it. Rollback
144
+ preserves the prior data, permissions and admission state.
145
+ The private `live_wallet_connections` service journal remains because replacing
146
+ user data does not end SDK sessions. It cannot restore old card permissions or
147
+ transaction authority and is not imported from a backup. Reset clears the
148
+ default address; an imported default still needs its exact current connection
149
+ ID and approved address. Outstanding connection SDK callbacks also block replacement.
150
+
151
+ User-data and wallet/request writers invalidate affected preparations and
152
+ increment their card revision in the same transaction. The trigger and `settings_back`
153
+ reuse one SQL transition: a complete, sealed, non-invalidated upload belonging
154
+ to that operation returns to sealed; other preparations return to draft. Old
155
+ confirmations cannot apply. Backup checking and final I/O still verify physical content;
156
+ a manifest alone is not proof of a valid file.
157
+
158
+ A `download_backup` admission consumes one card input and captures one local-data
159
+ snapshot in the same SQLite transaction. The export role and exact generated
160
+ `.settings-staging/<fileId>.download` namespace identify its private file; an
161
+ export role or display name alone is insufficient. File bytes are not stored
162
+ in operation JSON or nested in exported local data. Physical write, fsync, length and SHA checks
163
+ finish before the snapshot becomes available. `result` is immutable preparation
164
+ evidence; delivery reports have separate typed state and atomic attempt identity.
165
+
166
+ An exact unsupported download report can atomically reserve final/file I/O and
167
+ admit local publication of that same snapshot. An earlier possibly handled
168
+ attempt instead records a pending local-copy decision. Explicit consent/retry
169
+ uses a distinct save-attempt identity and compare-and-set predecessor, without
170
+ creating another snapshot. Application names and absent capability advertisement
171
+ do not authorize this effect.
172
+
173
+ The private `download.localSave` journal in `preparation_json` records its source
174
+ manifest, fixed `backups/<operationId>.json` destination, attempt/consent and
175
+ physical source device/inode as decimal strings. The verified source identity
176
+ is committed before exclusive same-volume hard-link publication. The source and
177
+ target must name the recorded file and pass size/SHA checks before `saved` is
178
+ committed. Existing destinations are never overwritten or removed. Private
179
+ unlink follows that result and actual descriptor closure; the final file has
180
+ no automatic expiry. Historical export path validation remains distinct from
181
+ the private `.download` row identity. No table, column or schema version changes.
182
+
183
+ Unknown file effects remain `saving`, retaining their source and reservations.
184
+ A failed DB result write retains the ended physical outcome for settlement.
185
+ A missing target is distinct from one that could not be read. Only a verified
186
+ absent target with a valid source permits an explicit retry within the original
187
+ period. Recovery after owner exit verifies an existing source-bound target only;
188
+ an absent or mismatching artifact is not regenerated. The new owner inherits
189
+ settlement responsibility without restoring the old card's action permission.
190
+ A committed saved result remains a past fact when its private file is gone.
191
+
192
+ The fixed thirty-minute transfer period begins at physical readiness, independently
193
+ of the original input expiry. The owner schedules its earliest live transfer
194
+ deadline; current DB time, owner and epoch decide expiry. An abandoned frame does
195
+ not own cleanup. A failed already-due journal cannot create a zero-delay loop or
196
+ cancel another snapshot's future deadline. Status reads and owner recovery can
197
+ retry cleanup. Current-generation access rejects stale callbacks after replacement.
198
+
199
+ Private staging files survive as cleanup journal entries when cards are
200
+ invalidated. Reset/import invalidate uploads and private downloads and transfer
201
+ cleanup ownership without changing file identity. Existing public backup files
202
+ remain unchanged. Acknowledgment, explicit cancellation, expiry, source failure
203
+ or owner restart ends private retention, except that an already-admitted local
204
+ publication retains the evidence needed to settle its result first. Its final
205
+ reservation blocks competing Settings application and data replacement until
206
+ physical I/O and result settlement end. Active descriptor reads/writes finish
207
+ before deletion; new ranges and retries are refused once authority ends.
208
+ `temporaryFileCleanup` includes physical cleanup and settlement of the operation's
209
+ ended I/O reservation. Stored results remain readable during pending cleanup,
210
+ including when expiry persistence fails; input remains closed and the failed
211
+ cleanup stays visible. Another operation's reservation is never released.
212
+
213
+ An explicit same-result read may finish its cleanup or verify an existing
214
+ published export, never regenerate a backup, repeat Host delivery, reapply data
215
+ or replace an SDK run. Files/permissions/SDK credentials/private transaction
216
+ material are excluded from public backups. Clearing the default address does
217
+ not invalidate account-independent coin metadata or disconnect the wallet.
218
+
219
+ Non-terminal review session expiry is recorded lazily when the session is read or mutated after its TTL. Review-session expiry has no background worker; private download retention uses the separate owner timer described above.
138
220
 
139
221
  ## Shared local server
140
222
 
141
- Exactly one parent runtime owner per data directory binds the configured loopback port and creates the shared product services and SQLite stores. Other clients authenticate the listener before sending control credentials and forward MCP messages to it. The authentication covers database identity, internal API version 7, configuration (including WalletConnect project configuration) and server instance. Proof and subsequent dispatch use the same TCP connection. Host/Origin validation is separate from authentication; neither protects against a malicious process running as the same OS user.
223
+ Exactly one parent runtime owner per data directory binds the configured loopback port and creates the shared product services and SQLite stores. Other clients authenticate the listener before sending control credentials and forward MCP messages to it. The authentication covers database identity, the package release version, configuration (including WalletConnect project configuration) and server instance. Proof and subsequent dispatch use the same TCP connection. Host/Origin validation is separate from authentication; neither protects against a malicious process running as the same OS user.
142
224
 
143
225
  The private `runtime-control.key` file is separate from UI permissions and wallet credentials and is excluded from product backups. Stdio closure and process signals close the owned server. No client signals a peer backend. The parent may terminate only its own SDK child. A peer can acquire the port after it becomes free. Failed calls are not replayed automatically. MCP framing, cancellation and EOF handling start before backend acquisition; wallet SDK readiness does not block parent service startup.
144
226
 
@@ -204,10 +286,12 @@ child exit, while parent verification, submission and lookup flags remain until
204
286
  their own work ends. SDK readiness does not clear those independent guards.
205
287
 
206
288
  Initial SDK restoration considers the entire known connection set, including
207
- prior-owner records, before publishing current eligibility. Only confirmed
208
- known connected records transfer to the new owner. Multiple valid records are
209
- management targets, not usable wallet choices: `connectionConflict` is derived
210
- from those rows with no additional table. Targeted disconnection remains
289
+ prior-owner records, before publishing current eligibility. Confirmed known
290
+ connected records transfer to the new owner. Known terminal records with a
291
+ present SDK session transfer management metadata without changing their outcome.
292
+ Multiple known occupied connections are management targets, not usable wallet
293
+ choices: `connectionConflict` is derived from the journal and current supervisor
294
+ snapshot, with no additional table. Targeted disconnection remains
211
295
  available while new pairing, account use, review preparation and signing are
212
296
  blocked. The final submission transaction applies the same single-connection
213
297
  rule. Failed/stopped records and unknown SDK sessions do not restore authority.
@@ -221,6 +305,17 @@ database evaluation time and published to cards as `usableConnectionId` and
221
305
  `assetReadAccount`; Views do not recount recorded connections. This adds no
222
306
  table or expiry writer. Stored status, disconnection outcomes and historical
223
307
  account records retain their separate meanings.
308
+ The store reads the current run's private supervisor snapshot inside evaluation
309
+ and immediate admission. Missing inspection does not mean an empty service.
310
+ `manageableConnectionIds` names exact nonpending recorded disconnect targets,
311
+ including known terminal records whose SDK sessions remain present. They are not
312
+ usable account choices. `connectionReconciliationRequired: true` means a present
313
+ SDK session has no journal target after ordinary registration/cleanup has ended;
314
+ it blocks pairing, account use and unsubmitted signing until the user removes the
315
+ retained connection in the wallet app and a complete current-run observation
316
+ confirms absence. Settings can explicitly restart the service to inspect it
317
+ again; restart alone does not resolve retained presence. Topics remain private. A pending registration
318
+ is not reported as a reconciliation failure.
224
319
 
225
320
  An admission that changes connection eligibility or targets also publishes the
226
321
  owner's ready Connect/Review card revisions in that same transaction, after
@@ -234,7 +329,8 @@ write; they do not start another SDK process. Repeated reads after a successful
234
329
  repair do not repeat the transition. Unrelated stored transaction results and
235
330
  already dispatched chain observation remain independent of that write.
236
331
  The supervisor's explicit replacement primitive requires fencing and actual
237
- child exit before a new run, but it has no current card or model entry point.
332
+ child exit before a new run. Its user entry point is a scoped, explicitly
333
+ prepared and confirmed Settings card; ordinary model calls cannot replace it.
238
334
 
239
335
  If a completed callback's flag write fails, the owner retains its exact operation
240
336
  identity as completion evidence. A current state read can retry that database
@@ -257,6 +353,25 @@ The target session/card's own required expiry writes still propagate errors.
257
353
  This is not availability during an unreadable database or a bypass of authority
258
354
  revocation failures.
259
355
 
356
+ Connection facts and workflow maintenance have separate internal contracts.
357
+ `readConnectionFacts(at)` collects recorded connections, current-run SDK presence,
358
+ pending work and read-address provenance from one SQLite read snapshot. The
359
+ shared selector and qualification projection compute eligibility from those
360
+ facts; they do not update requests, expire connections or repair callbacks.
361
+ Settings general facts use this diagnostic path and stored counts, so another
362
+ request's refused deadline write does not prevent opening or reading Settings.
363
+ Creating a card and checking its own permission, input expiry or cleanup retain
364
+ their own writes. Stored counts are not a promise about a later deletion impact.
365
+
366
+ `reconcileAndEvaluate` requires a current-wallet or server-bound review purpose.
367
+ Current wallet consumers use `reconcileConnectionContext`; exact request reads
368
+ retain their narrower target. Reset/import preparation and final admission still
369
+ settle deadlines and compare the current impact in their transaction. Snapshot
370
+ memory may precede its DB publication: initializing/state_sync does not grant
371
+ account use or establish an unrecorded-connection removal diagnosis. Only a
372
+ published available run can qualify that guidance; missing guidance does not
373
+ prove that the SDK is empty.
374
+
260
375
  Successful reset/import invalidates pending SDK startup or recovery in the old
261
376
  data generation and ends that child without automatically starting another.
262
377
  Rejected or rolled-back replacement does not change the run or generation.
@@ -335,13 +450,21 @@ unknown-outcome records may be removed after the explicit warning; removing
335
450
  records cannot cancel a transaction. A generation change rejects late writes.
336
451
 
337
452
  The wallet store advances expired signature and initial-observation deadlines
338
- through the same request transition writer used by the workflow. Current
339
- session/card reads, current local-data counts and preview counts, and the actual
340
- reset/import transaction use this operation even when no View is open. Expiry
453
+ through the same request transition writer used by the workflow. Explicit
454
+ current-wallet reconciliation settles current wallet work. A server-bound review
455
+ read settles its own request target unless it depends on current wallet work;
456
+ it does not use an unrelated completed request as a reason for global maintenance.
457
+ Reset/import preparation settles deadlines before calculating its impact, and
458
+ final admission settles them again and compares the current impact in the same
459
+ transaction as replacement, even when no View is open.
460
+
461
+ General Settings facts and stored local-data counts use the diagnostic read
462
+ contract; they do not advance live requests. Creating or reading a card still
463
+ checks that card's own permission, input expiry and operation cleanup. Expiry
341
464
  does not clear pending SDK/submission/lookup callbacks. Stored activity queries
342
- and public backup export only read recorded facts; they do not advance live
343
- requests or interpret imported history as authority. Replacement warnings do not
344
- claim an earlier counts snapshot is the number being deleted now.
465
+ and public backup export also read recorded facts without advancing live
466
+ requests or treating imported history as authority. Replacement warnings do not
467
+ claim an earlier stored-counts snapshot is the number being deleted now.
345
468
 
346
469
  Disconnect progress is the existing running Connect card's accepted disconnect
347
470
  action and connection reference. Connection updates preserve that operation
@@ -349,9 +472,9 @@ until its result is recorded; no additional persisted connection status is used.
349
472
 
350
473
  ### Current format and backups
351
474
 
352
- The current `user_version` is 9. It identifies one supported schema; there is no migration registry or older-format decoder. All clients sharing a data directory must use the same compatible runtime.
475
+ The runtime accepts one current SQLite structure, checked against its table, column, constraint, index and trigger definitions before writes. There is no separate database version counter, migration registry or older-format decoder. All clients sharing a data directory must use the same package release.
353
476
 
354
- A current backup carries `format`, `schemaVersion`, `network`, `exportedAt` and its product data. Import rejects a missing or different schema identifier, incomplete required fields, invalid references or invalid raw quantities. Missing settings or activity arrays are not filled from defaults. Supported `function_scan` provenance remains part of the current format. Validation failure leaves current data intact.
477
+ A current backup carries `format`, `network`, `exportedAt` and its product data. It has no numeric schema version. Import rejects a different format, unknown or missing fields, invalid references or invalid raw quantities. Missing settings or activity arrays are not filled from defaults. Supported `function_scan` provenance remains part of the current format. Validation failure leaves current data intact.
355
478
 
356
479
  New installations do not inherit older local review records, activity scans, known/active accounts or stored endpoints. Users configure the required context again; environment overrides retain their existing precedence. Empty local history does not imply an absence of on-chain transactions. Existing DB and backup files are not deleted by startup.
357
480