Skip to content

docs: add API contract between Flutter app and Serverpod - #77

Merged
moises-cisneros merged 2 commits into
mainfrom
docs/8-api-contract
Oct 5, 2026
Merged

moises-cisneros merged 2 commits into
mainfrom
docs/8-api-contract

Conversation

@TOMOKI977

@TOMOKI977 TOMOKI977 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #8

Rebased onto main (2026-10-05) and aligned with the escrow contract merged in #78 and #94: no set_budget step, approval window with a permissionless release, claim_refund only from Funded, fund parameters and fee snapshot, is_expired. Implements ADR-0005 (#72, merged).

This is the reference for the hire and pay implementation. The team chose the server relay (Decision A) for payments. #93 will be reworked to follow it.

Summary

Adds the contract between the Flutter app and Serverpod:

  • docs/architecture/api.md: endpoints, errors, relay and polling rules, response shapes, and the traceability from every MVP flow step (docs: MVP user flows #22) to an endpoint or client-only action.
  • docs/architecture/models/*.spy.yaml: draft Serverpod models (agent, hire, payment, feedback, skill, prepared transaction, chain submission, API exception).

Key decisions

  • A. Server relay. The client signs server-prepared unsigned XDR; the server verifies it matches what it prepared, persists the tx hash before submitting, submits, and polls durably. Submit methods never throw chain outcomes.
  • B. Polling now, streaming later. Polling is the MVP baseline; Serverpod streaming is the planned successor and must be additive (same shapes, states and error codes).
  • Escrow hire flow (ADR-0005).
    • Two client signatures: create_job (carrying token and budget), then fund. A Soroban transaction holds one contract invocation, so they cannot be combined without a non-standard call.
    • The client approves (complete) or rejects (reject) as evaluator, and can reject a submitted job only before approval_deadline. The agent's submit and the permissionless release and claim_refund are server-submitted.
  • Hire states mirror the escrow: open → funded → submitted → completed / rejected / expired.
    • A hire has no status until create_job confirms.
    • An unfunded job past expired_at is derived as expired.
    • runtimeStatus, rejectedFrom and feedbackReference are data, not states.
  • Refunds. After a runtime failure the client gets a one-step reject and refund. The fallback is claim_refund after expired_at.
  • Open questions reduced. P1 (manual review) now covers only funds sent outside the escrow; P2 becomes the job's expired_at. Timeout values come from config (ADR-0005 D3, deferred).

Acceptance criteria

Depends on / follow-ups

@TOMOKI977 TOMOKI977 added area: architecture System design, diagrams, contracts between layers type: docs Documentation deliverable labels Oct 2, 2026
@TOMOKI977 TOMOKI977 self-assigned this Oct 2, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Deploying puls3 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 88ffebd
Status: ✅  Deploy successful!
Preview URL: https://5496b698.puls3-4lw.pages.dev
Branch Preview URL: https://docs-8-api-contract.puls3-4lw.pages.dev

View logs

Define the Serverpod endpoints, models, errors, relay and polling rules for the MVP flows, aligned with the ERC-8183 escrow and hire states from ADR-0005.

Refs #8
Remove the server-signed setBudget step, since create_job carries token
and budget. Add the approval window and the permissionless release call,
restrict claim_refund to Funded, document fund parameters and the fee
snapshot, and reference is_expired.
@TOMOKI977

Copy link
Copy Markdown
Contributor Author

@moises-cisneros @XxHugheadxX @Pericena @fercodes @anahillanos474-max este PR es el que destraba el camino crítico de Stellar Elite (plan en #51): es la referencia para el relay de hire y pago (#96, #97) y para reconvertir #93. Ya está rebaseado sobre main y alineado con el escrow de #78 y #94. Necesita 1 aprobación para mergear. Si algo no cierra, dejen el comentario en la línea correspondiente de docs/architecture/api.md. ¡Gracias!

@moises-cisneros moises-cisneros left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excelente trabajo definiendo el contrato. Las decisiones sobre el Server Relay (Decisión A) y la sincronización de estados del Escrow nos dan una base recontra sólida (Concepts > Code).

@moises-cisneros
moises-cisneros merged commit 7bc7d20 into main Oct 5, 2026
8 checks passed
@moises-cisneros
moises-cisneros deleted the docs/8-api-contract branch October 5, 2026 21:05
Pericena added a commit that referenced this pull request Oct 8, 2026
Part B of the #109 split. Refs #27: the testnet end-to-end criterion
waits for the deploy endpoint (#18) and the relay (#96).

- DeployFlow + DeployFlowController: preparing -> waiting for signature
  -> registering on-chain -> activating -> live. Never runs twice,
  resumes from the failed step, keeps the prepared and signed
  transaction across a lost response, verifies every backend answer,
  and stops if the flow is closed mid-run.
- Presentational widgets: DeployStepper, phase card, error panel and
  success, with skeletons until values arrive.
- Errors with a recovery action and no reload: signature rejected,
  transaction failed, backend error, plus wallet unavailable, wrong
  network, account changed, connection lost/timeout, invalid response,
  expired preparation (prepares again) and a wallet that never answers
  (times out; the sheet can be closed while the wallet prompt is open).

Review fixes:
- The demo gateway is labelled: a banner says nothing is registered on
  Stellar, and the result reads "Demo deploy only" with no explorer
  link, no agent page and no made-up hash. Demo agents are not listed.
- WalletPort.signTransaction only signs and returns the signed XDR; the
  server submits (API contract #77, Decision A). MockWallet returns a
  marked signed placeholder instead of a hash.
- Real agents start at a 0.0 rating; explorer links use
  stellarExpertTxUrl; the unused SuccessPanel, DeployProgressView and
  AppScope.ids are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: architecture System design, diagrams, contracts between layers type: docs Documentation deliverable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: API contract between Flutter app and Serverpod

2 participants