Skip to content

feat(be): open the TEE Explorer report already verified, no pasting (#277) - #279

Merged
Lexirieru merged 2 commits into
mainfrom
feat/be-tee-explorer-link
Nov 12, 2026
Merged

Lexirieru merged 2 commits into
mainfrom
feat/be-tee-explorer-link

Conversation

@Lexirieru

Copy link
Copy Markdown
Contributor

Backend part of #277. "Paste the quote in TEE Explorer" can open a report that already reads VERIFIED, so nobody pastes anything.

Why

  • Pasting "Copy the proof" into https://proof.t16z.com answers "The quote is invalid": the Explorer takes only the Intel quote hex.
  • The Explorer has no URL that prefills a quote. Its own Verify button calls POST /api/upload, multipart file = the quote's bytes, then opens /reports/<checksum>. That API sends no CORS headers, so the FE can't call it.

What

  • POST /v1/runs/{runId}/proof/tee-explorer, owner only:
    • Takes each Intel quote in the run's stored proofs, one per attestation, and uploads the bytes.
    • Answers { runId, reports: [{ attestation, kind, url, verified }] }.
  • apps/be/src/teeExplorer.ts:
    • One upload per quote, kept in memory.
    • Only accepts a 64-hex checksum before it goes into a link; 20 s timeout, no redirects.
    • TEE_EXPLORER_URL (default https://proof.t16z.com).
  • Errors: 404 no_proof; 503 tee_explorer_unreachable / tee_explorer_error (never 502, per apps/be/CLAUDE.md); 422 not_a_quote.
  • Only the quote leaves: NEAR AI's hardware report and nonce, never conversation text. An uploaded report shows in the Explorer's public "Recent attestations", as it would if the owner pasted it.
  • Docs: apps/be/CLAUDE.md, apps/be/.env.example, docs/api-contract.md.

Tests (local)

  • bun run typecheck: passes.
  • bun run test: 134/134 (1 opt-in AgentMail live test skipped). New tests against test/fake-explorer.ts:
    • the quote's bytes are uploaded, once;
    • a second click reuses the link;
    • another user gets 404, a run without a proof gets 404 no_proof, GET gets 405;
    • an Explorer that's down gets 503 tee_explorer_error.
  • bun run load: 0 errors, 1525 runs stored, 0 missing events, approvals and Telegram checks all clean.
  • Real Explorer: calling the route from a local try-out session for a Payments Mind run returned verified: true and https://proof.t16z.com/reports/1b374e5b…, the report Axel opened by hand: VERIFIED, nonce …99e266, compose hash matching our proof.

For @AncungAulia (FE, View proof dialog)

  1. On click of "Paste the quote in TEE Explorer", open the tab first: const w = window.open('', '_blank').
  2. Then POST /v1/runs/{runId}/proof/tee-explorer and set w.location = reports[0].url. If it fails, w.close() and fall back to today's link with "Copy the Intel quote".
  3. Suggested label: "Check it in TEE Explorer".

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e

Lexirieru and others added 2 commits November 12, 2026 22:05
POST /v1/runs/{runId}/proof/tee-explorer uploads the Intel quote(s) in the
run's stored proof to Phala's TEE Attestation Explorer through its own
POST /api/upload and answers the report links. The Explorer has no prefill
URL and no CORS, so the FE couldn't do it, and pasting "Copy the proof"
answered "The quote is invalid". One upload per quote; owner only; an
Explorer failure answers 503.

Tests: bun run test 134/134 (fake Explorer: the quote's bytes uploaded once,
second click reused, other user 404, no proof 404, Explorer down 503);
bun run load: 0 errors, 0 runs missing events; one real upload from a local
run returned verified: true and the report link the owner checked by hand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
@Lexirieru
Lexirieru merged commit 8579686 into main Nov 12, 2026
1 check passed
@Lexirieru

Copy link
Copy Markdown
Contributor Author

Merged with Axel's approval; main deploys after its CI.

Checked in Chrome before the merge, on a local stack with the real Explorer:

  • A fresh Payments Mind run (new attestation) went through the route: 200 in 1.2 s with verified: true.
  • The link it returned (https://proof.t16z.com/reports/9618de8a…) opened to VERIFIED, "The attestation is verified and safe to use".

@AncungAulia the route is live after this deploy. The FE part of #277 is yours:

  1. On click of "Paste the quote in TEE Explorer" (maybe rename it "Check it in TEE Explorer"), open the tab first: const w = window.open('', '_blank'). This must happen in the click handler itself, or popup blockers stop it.
  2. Then POST /v1/runs/{runId}/proof/tee-explorer (body {}) and set w.location = reports[0].url.
  3. On an error (503 tee_explorer_unreachable / tee_explorer_error, 404 no_proof), w.close() and keep today's link plus "Copy the Intel quote".
  4. To test: send any message to a Mind, open View proof, click the link. A new tab should land on a VERIFIED report, and its nonce should match the one in the dialog.

@Lin1er no env change needed on the box; TEE_EXPLORER_URL defaults to https://proof.t16z.com.

@Lin1er

Lin1er commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

@Lexirieru read the backend diff; looks good to me. Same route and shape as my feat/be-tee-explorer (58de954, see #277), so I'll treat that branch as superseded by this PR and won't open a PR for it.

Checked by reading the diff (tests not re-run by me; CI be was still running):

  • Owner check comes from the existing getRun(user.id, …) path, so another user gets 404 run_not_found before any upload.
  • Only the Intel quote bytes go out; the checksum is checked as 64-hex before it goes into the link; 20 s timeout, redirect: 'error', upstream failures answer 503.

Small nits, none blocking:

  • docs/api-contract.md lists the errors but not 422 not_a_quote (the PR body and teeExplorer.ts have it).
  • A run with several attestations: one malformed quote turns the whole answer into 422, while the others would have worked. Fine for now, since gateway quotes are well-formed.

Also: #278 (7ccfc39) is live; the try-out e2e passed 22/22 after the deploy, and the be/engine/fe/landing services are active.

@Lin1er

Lin1er commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Live on the hosted demo: main 8579686 (automatic deploy after the merge).

  • Before: 7ccfc39, and the box matched git at that revision. CI: passed: test.
  • GET /v1/health → {"ok":true,"engine":true,"revision":"8579686"}. No rollback.
  • Rollback target: 7ccfc39 (/opt/hellonear/release-old).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants