@c4roa0/agentpay-user 0.0.0-stage → 0.3.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.
- package/AGENTS.md +137 -0
- package/CONTRIBUTING.md +16 -0
- package/LICENSE +373 -0
- package/NOTICE.md +20 -0
- package/README.md +85 -2
- package/SECURITY.md +16 -0
- package/doc/README.md +52 -0
- package/doc/TODO.md +107 -0
- package/doc/architecture.md +99 -0
- package/doc/design.md +60 -0
- package/doc/develope.md +68 -0
- package/doc/plans/user-wallet-distribution.md +91 -0
- package/doc/reference/harness-skill-runtime.md +120 -0
- package/doc/reference/local-cache-foundation.md +176 -0
- package/doc/reference/local-safe-owner-ui.md +25 -0
- package/doc/reference/local-update.md +18 -0
- package/doc/reference/multi-service-runtime.md +119 -0
- package/doc/reference/npm-integration-verification.md +103 -0
- package/doc/reference/onboarding-writing.md +48 -0
- package/doc/reference/original-order-recovery.md +97 -0
- package/doc/reference/private-anvil-onboarding-config.example.json +18 -0
- package/doc/reference/public-deployment-settings.md +56 -0
- package/doc/reference/random-skill-contract.md +18 -0
- package/doc/reference/result-file-cache.md +166 -0
- package/doc/reference/runtime-address-recovery.md +42 -0
- package/doc/reference/runtime-result-cache.md +157 -0
- package/doc/reference/runtime-startup-recovery.md +141 -0
- package/doc/reference/skill-input-output-cache.md +93 -0
- package/doc/reference/wallet-identity-policy-history.md +23 -0
- package/doc/runbooks/commands.md +103 -0
- package/doc/runbooks/deployment-authorization-update.md +42 -0
- package/doc/runbooks/emergency-payment-stop.md +80 -0
- package/doc/runbooks/local-autostart.md +212 -0
- package/doc/runbooks/local-cache.md +115 -0
- package/doc/runbooks/local-update.md +84 -0
- package/doc/runbooks/market-connection.md +73 -0
- package/doc/runbooks/npm-publication.md +56 -0
- package/doc/runbooks/official-test-package.md +62 -0
- package/doc/runbooks/order-cancellation.md +56 -0
- package/doc/runbooks/order-support.md +41 -0
- package/doc/runbooks/policy-renewal.md +80 -0
- package/doc/runbooks/private-anvil-terminal-setup.md +58 -0
- package/doc/runbooks/runtime-skill-client.md +155 -0
- package/doc/runbooks/safe-owner-web.md +104 -0
- package/doc/runbooks/safe-policy-migration.md +36 -0
- package/doc/runbooks/safe-policy-setup.md +52 -0
- package/doc/runbooks/terminal-authorization-preview.md +38 -0
- package/doc/runbooks/unlock-wallet.md +68 -0
- package/doc/runbooks/user-onboarding.md +87 -0
- package/doc/runbooks/wallet-identity.md +59 -0
- package/doc/security/public-source-review-2026-11-06.md +71 -0
- package/doc/usage.md +54 -0
- package/package.json +49 -4
- package/progress.md +210 -0
- package/run +29 -0
- package/scripts/agentpay-cli.mjs +11 -0
- package/scripts/authorize-existing-safe.mjs +211 -0
- package/scripts/autostart.mjs +186 -0
- package/scripts/cancel-order.mjs +76 -0
- package/scripts/check-installation.mjs +26 -0
- package/scripts/check-official-test-package.mjs +35 -0
- package/scripts/check-purchase-readiness.mjs +275 -0
- package/scripts/configure-runtime-client.mjs +16 -0
- package/scripts/guide-policy.mjs +64 -0
- package/scripts/initialize-caller-credential.mjs +11 -0
- package/scripts/install-skill-bundle.mjs +176 -0
- package/scripts/install-user.mjs +24 -0
- package/scripts/local-service.mjs +60 -0
- package/scripts/lock.mjs +11 -0
- package/scripts/login-notify.mjs +39 -0
- package/scripts/migrate-safe-policy.mjs +165 -0
- package/scripts/official-paid-test.mjs +9 -0
- package/scripts/poll-unconfirmed-notice.mjs +75 -0
- package/scripts/prepare-onboarding.mjs +33 -0
- package/scripts/preview-policy.mjs +65 -0
- package/scripts/random-model-ack-smoke.mjs +235 -0
- package/scripts/random-reject-smoke.mjs +147 -0
- package/scripts/renew.mjs +9 -0
- package/scripts/repair.mjs +10 -0
- package/scripts/revoke.mjs +9 -0
- package/scripts/select-skill-bundle.mjs +39 -0
- package/scripts/setup-local.mjs +199 -0
- package/scripts/status.mjs +13 -0
- package/scripts/test-package.mjs +35 -0
- package/scripts/unlock.mjs +13 -0
- package/scripts/update.mjs +7 -0
- package/scripts/user-setup.mjs +219 -0
- package/scripts/verify-npm-release.mjs +32 -0
- package/src/active-skill.mjs +160 -0
- package/src/anvil-onboarding-state.mjs +96 -0
- package/src/anvil-onboarding.mjs +1036 -0
- package/src/authorization-question-checkpoint.mjs +114 -0
- package/src/autostart-files.mjs +50 -0
- package/src/cache-management-cli.mjs +302 -0
- package/src/cache-management.mjs +47 -0
- package/src/caller-auth.mjs +58 -0
- package/src/client-request-lock.mjs +44 -0
- package/src/connect-market.mjs +408 -0
- package/src/demo-unlock-secret.mjs +64 -0
- package/src/deployment-status.mjs +198 -0
- package/src/file-cache-cli.mjs +83 -0
- package/src/file-cache-owner.mjs +74 -0
- package/src/file-cache-settings.mjs +50 -0
- package/src/file-cache.mjs +790 -0
- package/src/file-download.mjs +281 -0
- package/src/finalization-disclosure.mjs +16 -0
- package/src/guided-setup.mjs +194 -0
- package/src/index.mjs +1233 -0
- package/src/install-and-setup.mjs +38 -0
- package/src/install-preflight.mjs +201 -0
- package/src/install-user.mjs +279 -0
- package/src/installation-paths.mjs +31 -0
- package/src/invocation-result.mjs +148 -0
- package/src/invocation-store.mjs +385 -0
- package/src/local-data-directory.mjs +117 -0
- package/src/local-info.mjs +181 -0
- package/src/local-services.mjs +156 -0
- package/src/local-time.mjs +36 -0
- package/src/local-update.mjs +316 -0
- package/src/local-wallet-ipc.mjs +93 -0
- package/src/login-reminder.mjs +28 -0
- package/src/market-download-url.mjs +21 -0
- package/src/node-version.mjs +12 -0
- package/src/npm-update.mjs +126 -0
- package/src/official-paid-test.mjs +407 -0
- package/src/official-test-package.mjs +41 -0
- package/src/official-test-update.mjs +162 -0
- package/src/order-cancellation.mjs +241 -0
- package/src/order-closure.mjs +42 -0
- package/src/order-list-panel.mjs +110 -0
- package/src/order-review.mjs +424 -0
- package/src/order-status-panel.mjs +65 -0
- package/src/order-support.mjs +365 -0
- package/src/owner-approval-server.mjs +332 -0
- package/src/owner-signer.mjs +67 -0
- package/src/policy-info.mjs +38 -0
- package/src/policy-migration.mjs +84 -0
- package/src/policy-operations.mjs +67 -0
- package/src/policy-preview-server.mjs +236 -0
- package/src/policy-terminal-guide.mjs +377 -0
- package/src/prepare-local-services.mjs +143 -0
- package/src/prepare-onboarding.mjs +210 -0
- package/src/private-journal-files.mjs +29 -0
- package/src/protocol-package.mjs +25 -0
- package/src/readiness-profile.mjs +30 -0
- package/src/renew-policy.mjs +605 -0
- package/src/repair-market-wallet.mjs +137 -0
- package/src/restore-wallet.mjs +255 -0
- package/src/result-cache-view.mjs +276 -0
- package/src/runtime-client.mjs +1145 -0
- package/src/runtime-connection-settings.mjs +101 -0
- package/src/runtime-recovery.mjs +667 -0
- package/src/runtime-status.mjs +32 -0
- package/src/safe-owner-anvil.mjs +115 -0
- package/src/safe-policy-plan.mjs +195 -0
- package/src/service-reference.mjs +233 -0
- package/src/service-url.mjs +52 -0
- package/src/settlement-response.mjs +69 -0
- package/src/setup-autostart.mjs +197 -0
- package/src/setup-demo.mjs +152 -0
- package/src/skill-bundle.mjs +142 -0
- package/src/skill-client.mjs +198 -0
- package/src/skill-install-prompt.mjs +31 -0
- package/src/skill-package.mjs +50 -0
- package/src/skill-zip.mjs +220 -0
- package/src/software-versions.mjs +48 -0
- package/src/status-panel.mjs +603 -0
- package/src/transport.mjs +48 -0
- package/src/uninstall-local.mjs +299 -0
- package/src/user-cli.mjs +354 -0
- package/src/user-setup-guide.mjs +193 -0
- package/src/wallet-control.mjs +182 -0
- package/src/wallet-ipc-error.mjs +16 -0
- package/src/wallet-package.mjs +28 -0
- package/update-pair.json +6 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Public deployment settings and owner signer
|
|
2
|
+
|
|
3
|
+
## Public facts
|
|
4
|
+
|
|
5
|
+
User settings published by Market retain the existing fields: mode, chainId,
|
|
6
|
+
source, rpcUrl, settlementUrl, module, token, factory, registry, tokenDecimals,
|
|
7
|
+
tokenSymbol and the official-test metadata URL/digest/usage fields.
|
|
8
|
+
Supported mode labels are private-anvil and production; neither chooses a signer.
|
|
9
|
+
chainId must be a positive safe integer. HTTPS and loopback HTTP are permitted;
|
|
10
|
+
URL credentials, queries and fragments are rejected. Token decimals are 0–36.
|
|
11
|
+
Addresses must be valid nonzero EVM addresses. No participant Safe, owner, secret
|
|
12
|
+
or ownerSigner is accepted in the public User settings.
|
|
13
|
+
|
|
14
|
+
Provider settings retain network as eip155:<chainId> and assetAddress rather than
|
|
15
|
+
renaming their existing wire fields. Their numeric network and token constraints
|
|
16
|
+
match User settings. The Provider no longer defaults missing network to 31337.
|
|
17
|
+
This aligns the role-specific projections; it does not add a Protocol wire version
|
|
18
|
+
or claim the deployment scripts already generate one authoritative manifest.
|
|
19
|
+
|
|
20
|
+
Official package metadata remains release-pinned by User. Accepting another
|
|
21
|
+
network configuration never authorizes a substituted executable package.
|
|
22
|
+
|
|
23
|
+
## Local signer selection
|
|
24
|
+
|
|
25
|
+
Owner signing is selected independently of network:
|
|
26
|
+
- external: prepare operations for the Safe owner; never call an unlocked test account.
|
|
27
|
+
- anvil: explicit private test adapter; still requires chain 31337 and loopback HTTP.
|
|
28
|
+
The adapter also verifies the actual RPC chain and single-owner test Safe.
|
|
29
|
+
|
|
30
|
+
The initial private guide asks for this choice (default external) and saves it in
|
|
31
|
+
its local settings. When the participant confirms owner operations, it persists
|
|
32
|
+
runtime/owner-signer.json inside the User data directory as a private file:
|
|
33
|
+
`{"version":1,"kind":"external"}` or `{"version":1,"kind":"anvil"}`.
|
|
34
|
+
Renew/revoke read this local choice. AGENTPAY_OWNER_SIGNER can explicitly override
|
|
35
|
+
it for the current process. No record means external; existing installations are
|
|
36
|
+
not silently opted into test signing based on chain ID.
|
|
37
|
+
|
|
38
|
+
For an existing private installation with no saved selection, an operator may use
|
|
39
|
+
`AGENTPAY_OWNER_SIGNER=anvil ./run policy renew` (or revoke) only when that actual
|
|
40
|
+
authorization change is intended. Do not run either command merely to configure
|
|
41
|
+
the signer. No local Wallet Policy/key/history is changed by reading the selection.
|
|
42
|
+
|
|
43
|
+
## Implemented approval and remaining acceptance
|
|
44
|
+
|
|
45
|
+
The common setup runner accepts configured EVM networks and uses the same draft,
|
|
46
|
+
plan, chain checks and Wallet binding. Its historical module/local settings filename
|
|
47
|
+
is retained for checkpoint continuity. External approval serves a temporary local
|
|
48
|
+
website for an injected owner wallet, with a portable export fallback. Setup, renewal
|
|
49
|
+
and revocation retain their operation plans and check actual chain effects before
|
|
50
|
+
continuing. An external signer can be selected on Anvil. See
|
|
51
|
+
[browser approval](../runbooks/safe-owner-web.md) for execution and recovery.
|
|
52
|
+
Single-owner private Anvil acceptance does not prove multisig, headless recovery or
|
|
53
|
+
public-network readiness; those acceptance gates remain in [TODO](../TODO.md).
|
|
54
|
+
|
|
55
|
+
The official test package/network map is still private-only. Another network pauses
|
|
56
|
+
before that package installation after retaining its verified authorization.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Official random-service test example
|
|
2
|
+
|
|
3
|
+
The random service is the maintained post-setup payment connectivity example. Its
|
|
4
|
+
business input/output belongs to the reference Skill and Provider, not Runtime's
|
|
5
|
+
common protocol. Runtime accepts per-call service references and business JSON;
|
|
6
|
+
see [common invocation contract](multi-service-runtime.md).
|
|
7
|
+
|
|
8
|
+
The official test uses a release-pinned package digest from User. Market can supply
|
|
9
|
+
public download metadata but cannot replace trusted executable bytes. A new paid
|
|
10
|
+
test requires explicit quote confirmation; an interrupted test resumes its original
|
|
11
|
+
request. Normal startup, Orders, cache and Policy management do not require this
|
|
12
|
+
service to be selected globally.
|
|
13
|
+
|
|
14
|
+
The editable reference implementation is published in
|
|
15
|
+
[AgentPay Agent](https://github.com/c4rO-0/agentpay-agent). User's local test fixtures
|
|
16
|
+
are controlled copies for development, not a source of trusted production packages.
|
|
17
|
+
See [official package maintenance](../runbooks/official-test-package.md) and
|
|
18
|
+
[Skill author integration](../runbooks/runtime-skill-client.md).
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Local result file cache
|
|
2
|
+
|
|
3
|
+
Current source, 2026-11-04: [unified cache management](../runbooks/local-cache.md)
|
|
4
|
+
includes text/file display, both durable result stores and saved Provider source.
|
|
5
|
+
The output APIs below remain supported through the shared store. Controlled binary
|
|
6
|
+
verification passed; actual paid binary-service acceptance is a separate gate.
|
|
7
|
+
|
|
8
|
+
Implemented and verified within the private scope on 2026-11-02. See the
|
|
9
|
+
closeout (private historical evidence; not distributed) for controlled tests,
|
|
10
|
+
participant restart/unlock and unverified environments.
|
|
11
|
+
This is an optional local Runtime interface, not a Provider wire requirement.
|
|
12
|
+
|
|
13
|
+
## Operations
|
|
14
|
+
|
|
15
|
+
All routes are authenticated POSTs on the existing loopback Runtime with its
|
|
16
|
+
existing caller credential. Download requires exactly one saved Order with a verified
|
|
17
|
+
local result matching its original service/request. Listing and removing cached files
|
|
18
|
+
remain possible even when the original result file is missing or damaged. No Wallet signature, new payment, Provider service execution
|
|
19
|
+
or receipt confirmation is part of these operations.
|
|
20
|
+
|
|
21
|
+
| Route | JSON fields | Result |
|
|
22
|
+
| --- | --- | --- |
|
|
23
|
+
| `/files/cache` | `orderId`, `fileKey`, `url`; optional `filename`, `sha256` | Download/reuse metadata, including generated local path when available |
|
|
24
|
+
| `/files/list` | `orderId`; optional `offset`, `limit` (1–100) | Saved file metadata for this Order |
|
|
25
|
+
| `/files/remove` | `orderId`, `fileKey`, `confirmed: true` | Delete local copy and retain metadata with removed state |
|
|
26
|
+
|
|
27
|
+
The installed Runtime client exports `cacheResultFile`, `listResultFiles`, and
|
|
28
|
+
`removeResultFile`. Skill authors select a file URL explicitly; Runtime does not
|
|
29
|
+
inspect arbitrary business output for links or force a new output schema.
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import {loadRuntimeConnection, cacheResultFile, listResultFiles}
|
|
33
|
+
from './runtime-client.mjs'; // Installed User client module, not a copied implementation.
|
|
34
|
+
const connection = await loadRuntimeConnection();
|
|
35
|
+
const file = await cacheResultFile(connection, {
|
|
36
|
+
orderId, fileKey: 'report', url: reportUrl, filename: 'report.pdf',
|
|
37
|
+
// sha256: expectedDigest, // Optional expected digest from your delivery contract.
|
|
38
|
+
});
|
|
39
|
+
const files = await listResultFiles(connection, orderId);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Skill bootstrap code must resolve the installed User client through the saved local
|
|
43
|
+
connection as it already does. The illustrative import above denotes that installed
|
|
44
|
+
module; it is not a requirement to bundle transport or copy credentials into Skills.
|
|
45
|
+
Use `./run orders files ORDER_ID` to list copies and
|
|
46
|
+
`./run orders files ORDER_ID remove FILE_KEY` to remove one after terminal confirmation.
|
|
47
|
+
Listings show up to 100 entries, newest first; use `./run orders files ORDER_ID list 2`
|
|
48
|
+
for the second page. Runtime must be running; Wallet unlock is not needed. `confirmed: true` is an explicit operation acknowledgement, not an
|
|
49
|
+
OS isolation or cryptographic owner approval. Agents have the local caller boundary.
|
|
50
|
+
|
|
51
|
+
`fileKey` is 1–80 ASCII letters/digits/dots/underscores/hyphens and identifies one
|
|
52
|
+
file within the Order. Reuse the same key for retry. An expired URL may be replaced only when the
|
|
53
|
+
record already has a known local or expected digest; downloaded bytes must still
|
|
54
|
+
match that digest. Preserve the original optional `sha256` argument. Without any
|
|
55
|
+
known digest, use the original URL or explicitly select a different file key;
|
|
56
|
+
Runtime cannot establish that a newly supplied link contains the original bytes. Display filenames never form filesystem paths.
|
|
57
|
+
URLs, query credentials and file contents are not returned in routine metadata or
|
|
58
|
+
logged. Available metadata contains size, SHA-256, generated path, timestamp,
|
|
59
|
+
transport (http/https), and integrity description. Inspect the state before using a
|
|
60
|
+
path. The file is never executed, extracted, or rendered by Runtime.
|
|
61
|
+
|
|
62
|
+
## Transfer and integrity
|
|
63
|
+
|
|
64
|
+
HTTP and HTTPS are supported, including explicit ports. HTTP is unencrypted;
|
|
65
|
+
metadata reports its transport. Neither transport alone proves delivery correctness.
|
|
66
|
+
Source URLs may differ from the Provider service endpoint.
|
|
67
|
+
|
|
68
|
+
DNS answers are validated; allowed addresses are tried in order and pinned to each
|
|
69
|
+
connection. Up to five redirects are revalidated hop by hop; HTTPS-to-HTTP
|
|
70
|
+
downgrade is refused. Direct HTTP remains supported.
|
|
71
|
+
Private, loopback, link-local/metadata and reserved destinations are denied by
|
|
72
|
+
default. Embedded URL credentials are refused. Identity transfer is requested;
|
|
73
|
+
gzip, deflate and Brotli responses are decoded with both transfer and decoded-byte
|
|
74
|
+
limits. Unknown HTTP encodings are rejected; this does not restrict archive file formats. Caller/Wallet credentials are never forwarded. Optional signed query URLs
|
|
75
|
+
remain only in private metadata; protect cache backups accordingly.
|
|
76
|
+
|
|
77
|
+
An operator may set `AGENTPAY_USER_FILE_CACHE_PRIVATE_ORIGINS` to a JSON array of at
|
|
78
|
+
most 16 exact origins, e.g. `["http://127.0.0.1:8123"]`, in the Runtime environment
|
|
79
|
+
for controlled private fixtures. Only that scheme/host/port is excepted; DNS is still
|
|
80
|
+
pinned. Only loopback/RFC1918/ULA destinations qualify for this exception; metadata
|
|
81
|
+
link-local and reserved addresses remain blocked. No wildcard/all-private-network
|
|
82
|
+
option exists. Default is `[]`; the installer does not enable an exception.
|
|
83
|
+
|
|
84
|
+
Transfers stream to private temporary files, enforce the actual byte limit even
|
|
85
|
+
without Content-Length. Default total transfer timeout is 15 minutes, configurable
|
|
86
|
+
up to 24 hours. Connection/header attempts are capped at 10 seconds each within
|
|
87
|
+
that total budget. These are local resource limits, not Provider delivery deadlines. No partial file is marked
|
|
88
|
+
available. After restart, the first cache operation validates completed bytes with a durable
|
|
89
|
+
digest and finishes publication where possible; other interrupted transfers are
|
|
90
|
+
marked failed and their owned partial bytes removed. Retrying restarts only the download; no
|
|
91
|
+
byte-range append or automatic background network retry is implemented.
|
|
92
|
+
|
|
93
|
+
An optional expected SHA-256 must match. Otherwise the digest records local bytes
|
|
94
|
+
only. A Skill-supplied digest is not itself evidence from Settlement. Metadata uses
|
|
95
|
+
`expected_digest_matched` or `local_digest_only`; neither is an evidence-binding
|
|
96
|
+
claim. Reuse rechecks the saved file hash, size and permissions. Listing shows saved
|
|
97
|
+
metadata and does not reread/hash every binary. If a previously downloaded URL later
|
|
98
|
+
serves different bytes, retry cannot silently replace the known digest. Original
|
|
99
|
+
links may expire; refreshing one is separate from buying/executing the service.
|
|
100
|
+
|
|
101
|
+
## Storage, limits and cleanup
|
|
102
|
+
|
|
103
|
+
Storage is under `runtime/invocations.json.files/` in selected User data. Index and
|
|
104
|
+
binary files are owner-private (0600); directory is 0700. Generated SHA-256 storage
|
|
105
|
+
names derive from Order ID/file key. Files and index updates are fsynced and published
|
|
106
|
+
atomically. Metadata stores state/timestamps, source and integrity; it retains
|
|
107
|
+
removed/failed records. Local backup contains private result data and URLs.
|
|
108
|
+
|
|
109
|
+
Default limits: 100 MiB/file, 512 MiB shared input/output file bytes, 20 non-removed records per request or Order,
|
|
110
|
+
2 concurrent transfers, 10,000 retained history records and 8 MiB metadata.
|
|
111
|
+
Removed copies free byte capacity and per-Order slots. Removed history remains
|
|
112
|
+
bounded separately: at its cap, new keys stop with FILE_HISTORY_LIMIT; existing
|
|
113
|
+
keys remain reusable. History is not silently deleted. Operators can raise the
|
|
114
|
+
record cap (up to 100,000), subject to the metadata byte cap.
|
|
115
|
+
|
|
116
|
+
Prefer `./run cache settings` to inspect/change limits live. `./run cache settings`
|
|
117
|
+
also shows saved limits and the optional settings path:
|
|
118
|
+
`runtime/invocations.json.file-cache-settings.json` under selected User data.
|
|
119
|
+
Create an owner-private (0600) JSON file containing only the overrides needed:
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{"singleBytes":209715200,"totalBytes":1073741824,"timeoutMs":3600000}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Other keys are `filesPerResult`, `concurrent`, and `records`. Values must be positive
|
|
126
|
+
integers; singleBytes cannot exceed totalBytes; totalBytes is capped at 1 TiB,
|
|
127
|
+
concurrent at 16, records at 100,000 and timeoutMs at 86,400,000. Manual file edits require Runtime restart (`./run service restart` also locks Wallet);
|
|
128
|
+
`./run cache settings KEY VALUE` applies changes live without that restart. Invalid optional cache settings
|
|
129
|
+
fail file operations without stopping Runtime's Order recovery. Limits cannot be
|
|
130
|
+
supplied by a Skill in route requests.
|
|
131
|
+
|
|
132
|
+
URL transfers reserve the maximum file size; local inputs reserve their checked
|
|
133
|
+
file size. Reservations subtract already-written partial or published bytes;
|
|
134
|
+
actual stored bytes also count. A small file may still require one full-size slot.
|
|
135
|
+
Cache ownership uses `fs-native-extensions` 1.5.3 through a small file-lock adapter.
|
|
136
|
+
Each Runtime retains a descriptor for the empty `owner.lock` file in the cache
|
|
137
|
+
folder. OS locks release on process exit/crash; the file itself remains and must
|
|
138
|
+
not be deleted/replaced while Runtime is running. There are no heartbeat timers,
|
|
139
|
+
PID-reuse assumptions or extra ports. Multiple handles in one process share a queue.
|
|
140
|
+
|
|
141
|
+
The pinned package ships Node prebuilds for Linux, macOS and Windows x64/ARM64;
|
|
142
|
+
this host verified Linux x64 with Node 22.22.3 using installation scripts disabled,
|
|
143
|
+
without compilation. The lock adapter no longer rejects other OSes. This is not a
|
|
144
|
+
claim that all User filesystem permissions, startup or CLI operations have been
|
|
145
|
+
ported/tested on Windows/macOS/mobile. Actual supported environments remain subject
|
|
146
|
+
to platform acceptance. Network/shared-filesystem locking is not validated.
|
|
147
|
+
|
|
148
|
+
If the native binding is unavailable, file operations fail with
|
|
149
|
+
`FILE_CACHE_LOCK_UNAVAILABLE`; they never silently skip locking. Reinstall the
|
|
150
|
+
locked User dependencies with `npm ci` and restart Runtime; if the error persists,
|
|
151
|
+
report the Node/OS/architecture to support. Runtime startup and Order recovery do
|
|
152
|
+
not load this optional native binding. A lock file left after a crash is normal:
|
|
153
|
+
do not manually delete it to recover. Full uninstall still stops services first.
|
|
154
|
+
|
|
155
|
+
Removal first persists deletion intent, then deletes bytes and records completion;
|
|
156
|
+
restart finishes interrupted deletion. Removal retains history and does not cancel/refund an Order or remove structured
|
|
157
|
+
results. Cache-full never evicts original data. The existing confirmed all-local-data
|
|
158
|
+
uninstall removes this subdirectory with User data. Back up the complete User data
|
|
159
|
+
folder privately to retain pending/verified results, files, history and signed URLs;
|
|
160
|
+
key/Policy backup alone cannot restore file contents.
|
|
161
|
+
|
|
162
|
+
Tests use controlled streams, default HTTP/HTTPS clients with normal certificate
|
|
163
|
+
validation, actual SIGKILL transfer recovery, and two
|
|
164
|
+
maintained business payloads through Runtime. They are not production network or
|
|
165
|
+
live paid acceptance, and do not establish that an arbitrary Provider can retain or
|
|
166
|
+
reissue files indefinitely.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Runtime address and original-request recovery
|
|
2
|
+
|
|
3
|
+
Implemented recovery boundary; participant and real-network scope remain in TODO.
|
|
4
|
+
A local Runtime URL is transport location, not purchase identity. Historical records
|
|
5
|
+
that included an address are retained for guarded lookup rather than silently reset.
|
|
6
|
+
|
|
7
|
+
## Existing-only recovery
|
|
8
|
+
|
|
9
|
+
Treat loopback Runtime URL as a connection location. Preserve service/profile/input,
|
|
10
|
+
caller request ID, original orderRequestId, authorization scope and any known Order
|
|
11
|
+
ID as recovery evidence. Do not add a machine ID or bind nickname to an installation.
|
|
12
|
+
|
|
13
|
+
Before allowing a changed destination, inspect the original request through the
|
|
14
|
+
authenticated local interface. Do not create state during this check. Continuing a
|
|
15
|
+
recovered request must atomically require that original invocation still exists and
|
|
16
|
+
matches: a separate successful preflight alone cannot protect against state removal
|
|
17
|
+
before execution. Missing, mismatched or ambiguous history stops paid continuation.
|
|
18
|
+
The new Runtime may not silently call begin's create branch for a recovery request.
|
|
19
|
+
|
|
20
|
+
Default selection must find old records independently of the changed port. Preserve
|
|
21
|
+
historical records and block ambiguity; do not overwrite legacy keys or silently
|
|
22
|
+
choose one of multiple candidate requests. Valid local verified results can be read
|
|
23
|
+
without restarting a purchase. Explicit new-purchase intent remains separate.
|
|
24
|
+
|
|
25
|
+
A truly never-submitted request needs a separately justified creation path; absence
|
|
26
|
+
of a local Order ID is not proof that it never reached Runtime. A lost-history
|
|
27
|
+
reinstall requires original-order reconciliation, not blind URL replacement.
|
|
28
|
+
|
|
29
|
+
## Required regression coverage
|
|
30
|
+
|
|
31
|
+
Same history/new port; same Wallet/missing history; changed service/input/scope;
|
|
32
|
+
legacy address-keyed selection; multiple candidates; concurrent selection; crash
|
|
33
|
+
between lookup and execution; saved result reuse. In every recovery failure assert
|
|
34
|
+
zero new prepare/sign/fund calls. Use two maintained business payloads. No old
|
|
35
|
+
Policy, Order, commitment or service profile is rewritten.
|
|
36
|
+
|
|
37
|
+
## Related input snapshots
|
|
38
|
+
|
|
39
|
+
The approved [Skill input/output persistence plan](skill-input-output-cache.md) adds
|
|
40
|
+
request-scoped file snapshots without changing the existing-only recovery requirement.
|
|
41
|
+
Implement and verify these together at the invocation boundary; cached files alone
|
|
42
|
+
do not prove that another Runtime retains the original financial history.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Runtime result records and file caching
|
|
2
|
+
|
|
3
|
+
Date: 2026-11-02. All three implementation loops are complete within the
|
|
4
|
+
recorded private scope (private historical evidence; not distributed), including
|
|
5
|
+
participant restart/unlock. This plan introduces no new Provider output protocol.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Goal and existing behavior
|
|
9
|
+
|
|
10
|
+
Preserve a paid service's original result across Runtime/Agent interruption without
|
|
11
|
+
buying or executing the service again. Separate payment status, delivery evidence,
|
|
12
|
+
local result availability and downloaded file availability.
|
|
13
|
+
|
|
14
|
+
The initial verified-result store used `runtime/invocations.json.results/` and saved
|
|
15
|
+
only after evidence verification. Implemented loop 1 now saves a bounded pending
|
|
16
|
+
record first, then verifies and promotes it; local recovery distinguishes missing,
|
|
17
|
+
pending, invalid and old-format results. Loop 2 keeps binaries and transfer metadata
|
|
18
|
+
separate. See the current file-cache reference for implemented behavior and limits.
|
|
19
|
+
A JSON containing a URL is not a local copy of that file.
|
|
20
|
+
|
|
21
|
+
An initial pending-JSON draft was paused while this layered plan was approved.
|
|
22
|
+
Loop 1 now implements structured result persistence under that plan; it does not
|
|
23
|
+
implement file downloads. Current pending records use a separate private
|
|
24
|
+
`runtime/invocations.json.pending-results/` directory and retain the candidate
|
|
25
|
+
alongside the verified copy. Each record is capped at 2 MiB, matching the existing
|
|
26
|
+
result read limit. Automatic eviction and binary-file quota belong to loop 2.
|
|
27
|
+
|
|
28
|
+
## Boundaries
|
|
29
|
+
|
|
30
|
+
- User Runtime owns private local storage and recovery orchestration. Wallet keeps
|
|
31
|
+
its existing bounded signing/read authority. Settlement stores hashes/usage and
|
|
32
|
+
delivery evidence, not private output or downloaded files. Market is not a result
|
|
33
|
+
hosting service. No contract, SQL or shared Provider wire change is required by
|
|
34
|
+
this plan.
|
|
35
|
+
- Keep Provider output format and existing output-hash semantics application-owned.
|
|
36
|
+
Do not scan arbitrary output strings for URLs, invent business-specific adapters,
|
|
37
|
+
require file descriptors in every response, or change what existing receipts mean.
|
|
38
|
+
- A Skill explicitly requests caching of selected files through a generic local
|
|
39
|
+
interface. This interface is an opt-in local feature, not a new prerequisite for
|
|
40
|
+
a Provider to accept Orders. The implemented local API is documented in
|
|
41
|
+
[the file-cache reference](../reference/result-file-cache.md); it is not a Provider wire change.
|
|
42
|
+
- Private contents, download tokens and signed URLs never appear in status/help,
|
|
43
|
+
routine logs, Market, or Settlement. Local OS ownership is the protection boundary;
|
|
44
|
+
this is not isolation from another process running as the same OS user.
|
|
45
|
+
- Cache state never authorizes payment, confirms receipt, changes dispute deadlines,
|
|
46
|
+
proves service quality, or automatically creates a replacement purchase.
|
|
47
|
+
|
|
48
|
+
## Storage and separate states
|
|
49
|
+
|
|
50
|
+
Keep the existing verified-record format and location. Add separate pending result
|
|
51
|
+
storage and file storage under the selected User data directory, with private owner
|
|
52
|
+
permissions. Paths/names supplied by the Provider must not determine filesystem
|
|
53
|
+
paths; use generated internal identifiers. Original human filenames are metadata.
|
|
54
|
+
|
|
55
|
+
| Layer | States and meaning |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| Financial Order | Existing authenticated Settlement state; never inferred from cache |
|
|
58
|
+
| Result record | Missing; pending evidence; verified; invalid; older format not verifiable |
|
|
59
|
+
| File | Not downloaded; downloading; available locally; interrupted/failed; removed locally |
|
|
60
|
+
| File integrity | Local digest recorded; expected digest matched, if provided; evidence binding verified only when the existing delivery contract supports it |
|
|
61
|
+
|
|
62
|
+
Do not label an old-format result as absent if bytes exist. Do not label a local
|
|
63
|
+
hash as Provider authenticity: a digest computed after download proves only local
|
|
64
|
+
integrity unless independently bound to the agreed original evidence. A verified
|
|
65
|
+
structured result may coexist with undownloaded/expired file links. No implicit
|
|
66
|
+
"all files complete" claim is possible for unknown application-owned output.
|
|
67
|
+
|
|
68
|
+
Result records contain the original invocation/Order identity and service binding,
|
|
69
|
+
verification state and timestamps. File metadata references the original result,
|
|
70
|
+
local generated file identity, display filename, actual size, digest, source and
|
|
71
|
+
transfer state. Avoid putting binary content/base64 blobs in result JSON.
|
|
72
|
+
|
|
73
|
+
## Result receipt and restart
|
|
74
|
+
|
|
75
|
+
1. Validate Provider response shape, size, identity and output integrity using the
|
|
76
|
+
existing service contract. Save the bounded result as pending before waiting for
|
|
77
|
+
Settlement's evidence. Do not return it as a successful verified delivery yet.
|
|
78
|
+
2. Verify original Order/service/request, output hash and usage against authenticated
|
|
79
|
+
Settlement evidence using the original Policy scope. Revocation or unavailable
|
|
80
|
+
authority stays a visible blocker; no Safe-only lookup or rebinding workaround.
|
|
81
|
+
3. Atomically promote the result to verified, then return it. Crash between promotion
|
|
82
|
+
and response must return the same saved result on retry. Conflicting candidates
|
|
83
|
+
never silently overwrite the original. Avoid comparing mutable disclosure fields
|
|
84
|
+
as if they were immutable delivery content.
|
|
85
|
+
4. Startup/background recovery may verify saved pending results using bounded reads;
|
|
86
|
+
it must not invoke Provider service execution, submit payment or confirm receipt.
|
|
87
|
+
Explicit same-request resume can use this pending copy before considering service
|
|
88
|
+
execution. Existing financial closure still governs all service/mutation actions.
|
|
89
|
+
5. Corruption, disk-full, partial writes, concurrent recovery and unknown legacy
|
|
90
|
+
formats must fail visibly and preserve original history. Persisted pending state
|
|
91
|
+
must be included in orphan/history checks and limits. Unverified files never
|
|
92
|
+
become ordinary verified results merely because an Order was paid out.
|
|
93
|
+
|
|
94
|
+
When no result was durably received (for example the process dies before receiving
|
|
95
|
+
the response), local caching cannot solve that loss. Original Provider retrieval,
|
|
96
|
+
its permissions and applicable support deadlines remain the recovery route.
|
|
97
|
+
|
|
98
|
+
## File transfer
|
|
99
|
+
|
|
100
|
+
- Skill calls a bounded, authenticated local cache operation for an explicitly
|
|
101
|
+
selected result/file. Do not reuse the payment or generic signing interface.
|
|
102
|
+
- Support HTTP and HTTPS; record whether the source transport is encrypted. Validate destination resolution and redirects, including private,
|
|
103
|
+
loopback, link-local and metadata endpoints; prevent DNS rebinding/redirect bypass.
|
|
104
|
+
Controlled private rehearsal fixtures require explicit narrow configuration,
|
|
105
|
+
never a global private-network bypass.
|
|
106
|
+
- No arbitrary filesystem writes, automatic unpacking, execution, previewing active
|
|
107
|
+
content, or forwarding Wallet/Runtime tokens to remote sources. Arbitrary remote
|
|
108
|
+
authentication headers are not an initial feature. Keep any permitted signed URL
|
|
109
|
+
private; redirect changes must not leak credentials.
|
|
110
|
+
- Stream to a temporary file, cap actual bytes even without Content-Length, enforce
|
|
111
|
+
deadlines/concurrency and reserve quota before writing. Match a supplied expected
|
|
112
|
+
hash where applicable, then fsync and atomically publish. Partial bytes are not an
|
|
113
|
+
available result. Leave original identity intact after timeout/network failure.
|
|
114
|
+
- Initial restart recovery may retry only the file transfer. Byte-range continuation
|
|
115
|
+
is optional: use it only with reliable validators preventing mixed file versions;
|
|
116
|
+
otherwise restart the download rather than append blindly. Never invoke the paid
|
|
117
|
+
service again to refresh an expired link.
|
|
118
|
+
- If the URL expired or content changed, retain the failure and original metadata.
|
|
119
|
+
Requesting an original file again is distinct from rerunning the service. No claim
|
|
120
|
+
that every Provider can reissue URLs or retain outputs indefinitely.
|
|
121
|
+
|
|
122
|
+
## Capacity and cleanup
|
|
123
|
+
|
|
124
|
+
Implement bounded total file bytes, single-file bytes, per-result file count and
|
|
125
|
+
concurrent transfers. Implemented defaults and configuration names are documented in the
|
|
126
|
+
[file-cache reference](../reference/result-file-cache.md); the cache is bounded. Account for
|
|
127
|
+
concurrent reservations, interrupted temporary files and disk-full failures.
|
|
128
|
+
|
|
129
|
+
Do not automatically evict Order history, evidence metadata or pending result records
|
|
130
|
+
to make room. At the limit, stop new file downloads with a clear action. Initial
|
|
131
|
+
cleanup is deliberate: show scope/size, confirm, delete only selected local file
|
|
132
|
+
copies, and retain metadata marked removed locally. Protect in-flight writes and
|
|
133
|
+
use locks/atomic transitions so cleanup cannot publish a deleted transfer as ready.
|
|
134
|
+
Later automatic retention requires its own explicit policy. Uninstall's existing
|
|
135
|
+
confirmed all-local-data removal includes this storage. Backup guidance must explain
|
|
136
|
+
that restoring keys/Policy alone does not restore private result/file copies.
|
|
137
|
+
|
|
138
|
+
## UX and implementation loops
|
|
139
|
+
|
|
140
|
+
1. **Result preservation:** pending → evidence verification → verified; read-only
|
|
141
|
+
restart recovery; accurate missing/invalid/legacy/pending messages in status,
|
|
142
|
+
orders and details. Keep structured results general. Verify crash boundaries,
|
|
143
|
+
wrong evidence, revoked Policy, disk errors and concurrent same-request resume
|
|
144
|
+
with at least two maintained business payloads through one Runtime.
|
|
145
|
+
2. **File cache:** finalize the local Skill client interface and limits; implement
|
|
146
|
+
metadata + streaming file storage, safe downloads, interruption/retry, quota and
|
|
147
|
+
deliberate cleanup. Test maintained text/binary fixtures, malicious destinations,
|
|
148
|
+
redirects, changed downloads, large/unknown-length streams and cleanup races.
|
|
149
|
+
3. **Integration and acceptance:** document Skill-author usage and local CLI access;
|
|
150
|
+
distinguish original Order status, record verification and file availability.
|
|
151
|
+
Integrate uninstall/backup/info. Participant tests use official controlled fixtures,
|
|
152
|
+
preserve original Policy/history and avoid third-party Skills. No new purchase is
|
|
153
|
+
needed merely to inspect existing cache. Report source tests separately from
|
|
154
|
+
real-process and human acceptance.
|
|
155
|
+
|
|
156
|
+
The loops above were completed in sequence; see the closeout for their evidence. Neither a JSON placeholder
|
|
157
|
+
nor mocked downloads constitute acceptance of durable binary file recovery.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Runtime startup self-check and Order recovery
|
|
2
|
+
|
|
3
|
+
Status: source implementation and isolated verification completed on 2026-10-24;
|
|
4
|
+
participant restart/unlock and legacy settled-Order reconciliation were reported.
|
|
5
|
+
Full login/reboot and missing-result restoration are not established. See verification and limits (private historical evidence; not distributed).
|
|
6
|
+
The source review table below records the pre-change findings.
|
|
7
|
+
This plan precedes discussion of `./run update`; it does not authorize real funds,
|
|
8
|
+
new Orders, deletion of participant history, or widening Wallet authority.
|
|
9
|
+
|
|
10
|
+
## Required behavior
|
|
11
|
+
|
|
12
|
+
Start Runtime's safely configured local listener before asynchronous Order checks.
|
|
13
|
+
A historical business record, locked Wallet, unavailable network or old routing
|
|
14
|
+
format must not cause a restart loop. Report separately: process liveness,
|
|
15
|
+
self-check progress, Wallet availability/lock/Policy state, and purchase readiness.
|
|
16
|
+
An authenticated status view explains blockers and the next action without exposing
|
|
17
|
+
private input/output, signatures or credentials. Public health remains minimal.
|
|
18
|
+
|
|
19
|
+
This is not permission to listen without caller authentication, bind publicly,
|
|
20
|
+
overwrite a live socket/port, or ignore unsafe installation ownership. If the
|
|
21
|
+
listener itself cannot safely start (occupied port, missing/unsafe authentication
|
|
22
|
+
material), the CLI must explain repair; do not claim that every configuration can
|
|
23
|
+
produce a running HTTP server. Wallet capability failure may disable Wallet actions
|
|
24
|
+
without disabling an otherwise safely authenticated status listener.
|
|
25
|
+
|
|
26
|
+
Run local checks first, then reconcile eligible historical Orders in a bounded
|
|
27
|
+
background queue. Self-check does not prepare an Order, sign/submit a payment,
|
|
28
|
+
request service authorization, execute a Provider request, confirm receipt, cancel
|
|
29
|
+
an Order, or revoke/change Policy. These remain existing explicit invocation or
|
|
30
|
+
administrative flows. The existing Settlement workers own automatic closure/refund.
|
|
31
|
+
|
|
32
|
+
## Two independent outcomes
|
|
33
|
+
|
|
34
|
+
A financial terminal state (Released, Refunded or Cancelled) is separate from
|
|
35
|
+
verified local result availability. Delivered is not financial finality. A cached
|
|
36
|
+
result does not establish payout; payout does not establish that the client saved
|
|
37
|
+
or received the output. Store observations with source, identity and observed-at
|
|
38
|
+
epoch time; retain original invocation/request/Order identities and replay fences.
|
|
39
|
+
These are local projections, not new Protocol enums or rewritten wire states.
|
|
40
|
+
|
|
41
|
+
## Recovery matrix
|
|
42
|
+
|
|
43
|
+
| Observed condition | Startup self-check / permitted recovery | Purchase boundary and user action |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| No history in a genuinely new installation | Complete local inventory; inspect Wallet/configuration | Normal readiness still required. Missing history in a previously used installation is not proof of a new installation. |
|
|
46
|
+
| Wallet missing, stopped, locked or unbound | Keep Runtime available; expose specific dependency status; retry after dependency changes | No payment without Wallet's existing checks. Prompt start/unlock/setup as appropriate. Never save an unlock secret. |
|
|
47
|
+
| Settlement/network unavailable or maintenance | Keep last observation explicitly stale; retry boundedly with backoff | Do not claim finality or replay a payment. Unresolved affected calls wait. |
|
|
48
|
+
| Valid current history and verified cached result | Validate result binding; separately reconcile financial status | Same-call result reuse needs no new payment; report any pending financial check separately. |
|
|
49
|
+
| Invocation exists, no saved Order ID | Preserve orderRequestId and commitmentNonce; inspect what read APIs can establish | Lost prepare response may still mean an Order exists. Self-check must not call prepare as a substitute for read. Only original explicit resume may use its established idempotent path. |
|
|
50
|
+
| Signed payload saved, payment outcome unknown | Read original Order/funding evidence using saved identity | Neither paymentSubmitted false nor a timeout proves no funding. No replacement Order, nonce or signature generated by self-check. |
|
|
51
|
+
| Funded, not yet accepted | Observe acceptance/closure/deadlines | Do not cancel because Provider briefly goes offline. Existing user cancellation and Settlement timeout rules apply. |
|
|
52
|
+
| Accepted, still executing | Observe original Order and deadline | No new service execution in background. Resume original request explicitly; accepted service deadline remains authoritative. |
|
|
53
|
+
| Delivered, payout pending | Track finalization/refund/closure observations separately from output cache | No startup receipt acknowledgement or accelerated payout. |
|
|
54
|
+
| Released, verified result saved | Persist verified financial observation; retain result and request replay fence | Same request returns existing result where its format is supported; no purchase. |
|
|
55
|
+
| Released, result absent or incompatible | Record settled transaction and unavailable/unverified result separately | Do not rerun the service or fabricate output. Existing Provider result retrieval may be used only if supported by the original contract and authorization; otherwise explain limitation. |
|
|
56
|
+
| Refunded or Cancelled | Persist verified terminal observation, preserve request identities and any valid result evidence | Same request stays terminal, not a fresh purchase; refunds do not restore cumulative Policy spend. |
|
|
57
|
+
| Legacy routing record | Preserve original bytes, IDs and binding; reconcile independently of current call routing where authoritative identity is available | No automatic routingVersion addition or coercion into new service context. Known request stays fenced; terminal history need not block unrelated new calls once scope is safely known. |
|
|
58
|
+
| Corrupt/unknown schema, conflicting IDs, unsafe file or write failure | Preserve source; report repair needed; isolate only if records can be reliably identified | If affected scope is unknown, pause all new paid calls while status stays available. Never replace unreadable state with an empty store. |
|
|
59
|
+
| Order not found, chain/Factory/Policy/deployment changed | Keep unresolved; require matching original deployment and identity evidence | A 404 or wrong current deployment does not mean unpaid. Do not silently query new deployment as if it owned the old Order. |
|
|
60
|
+
| Local and authoritative observations conflict, or finality is insufficient | Preserve evidence and mark pending/review; recheck matching source | Do not pick a convenient terminal result or release replay protection. |
|
|
61
|
+
|
|
62
|
+
## Identity, authority and scope
|
|
63
|
+
|
|
64
|
+
Use Wallet's formal `readSettlementOrder` IPC and Settlement's Buyer-scoped read
|
|
65
|
+
endpoint; a normal User never reads server SQL or operator files. Today that HTTP
|
|
66
|
+
read requires a signed authentication request. Wallet locked means remote checks
|
|
67
|
+
wait for unlock; do not bypass authentication or add anonymous Order disclosure.
|
|
68
|
+
Signing a read authentication request is not payment signing.
|
|
69
|
+
|
|
70
|
+
Match Order ID, Buyer, chain, original Vault/Factory/Policy when available, service
|
|
71
|
+
reference and request hash. Persist only verified observations. For historical
|
|
72
|
+
records whose deployment facts cannot be recovered reliably, report the gap rather
|
|
73
|
+
than guessing. Optional independent chain verification must use the exact original
|
|
74
|
+
identity and existing finality policy; changing chain rules is outside this plan.
|
|
75
|
+
|
|
76
|
+
The participant's one legacy Order has independently observed Released state and
|
|
77
|
+
zero Vault balance on private Anvil. This proves the scoped chain observation,
|
|
78
|
+
not client result availability or a fresh Settlement database reconciliation.
|
|
79
|
+
Do not hard-code that Order or the reference random service into implementation.
|
|
80
|
+
|
|
81
|
+
Until initial inventory establishes a trustworthy replay boundary, block new paid
|
|
82
|
+
calls. After inventory, isolate known affected requests; allow unrelated requests
|
|
83
|
+
only when duplicate-payment scope is reliably bounded and normal Wallet/Settlement
|
|
84
|
+
readiness passes. Global pause remains valid for unreadable/conflicting history.
|
|
85
|
+
An explicit new user request (`--force`) is not an automatic recovery fallback.
|
|
86
|
+
|
|
87
|
+
## Concurrency, persistence and scheduling
|
|
88
|
+
|
|
89
|
+
- One self-check scheduler per Runtime; bounded batch/concurrency and timeouts,
|
|
90
|
+
capped retry backoff with jitter. Wake on restart and dependency recovery;
|
|
91
|
+
no unbounded timers, pending promises or frequent polls of confirmed terminal Orders.
|
|
92
|
+
- Serialize background observations with foreground invocation updates. A stale
|
|
93
|
+
read must not overwrite a newer outcome; merge observation metadata without
|
|
94
|
+
mutating immutable request/Order/payment identities.
|
|
95
|
+
- Persist recovery observations atomically and durably. Crash during checking,
|
|
96
|
+
writing or restart resumes the same work. No archival or format migration that
|
|
97
|
+
opens a window for a known invocation ID to become a new purchase.
|
|
98
|
+
- Do not remove replay fences/results on terminal detection or introduce indefinite
|
|
99
|
+
new copies of private payloads. Any archive schema/retention change is reviewed
|
|
100
|
+
separately; preserve existing source history in the first implementation.
|
|
101
|
+
- Stop scheduling on shutdown and bound outstanding calls. Status counts distinguish
|
|
102
|
+
checked, waiting on dependency, unsettled and needs-review; no misleading all-clear
|
|
103
|
+
based solely on an empty queue or a successful `/health` response.
|
|
104
|
+
|
|
105
|
+
## Source review: existing coverage and gaps
|
|
106
|
+
|
|
107
|
+
| Component / source | Existing behavior | Required work |
|
|
108
|
+
| --- | --- | --- |
|
|
109
|
+
| User `src/index.mjs` startup | Calls requireCurrentRouting before server.listen; initial Wallet credential failures also exit | Decouple safe listener from business checks and expose authenticated readiness/status. |
|
|
110
|
+
| User `src/invocation-store.mjs` | Whole-document validation, durable IDs and atomic saves; legacy mismatch fences repeats | Add read-only inventory and bounded isolation without weakening begin/update checks; choose storage evolution explicitly. |
|
|
111
|
+
| User `src/invocation-result.mjs` | Independently persisted verified results; binding checks | Keep output status distinct from money; inspect cached-result conflicts without erasing records. |
|
|
112
|
+
| User `src/index.mjs` invocation path | Reads original Order on active recovery; saves result before HTTP success; no background reconciliation | Add independent read-only scheduler and serialize observations with invocation writes. |
|
|
113
|
+
| User `src/order-closure.mjs` | Fences cancellation/refund/closure; does not treat Released as result availability | Define terminal financial classification for background work; preserve valid cached output. Review Released-without-result continuation explicitly. |
|
|
114
|
+
| Wallet `src/ipc.ts`, `src/settlement-http.ts` | Bounded authenticated Order reads; signing requires unlock | Reuse current authority; expose waiting-for-unlock clearly. No generic signing or new secrets. |
|
|
115
|
+
| Settlement `src/agentpay-order-preparation-store.mjs` | Buyer-scoped Order projection, deadlines, closure/finalization and delivery evidence | Verify existing projection covers legacy/terminal reads. Read-by-orderRequestId and old-Policy access are gaps to assess, not assumed supported or newly authorized endpoints. |
|
|
116
|
+
| User lifecycle/status and installer | systemd supervision, lock status, preserved settings; no complete upgrade inventory | Add readiness presentation and preflight before disruptive upgrade actions. Defer update orchestration until this recovery loop is closed. |
|
|
117
|
+
|
|
118
|
+
## Implementation and acceptance order
|
|
119
|
+
|
|
120
|
+
1. **Safe startup and local inventory.** Separate liveness/readiness, retain replay
|
|
121
|
+
fences, classify legacy/corrupt/current records and dependency failures. Test
|
|
122
|
+
the actual process starts with a valid secure listener despite old history;
|
|
123
|
+
affected/unknown-scope paid calls are fenced and state bytes remain unchanged.
|
|
124
|
+
2. **Read-only Order reconciliation.** Use formal authenticated reads, independent
|
|
125
|
+
financial/result observations, durable writes, bounded retries and concurrency.
|
|
126
|
+
Test all matrix branches including absent Order ID, wrong identity, locked Wallet,
|
|
127
|
+
maintenance, incomplete funding, terminal state and conflicting cache. Any shared
|
|
128
|
+
API/storage change requires consumer review before implementation.
|
|
129
|
+
3. **Recovery and upgrade handoff.** Present actionable status in `./run status`
|
|
130
|
+
and install/setup; verify restart during scans/writes, race with active calls,
|
|
131
|
+
repeated restarts and no duplicate payment. Preserve known request IDs through
|
|
132
|
+
any approved legacy handling. Use maintained fixtures with at least two business
|
|
133
|
+
payloads and official connectivity material only.
|
|
134
|
+
4. **Participant acceptance.** Re-read the supplied desktop record, reconcile with
|
|
135
|
+
matching authority, and verify Runtime stays running, old request cannot trigger
|
|
136
|
+
a new purchase, and Wallet lock/unlock does not restart Runtime. Additional paid
|
|
137
|
+
acceptance needs explicit scope; do not rerun connectivity purchase automatically.
|
|
138
|
+
|
|
139
|
+
Each loop gets focused tests and evidence before the next. Mock tests do not prove
|
|
140
|
+
real process restart, chain settlement or participant usability. `./run update`
|
|
141
|
+
remains a subsequent design discussion, not part of this implementation approval.
|