Retrieval Packing Displacement
by Packing displacement analysis in Onchain & crypto
Compare strict rank-prefix packing with rank-order greedy-fit and score-density greedy-fit for up to 64 passages under a 1–2048 token budget. Report evidence displacement and optional observed selection violations. Uses declared integer costs/scores; no tokenization or causal attribution. New modular adapter: retained result recovery for 24 hours, minimal receipt metadata for 90 days. Existing live route unchanged.
https://www.mahastrategies.com/api/v1/context/retrieval/packing-displacement- Price
- $0.075
- per call in USDC
- Uptime
- 100%
- last 30 days
- Response time
- 222 ms
- 552 ms slowest 5%
- Last check
- Passed
- 37 min ago, next any minute now
Reliability
Status and outage history · Atom feed · Watch with other listings
How to call it
POST https://www.mahastrategies.com/api/v1/context/retrieval/packing-displacement
Each call costs $0.075 in USDC on Base, paid with the request over x402.
Run a free test callOne unpaid request, the way an agent sends it. You see the payment challenge it gets back. Nothing is charged.
Example request
From the listing.
POST https://www.mahastrategies.com/api/v1/context/retrieval/packing-displacement
content-type: application/json
{
"budget": 8,
"candidates": [
{
"evidenceIds": [
"e1"
],
"passageId": "p1",
"rank": 1,
"score": 9,
"tokens": 6
},
{
"evidenceIds": [
"e2"
],
"passageId": "p2",
"rank": 2,
"score": 8,
"tokens": 5
},
{
"evidenceIds": [
"e2"
],
"passageId": "p3",
"rank": 3,
"score": 3,
"tokens": 2
}
],
"dataClass": "synthetic",
"observedSelectedPassageIds": null,
"requiredEvidenceIds": [
"e1",
"e2"
]
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
budget | integer | Yes | |
candidates | array | Yes | |
dataClass | string | Yes | One of: public, synthetic. |
observedSelectedPassageIds | array or null | Yes | |
requiredEvidenceIds | array | Yes |
Example response
The provider's example. We can't check it without paying.
Example response, 74 lines
{
"data": {
"chargedAmount": "75000",
"inputHash": "sha256:dca4136fd984b5a0cd6170947e2b89cf4f9a472443ac80e7b00623a80…",
"limitations": [
"Public or synthetic inputs only. Caller labels are declarations,…"
],
"productId": "packing-displacement-analysis",
"result": {
"budget": 8,
"causalityEstablished": false,
"dataClass": "synthetic",
"densityDisplacedPassageIds": [
"p1"
],
"densityGreedy": {
"coverageBps": 5000,
"coveredEvidenceIds": [
"e2"
],
"selectedPassageIds": [
"p2",
"p3"
],
"totalScore": 11,
"usedTokens": 7
},
"greedyAddedPassageIds": [
"p3"
],
"greedyFit": {
"coverageBps": 10000,
"coveredEvidenceIds": [
"e1",
"e2"
],
"selectedPassageIds": [
"p1",
"p3"
],
"totalScore": 12,
"usedTokens": 8
},
"greedyRecoveredEvidenceIds": [
"e2"
],
"inputSha256": "sha256:dca4136fd984b5a0cd6170947e2b89cf4f9a472443ac80e7b00623a80…",
"limits": [
"Public/synthetic is a caller declaration, not content inspection…"
],
"observedSelection": null,
"rankPrefix": {
"coverageBps": 5000,
"coveredEvidenceIds": [
"e1"
],
"selectedPassageIds": [
"p1"
],
"totalScore": 9,
"usedTokens": 6
},
"resultSha256": "sha256:45a542ef56b8f1a295b2ca7ab633aa121d2a07a6dd811984bd941498e…",
"sourcesVerified": false
},
"resultHash": "sha256:e26397a7364ab35452088a2f4f61ef63d24abae672c9779f5a34dfd67…",
"sourceContractAmount": "78000",
"version": "maha-legacy-adapter/1"
},
"proof": {
"settlement_id": "0x00000000000000000000000000000000000000000000000000000000000000…"
},
"success": true
}Call it from code
The curl command shows the payment challenge. The JavaScript and Python versions pay and call, and never pay more than $0.075.
curl: see the payment challenge
# bash or zsh: see the payment challenge. Nothing is charged.
curl -sS -g -i -X POST 'https://www.mahastrategies.com/api/v1/context/retrieval/packing-displacement' \
-H 'content-type: application/json' \
--data-raw '{"budget":8,"candidates":[{"evidenceIds":["e1"],"passageId":"p1","rank":1,"score":9,"tokens":6},{"evidenceIds":["e2"],"passageId":"p2","rank":2,"score":8,"tokens":5},{"evidenceIds":["e2"],"passageId":"p3","rank":3,"score":3,"tokens":2}],"dataClass":"synthetic","observedSelectedPassageIds":null,"requiredEvidenceIds":["e1","e2"]}'
# x402 v2 sends the challenge base64-encoded in the PAYMENT-REQUIRED header (v1 sends it in the body).
# To read the header:
curl -sS -g -o /dev/null -D - -X POST 'https://www.mahastrategies.com/api/v1/context/retrieval/packing-displacement' \
-H 'content-type: application/json' \
--data-raw '{"budget":8,"candidates":[{"evidenceIds":["e1"],"passageId":"p1","rank":1,"score":9,"tokens":6},{"evidenceIds":["e2"],"passageId":"p2","rank":2,"score":8,"tokens":5},{"evidenceIds":["e2"],"passageId":"p3","rank":3,"score":3,"tokens":2}],"dataClass":"synthetic","observedSelectedPassageIds":null,"requiredEvidenceIds":["e1","e2"]}' \
| grep -i '^payment-required:' | cut -d' ' -f2 | tr -d '\r' | base64 --decodeJavaScript: pay and call
// npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
// Pays at most $0.075 per call.
const client = new x402Client().setSpendControls({ maxAmountPerPayment: "$0.075" });
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const pay = wrapFetchWithPayment(fetch, client);
// Not sure it's safe to pay? ToolVet checks it first for $0.005. Pay for that from a separate
// client: this one is capped at $0.075 per payment. GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fwww.mahastrategies.com%2Fapi%2Fv1%2Fcontext%2Fretrieval%2Fpacking-displacement&method=POST
const res = await pay("https://www.mahastrategies.com/api/v1/context/retrieval/packing-displacement", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
"budget": 8,
"candidates": [
{
"evidenceIds": [
"e1"
],
"passageId": "p1",
"rank": 1,
"score": 9,
"tokens": 6
},
{
"evidenceIds": [
"e2"
],
"passageId": "p2",
"rank": 2,
"score": 8,
"tokens": 5
},
{
"evidenceIds": [
"e2"
],
"passageId": "p3",
"rank": 3,
"score": 3,
"tokens": 2
}
],
"dataClass": "synthetic",
"observedSelectedPassageIds": null,
"requiredEvidenceIds": [
"e1",
"e2"
]
}),
});
console.log(res.status, await res.text());Python: pay and call
# pip install "x402[requests,evm]"
import os
from eth_account import Account
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client
# Pays at most $0.075 per call.
client = x402ClientSync().set_spend_controls({"max_amount_per_payment": "$0.075"})
register_exact_evm_client(client, EthAccountSigner(Account.from_key(os.environ["EVM_PRIVATE_KEY"])))
with x402_requests(client) as session:
res = session.post(
"https://www.mahastrategies.com/api/v1/context/retrieval/packing-displacement",
json={
"budget": 8,
"candidates": [
{
"evidenceIds": [
"e1",
],
"passageId": "p1",
"rank": 1,
"score": 9,
"tokens": 6,
},
{
"evidenceIds": [
"e2",
],
"passageId": "p2",
"rank": 2,
"score": 8,
"tokens": 5,
},
{
"evidenceIds": [
"e2",
],
"passageId": "p3",
"rank": 3,
"score": 3,
"tokens": 2,
},
],
"dataClass": "synthetic",
"observedSelectedPassageIds": None,
"requiredEvidenceIds": [
"e1",
"e2",
],
},
)
print(res.status_code, res.text)Security scan
No findings
We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.
Recent checks
| When | Result | HTTP | Time | Price |
|---|---|---|---|---|
| 37 min ago | Passed | 402 | 257 ms | $0.075 |
| 5 h ago | Passed | 402 | 552 ms | $0.075 |
| 10 h ago | Passed | 402 | 378 ms | $0.075 |
| 15 h ago | Passed | 402 | 185 ms | $0.075 |
| 19 h ago | Passed | 402 | 222 ms | $0.075 |
Show 3 older checks
| 24 h ago | Passed | 402 | 237 ms | $0.075 |
| 28 h ago | Passed | 402 | 221 ms | $0.075 |
| 32 h ago | Passed | 402 | 192 ms | $0.075 |