Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 38 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,39 @@ Best-execution routing across Jupiter Perps, Pacifica, Drift, and Flash Trade.

Your agent decides. Toreva executes. Every action receipted.

## Agentic perps setup
## Establish your wallet

Use `toreva_establish` before perps execution when an agent needs delegated
authority for a human wallet. The standard perps pattern is:
Use `toreva_establish` to attach a policy-controlled delegated authority to
your Solana wallet. Your wallet stays the root owner — Toreva creates a bounded
session key that enforces spend caps, allowed-token constraints, and revocation
policy. Non-custodial: Toreva never holds private key material. Every
establishment is receipted.

```text
human wallet
-> Toreva/Swig master authority
-> venue-specific child capability
-> Pacifica API agent wallet when Pacifica is selected
```bash
# Minimum — attach delegated authority to your wallet
toreva_establish({ walletAddress: "your-wallet-address" })
```

The human wallet remains the root owner. The Swig authority is the policy and
capital-management control layer. Pacifica uses a separate API agent wallet
because Pacifica REST orders require an on-curve Ed25519 signer. Toreva can
create, bind, fund, route, monitor, and revoke that child capability through
Toreva surfaces; the user does not need to open Pacifica.
Once established, your agent can execute across all supported primitives —
earn, perps, and more — without re-authenticating for each operation.

For best execution, omit `venue` on `toreva_perps_long` or
`toreva_perps_short`. Toreva will compare enabled venues and route by estimated
all-in cost. Set `venue` only when you intentionally want a specific venue.
Perps tools use the Gateway MCP field contract: `walletAddress`, `token`,
`sizeUsd`, `leverage`, `collateralToken`, and `collateralAmount`.
## Earn

The public integration packet lives in this repo:
Deploy idle USDC to yield across supported venues with `toreva_earn`. Scan,
compare, and execute from a single tool.

- [Agentic perps integration patterns](./docs/agentic-perps-integration-patterns.md)
- [OpenAPI-style relay examples](./docs/toreva-perps.openapi.json)
- [Claude Code agent prompt](./docs/claude-code-agent-prompt.md)
```bash
npx toreva earn-compare --asset USDC --venue kamino
npx toreva earn-compare --asset USDC --venue marginfi
```

| Venue | Asset |
| --- | --- |
| Kamino Finance | USDC |
| Marginfi | USDC |

Every earn execution returns a read-evidence receipt, a venue-intelligence
receipt, and a sentinel review receipt.

## Install

Expand Down Expand Up @@ -114,6 +118,18 @@ truth for agent, SDK, CLI, Skills, and MCP integration details.

## Perps tools

Run `toreva_establish` first to attach a delegated authority before execution.
For best fill, omit `venue` — Toreva compares enabled venues and routes by
estimated all-in cost. Set `venue` only when you intentionally want a specific
venue. Perps tools use fields: `walletAddress`, `token`, `sizeUsd`, `leverage`,
`collateralToken`, and `collateralAmount`.

The public integration packet lives in this repo:

- [Agentic perps integration patterns](./docs/agentic-perps-integration-patterns.md)
- [OpenAPI-style relay examples](./docs/toreva-perps.openapi.json)
- [Claude Code agent prompt](./docs/claude-code-agent-prompt.md)

| Tool | Fee | What it does |
| --- | --- | --- |
| `toreva_perps_long` | 1 bps | Open long — routes to better fill |
Expand Down
79 changes: 79 additions & 0 deletions data/founder-narrative/goal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"schema_version": "coordinator.founder_narrative_fleet.goal.v1",
"goal_id": "founder-narrative:kit",
"agent": "kit",
"domain": "customer-external",
"repo": "/Users/paulbush/toreva_vs/kit",
"founder_narrative": {
"product_truth": "Toreva is a Solana-first finance app whose agent scans positions, compares DeFi opportunities, and prepares transparent ready-to-execute actions while users keep control.",
"user_pain": "Crypto holders are forced to choose between idle capital and high-friction manual DeFi work.",
"promised_outcome": "Strategic execution becomes as simple as a user-approved click, backed by receipts, costs, outcomes, and risk clarity.",
"operating_principle": "Raw computational intelligence with an elegant, approachable user experience: powerful, transparent, and controlled."
},
"standing_goal": "Implement the founder narrative inside this agent's bounded domain by finding and completing the highest-value next action that makes Toreva more tireless, transparent, user-controlled, Solana-capable, and commercially real.",
"six_minute_wake_question": "What is the highest-value bounded action I can take now to advance Toreva's founder narrative, reduce founder load, and create evidence another agent or Paul can use?",
"bounded_delegation": {
"must_respect_repo_charter": true,
"must_respect_agent_charter": true,
"must_respect_constitutions": true,
"forbidden_without_founder_resolution": [
"external spend",
"cloud migration or always-on compute expansion",
"custody, signing, key management, or movement of funds",
"legal/regulatory commitments",
"privacy-sensitive data expansion",
"material product or pricing commitments",
"creating new agents when an existing agent can be extended"
]
},
"collaboration": {
"model": "best_athlete_dispatch",
"required_behavior": [
"Answer pending peer dispatches before self-selected work unless a P0 safety issue blocks it.",
"Dispatch work to the best-scoped existing agent when that agent can do it better or more safely.",
"Challenge weak assumptions from peer agents with evidence, then disagree and commit after a bounded decision.",
"Do not silently expand scope; route boundary questions through EA and Notifications for founder email resolution."
]
},
"runtime_contract": {
"local_action_timebox_minutes": 4,
"acceptable_wake_actions": [
"complete a small repo-local implementation with tests and PR evidence",
"answer or unblock a pending peer dispatch with evidence",
"create a bounded action proposal or evidence artifact another agent can use",
"dispatch a scoped request to the best-athlete existing agent",
"record a boundary issue and route it through EA/Notifications for founder resolution"
],
"must_include_machine_evidence": true,
"oversized_work_rule": "If the highest-value action cannot be completed inside the local timebox, do not start an open-ended build; emit a concrete action proposal, dispatch the best athlete, or escalate the boundary issue with evidence."
},
"performance_incentives": {
"peer_response_reliability_weight": 40,
"founder_narrative_progress_weight": 25,
"evidence_quality_weight": 20,
"best_athlete_delegation_weight": 10,
"bounded_delegation_weight": 5,
"hard_penalties": [
"Ignoring or timing out peer requests without status.",
"Doing another agent's work instead of dispatching to the best athlete.",
"Claiming founder-narrative progress without evidence refs.",
"Crossing a bounded delegation or constitution gate without escalation."
]
},
"founder_escalation": {
"email": "paul@toreva.com",
"route": "notifications_and_ea",
"trigger_conditions": [
"A required decision exceeds the agent's delegation.",
"Two agents disagree on ownership or authority and cannot resolve it with charters.",
"A goal requires spend, custody/signing, external commitments, or legal/regulatory judgment.",
"A constitution or memory-governance conflict blocks progress."
],
"required_artifacts": [
"Write an RFC-822 email draft under data/founder-narrative/escalations/.",
"Dispatch Notifications to send the email to paul@toreva.com.",
"Dispatch EA with the founder decision brief and evidence refs."
]
},
"updated_at": "2026-06-05T09:37:31.627Z"
}
79 changes: 79 additions & 0 deletions data/founder-narrative/rollback-path-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"schema_version": "kit.rollback_path.v1",
"description": "Canonical rollback_path field definition for action packets. Describes how a user cancels or recovers without Toreva involvement.",

"schema": {
"rollback_path": {
"type": "object",
"required": ["method", "description", "non_custodial_note", "recovery_evidence_ref", "attested_by"],
"properties": {
"method": {
"type": "string",
"enum": ["user_initiated_withdrawal", "app_cancel", "timeout_expiry"],
"description": "Mechanism by which the action can be undone or funds recovered."
},
"description": {
"type": "string",
"description": "Human-readable summary of how the user cancels or recovers. Must be true without Toreva online."
},
"non_custodial_note": {
"type": "string",
"const": "Toreva does not hold private keys. User retains signing authority.",
"description": "Non-custodial invariant confirmation. Value is fixed."
},
"recovery_evidence_ref": {
"type": "string",
"description": "File path (relative to repo root) or URL to the kit recovery script or equivalent attestable artefact."
},
"attested_by": {
"type": "string",
"description": "Agent that verified non-custodial recoverability by reviewing the recovery_evidence_ref. Leave 'pending' until review complete.",
"examples": ["kit-agent", "risk-agent", "pending"]
}
}
}
},

"invariants": [
"rollback_path.method must be exercisable without Toreva being online or in the loop.",
"rollback_path.non_custodial_note value is fixed and must not be altered.",
"attested_by must not be a live agent name until recovery_evidence_ref contains no TODO placeholders.",
"For any action_packet labelled ready-to-execute, attested_by must be a named agent (not 'pending')."
],

"method_guidance": {
"user_initiated_withdrawal": "User calls venue protocol directly (e.g. Pacifica close-position + withdraw). Suitable for perps positions. Requires working recovery script with no TODOs.",
"app_cancel": "User taps 'Cancel' in Toreva app before execution is dispatched on-chain. Toreva must not have yet submitted the transaction. Suitable for pre-signed but unbroadcast actions.",
"timeout_expiry": "Action packet has an on-chain expiry; if user takes no action the packet lapses. Suitable for limit/conditional orders."
},

"populated_example": {
"_context": "DeFi rebalance recommendation — research/backtested variant (no live fund movement yet)",
"rollback_path": {
"method": "user_initiated_withdrawal",
"description": "User can close all Pacifica perp positions and withdraw margin directly via Pacifica's native API using only their wallet keypair. No Toreva endpoint is required. Steps: (1) run kit/examples/recovery/recovery.ts with walletKeypair + any public Solana RPC; (2) script closes open positions on-chain; (3) script withdraws margin balances to wallet. Toreva need not be online at any step.",
"non_custodial_note": "Toreva does not hold private keys. User retains signing authority.",
"recovery_evidence_ref": "kit/examples/recovery/recovery.ts",
"attested_by": "kit-agent"
},
"_attestation_evidence": "kit-agent resolved all 4 TODO placeholders (2026-06-05T13:35Z), pnpm typecheck 4/4 pass, dry-run trace 5/5 pass (Ed25519 sign+verify correct, base58 pubkey 44 chars, signature 64 bytes / 88 base64 chars, signed body structure correct, body signature verifies). PR #19 branch daemon/kit/rollback-path-schema-2026-06-05. See iam/intake/responses/2026-06-05-rollback-path-kit-dispatch.md for full trace.",
"_attestation_accepted_by": "iam-agent (2026-06-06): kit-agent is a named valid attestor per schema examples; all 6 preconditions in attestation_gate.preconditions_for_attestation verified by kit dry-run trace. Risk-agent review remains available as belt-and-suspenders."
},

"attestation_gate": {
"preconditions_for_attestation": [
"PACIFICA_PROGRAM_ID replaced with verifiable mainnet program ID (checkable on Solana explorer).",
"authenticateWithPacifica implements Pacifica's documented auth-challenge flow (GET /auth/challenge → sign nonce → POST /auth/verify or equivalent).",
"buildPacificaCloseInstruction builds from Pacifica's published IDL or SDK — no placeholder throws.",
"buildPacificaWithdrawInstruction same as above.",
"Script compiles with pnpm typecheck.",
"At least one integration test or a manual dry-run trace showing the auth + position-query path succeeds without Toreva endpoints."
],
"attestation_class": "not-class-a",
"attestation_class_rationale": "Pacifica program IDs are public on-chain data. Implementing against a public DEX protocol's documented API does not cross custody, revenue, legal, or product-model gates. Research step only — requires consulting Pacifica's public docs or on-chain registry."
},

"updated_at": "2026-06-06T00:00:00Z",
"authored_by": "kit-agent",
"attested_at": "2026-06-06T00:00:00Z"
}
1 change: 1 addition & 0 deletions data/runner-collaboration-ledger.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"collaboration_run_id": "collab:kit:2026-05-29-coordinator-toreva-momentum-mode-seven-survival-focus-areas.md", "critic_perspectives": [], "evidence": [{"kind": "response", "ref": "/Users/paulbush/toreva_vs/kit/intake/responses/2026-05-29-coordinator-toreva-momentum-mode-seven-survival-focus-areas.md"}, {"kind": "runner_log", "ref": "/Users/paulbush/toreva_vs/kit/data/runs/2026-05-29-coordinator-toreva-momentum-mode-seven-survival-focus-areas.md.stdout.log"}, {"kind": "runner_log", "ref": "/Users/paulbush/toreva_vs/kit/data/runs/2026-05-29-coordinator-toreva-momentum-mode-seven-survival-focus-areas.md.stderr.log"}], "mode": "primary_critic", "next_adjacent_actions": [], "primary_perspective": "kit@claude", "recorded_at": "2026-05-29T07:57:12Z", "response_certificate": {"acknowledged": true, "certification_basis": "failure_artifact", "certified": false, "in_progress": false, "issued_at": "2026-05-29T07:57:12Z", "outcome": "invalid_response", "owner_agent_id": "kit", "substantive_response": false}, "runner": {"attempts": 2, "duration_s": 258, "exit_code": 0, "name": "claude", "validation_code": "missing_summary"}, "schema": "toreva.kernel.runner-collaboration-ledger.v1", "task": {"task_class": "momentum-mode", "title": "Fallback Dispatch \u2014 Toreva Momentum Mode: Seven Survival Focus Areas"}, "transport": "filesystem"}
Loading