# Order Sidera project memory through x402

Send supported LLM session logs as one `tar.zst` archive. Sidera measures the original JSONL bytes, returns the exact price and approximate processing time, and requests payment only after you review that measured quote.

The delivered files are **`memory.md` and losslessly compressed original logs `raw.tar.zst`**. Use the [agent usage guide](USAGE.md) to search the memory and follow its source references.

The public API base is:

```text
https://shadowharness.com
```

## 1. Prepare one input archive

Put 1–10,000 original JSONL session files under the matching source directory:

```text
raw/claude/<session>.jsonl
raw/ext-codex/<session>.jsonl
raw/ext-grok/<session>.jsonl
raw/ext-gemini/<session>.jsonl
```

Create one Zstandard-compressed tar archive:

```bash
tar --zstd -cf input.tar.zst raw
```

ZIP files, multiple archives, links, sparse files and other paths are not accepted. Each filename must start with an ASCII letter or digit, contain only letters, digits, `_`, `.`, or `-`, and end in `.jsonl`.

You may request a free size estimate before creating an order. This does not reserve capacity or determine the bill:

```http
GET https://shadowharness.com/v1/quote?bytes=100000000
```

## 2. Create a private order

Generate a secret random `request_key` with at least 128 bits of entropy, encoded as 32–128 URL-safe letters, digits, `_`, or `-`. Keep it private. Send it with the email address that should receive the order confirmation:

```http
POST https://shadowharness.com/v1/orders
Content-Type: application/json
```

```json
{
  "request_key": "EXAMPLE_ONLY_GENERATE_A_NEW_RANDOM_SECRET",
  "email": "buyer@example.com"
}
```

A new order returns HTTP 201 with `state: "uploading"` and an `upload_deadline_at` 60 minutes ahead; complete the upload before then, or the request expires and a new one is required. Save the `order_id`, private `order_token`, `upload_url`, `payment_url`, `status_url` and `cancel_url`. Repeat the same `request_key` and email to recover a lost receipt; do not create a second order.

## 3. Upload for measurement

Upload the archive with the order token:

```http
PUT <upload_url>
Authorization: Bearer <order_token>
Content-Type: application/zstd

<input.tar.zst bytes>
```

The server safely expands the archive and measures the original JSONL bytes and SHA-256 values. A successful measurement returns HTTP 200 with `state: "awaiting_payment"`, including:

- `input.original_bytes` and `input.compressed_bytes`
- `pricing.price`, `pricing.billable_mb` and the applied rate
- `delivery.estimated_duration_seconds.{min,max}`
- `quote.expires_at` and `quote.valid_for_seconds`

Billing uses decimal MB: 1 MB = 1,000,000 original bytes. The whole order is rounded up once to the next MB. Compression does not lower the measured billable size.

## 4. Review the quote and pay through x402

The measured quote is valid for 60 minutes. If you cancel or do not submit payment before expiry, Sidera deletes the uploaded data and order workspace and returns the worker to the pool. A new request and upload are then required. A payment already being settled is retained until its outcome is known.

Request the x402 challenge from the order's own payment URL:

```http
POST <payment_url>
Content-Type: application/json

{"request_key":"<same request_key>"}
```

The HTTP 402 response supplies a `PAYMENT-REQUIRED` header and an `accepts[]` list. Select one USDC option on **Base, Polygon or Solana**. Check the amount, network, `terms_sha256`, pricing, processing estimate and quote expiry before signing. Use an x402-capable wallet or agent to create `PAYMENT-SIGNATURE`, then repeat the same POST with that header.

Successful settlement returns HTTP 201 and starts processing. HTTP 202 with `settling` or `payment_review` means the payment outcome is still being checked; do not pay again.

After settlement, Sidera emails the order ID, amount, network, transaction ID, approximate completion window, order-specific status API and support instructions. Mail delivery is retried without stopping paid processing.

## 5. Check progress and download both files

Poll at the interval returned by the API, currently 60 seconds:

```http
GET <status_url>
Authorization: Bearer <order_token>
```

Each order has its own status URL and token. Keep the token private. Status checks do not require another payment.

When `state` is `done`, the response contains authenticated artifact URLs for `memory.md` and `raw.tar.zst`. Download both with the same Bearer token and compare their byte sizes and SHA-256 values with `artifacts[]`.

After both checks pass, acknowledge delivery by sending the exact two name-to-hash pairs:

```http
POST <delivery_receipt_url>
Authorization: Bearer <order_token>
Content-Type: application/json
```

```json
{
  "memory.md": "<SHA-256 from artifacts[]>",
  "raw.tar.zst": "<SHA-256 from artifacts[]>"
}
```

Download and acknowledge within 24 hours after processing completes. On acknowledgement, or at the end of that window, the worker is deleted after the two artifacts have been verified. Recovery data is kept for seven days and then permanently deleted. It is not available through a public API. To request it during that period, email **shadowharness@gmail.com** from the same address used to place the order and include the exact order ID; requests from another address are not accepted.

The raw archive includes `USAGE.md`, `raw-archive.mjs`, and each logical original beside its `.sidera` compressed frames and index. Keep these together so source byte ranges from `memory.md` remain drillable.

## Cancellation and recovery

- Before payment, `POST <cancel_url>` with the Bearer token deletes the uploaded input and resets the worker.
- A wallet window closing or a rejected signature does not notify the server; the measured quote expires after 60 minutes instead.
- If a payment response is lost, retry with the same request key and original payment signature. Do not sign and pay again.
- If paid processing reaches `failed`, `POST <status_url>/retry` with the Bearer token retries processing without another payment.
- If no worker is available, the gateway returns HTTP 503 `no_available_worker` with `Retry-After: 60`; retry the same request key after that interval.
- Once an order's worker has been retired (after an expired unpaid order, or after delivery), its URLs answer HTTP 410 with `order_expired` or `order_retired`.

For trouble or delays, email **shadowharness@gmail.com** with the order ID and transaction ID. Do not include the private order token.
