Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
af0721d
feat(relayer): forward Mochi's sealed note to NEAR AI with plain-fiel…
dadadave80 Nov 13, 2026
597e781
build: package the sealed-note path beside the account endpoints
dadadave80 Nov 13, 2026
7e3e25b
test(relayer): type the sealed-note header cases
dadadave80 Nov 13, 2026
ce97d6b
feat(web): verify, encrypt and seal Mochi's note with the NEAR AI SDK
dadadave80 Nov 13, 2026
caf9256
feat(web): show Mochi's note on the latest accepted return behind VIT…
dadadave80 Nov 13, 2026
8052f2e
fix(note): cap GLM-5.3 Flash reasoning with thinking_token_budget 0
dadadave80 Nov 13, 2026
a2ce62f
chore(scripts): add a one-completion live sealed-note check
dadadave80 Nov 13, 2026
38b1fac
build: gate the sealed note behind an explicit production opt-in
dadadave80 Nov 13, 2026
f90e637
docs: record the sealed-note relay, live seal and NEAR AI discrepancies
dadadave80 Nov 13, 2026
2c5ecc8
fix(relayer): accept only compact canonical note JSON so duplicate ke…
dadadave80 Nov 13, 2026
4ceeed7
fix(note): keep the written note across later returns and stop over-c…
dadadave80 Nov 13, 2026
f92cc40
chore(scripts): report the encryption header actually sent upstream
dadadave80 Nov 13, 2026
78b0aa9
docs: record in-browser live seals and journey eligibility reads
dadadave80 Nov 13, 2026
c148a69
fix(relayer): allow note retries within a daily allowance and time ou…
dadadave80 Nov 13, 2026
bb4075b
fix(note): verify seals with the SDK's Ed25519 and keep unrecorded si…
dadadave80 Nov 13, 2026
f8417a2
fix(note): state only what each note established, keep focus on it an…
dadadave80 Nov 13, 2026
b87cda4
docs: describe unrecorded seals and SDK signature checks in the threa…
dadadave80 Nov 13, 2026
e483b43
docs: record the sealed-note review fixes
dadadave80 Nov 13, 2026
1bf4bdd
docs: keep progress rows in date order after rebase
dadadave80 Nov 13, 2026
42a4f32
fix(note): charge note allowances only when all pass and bound every …
dadadave80 Nov 13, 2026
4ecee1e
fix(note): keep a readable note when a retry fails and name late refu…
dadadave80 Nov 13, 2026
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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ TIDEBOUND_HTTP_ENABLED=false

# Harbor records panel (live public reads only). Off unless exactly "true".
VITE_RECORDS_ENABLED=false
# Optional server-only key for Mochi's sealed note (/api/v1/privy/note). Unset keeps that endpoint disabled.
NEAR_AI_API_KEY=
# Browser flag. Production builds enable it only when VITE_SEALED_NOTE_ENABLED is exactly true; previews never do.
VITE_SEALED_NOTE_ENABLED=false
2 changes: 2 additions & 0 deletions JUDGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Current Familiar has one playable Phaser edition. The introduction stays first;
| TypeScript/Rust spatial transitions agree | `make test` | Shared fixture, solver and replay tests |
| Every listed pet keyless on pinned global code; replayed-court state and one-time Shells for the test player; player and admin keys disclosed | `make judge` | Live public-RPC state of `familiar-game.testnet`, not proof of deployed code (root code differs from the HEAD build); reports key permissions, cannot see custody |
| Doctored courts (historical and current rules), repeat Shell grants and out-of-scope signing are refused | `make break` | HEAD source in the contract unit runtime plus signer unit tests; full Wasm sandbox stays `bun run test:tidebound-sandbox` |
| Mochi's sealed note: relay checks, E2EE v3 round trip (including NEAR AI's published Ed25519 vector) and the sealed/plain/broken decision | `bun test services/relayer/src/sealed-note.test.ts web/src/note` | Local key pairs and mocked NEAR AI responses; no network |
| A live note seals: attested model key, E2EE v3, provider_tee signature over `model:sha256(request):sha256(response)` | `NEAR_AI_API_KEY=<your key> bun scripts/sealed-note-live.ts` | Spends one NEAR AI completion; player identity and journey eligibility are local stand-ins. The claim is only "signed by the attested model key": NEAR AI instances share that signing key, so no single machine is identified |
| Actual contract compatibility and original-operation invariants | `bun run build:contracts`, then `bun run test:tidebound-sandbox` | Separate same-layout local-chain test; deployed-byte upgrade mode additionally requires all five frozen original Wasm artifacts |

Only two report JSON files remain:
Expand Down
12 changes: 12 additions & 0 deletions PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ Full earlier progress and acceptance records are preserved in the [archive](docs
| 2026-11-13 | Public repository and native Git connection established | https://github.com/dadadave80/familiar; GitHub branch-protection readback; existing-project Git link | User explicitly chose public visibility. Initial source23a576d uploaded to main; required PR checks, strict up-to-date main and admin enforcement enabled, force pushes/deletion disabled. Existing Vercel project linked to this repository without replacing encrypted environment or current public alias. This documentation PR is the end-to-end trigger check; its production result is not yet claimed here. |
| 2026-11-13 | Harbor records (Mochi’s papers, key line, Tidekeeper’s stamp, admin disclosure) behind `VITE_RECORDS_ENABLED`, default off | `bun run test` 246 pass; Rust 123 pass/2 ignored; `make build`; `make browser`; `make evidence`; `bun run test:records-browser` (Chromium only, 390×844/1440×900, mocked RPC, includes Check again keeping focus) | Each line comes from a public `finality: final` read and says “couldn’t be checked” when its read fails. Browser check intercepts RPC with shapes captured live from test.rpc.fastnear.com; a separate read-only Bun run of the same builder against live testnet (qa-maker-h1/qa-mochi-h1) returned no line as unchecked (records lines read; admin keys reported as findings). A Chromium page on a local origin fetched the public RPC directly (CORS allowed). Player key is reported as RPC lists it (currently FullAccess); no key changed. A real signed-in Privy session showing the panel is unverified. Flag-off build omits the records code. No push or deployment. |
| 2026-11-13 | `make judge` and `make break` added; NEAR claims table in README | `make judge` (live fastnear RPC, `familiar-game.testnet`): 16 PASS, 0 FAIL, all 4 pets from `nft_tokens`. `make break`: 7 Rust refusal/acceptance tests (first_light_v1 and v2) + 5 signer tests pass. Codex hostile review found 5 gaps (undefined-hash false PASS, hard-coded pet sample, v1-only court tests, snapshot-vs-code and custody overclaims); all fixed. Full `make check`: 235 Bun tests, 130 Rust passes, typecheck; `make evidence` 15 signatures offline | Judge confirms every pet has no keys and run global code `CQQ63d8…` = `get_config.pet_code_hash`; `qa-maker-h1` has 2 accepted claims and 12 Shells granted once. Reported, not claimed: player keys are FullAccess (Privy-held), the method limit is the off-chain signer; root/items keep FullAccess admin keys; deployed root code `66HumWXu…` differs from the HEAD build `4xtG2991…` recorded in FAMILIAR-GAMEPLAY.json. `.env` NEAR_ROOT still names the older `familiar-1105-28522e` stack; judge does not read `.env`. Threat model now states replay proves legal steps only, winning inputs are public, and one pet passed between accounts earns each account a commission. `make break` uses the contract unit runtime, not the Wasm sandbox. No deploy, no signing, no push. |
| 2026-11-13 | Mochi's sealed note on local branch `feat/sealed-note` (flagged off) | `bun run test` 247 pass/15685 assertions; `cargo test --manifest-path contracts/Cargo.toml --workspace` 123 pass/2 ignored; `make build`, `bun run build:release`, `make browser` (Chromium/WebKit), `make evidence` (15 signatures) pass; mocked note UI viewed at 390×844 and 1440×900; `bun --env-file=<main checkout .env> scripts/sealed-note-live.ts` | Live 2026-11-13: keyless `GET /v1/model/z-ai%2Fglm-5.3-flash` → `providerType:vllm, attestationSupported:true`; keyless `GET /v1/attestation/report` (ed25519, fresh nonce, `x-no-aliasing`) → 200 with 3 instances sharing key `5a0210f2…0caff`, all verified by SDK 0.3.0 (`UpToDate`, GPU evidence required); CORS allows the production origin. Three live completions with `X-Encryption-Version: 3`: chats `8af36ee4753d4228994b34ee1a8183ab` and `f63baa0caeb549f4932deb02daa59745` were broken (GLM spent all 120 tokens reasoning, `finish_reason:length`, empty content, despite `chat_template_kwargs.enable_thinking:false`); after switching to `thinking_token_budget:0`, chat `daa6b15838fc402689766a28b7826446` returned `provider_tee`, decrypted and **sealed**. Then the real `writeSealedNote` ran inside Playwright Chromium and WebKit (SDK default browser verifiers via NEAR AI's PCCS/NRAS proxies, WebCrypto Ed25519) against the relay code in-process: chats `20d3c9c6263b42edac0533dd02eb89d4` (Chromium) and `d8b367f524824d53ad99bb8f2849d736` (WebKit) both **sealed**, and the note stayed attached after a later accepted return. Five live completions in total. Read-only testnet views: `tidebound_journey` on `familiar-game.testnet` returns `claims` (qa-maker-v2: 2, dadadave80: 0) and `rpcNoteChain` reads them; unregistered keys resolve to no player. Eligibility/identity in the live runs were local stand-ins; no Privy JWT, deployed relay or Vercel variable was exercised. The in-game satchel with the flag on was not viewed; the note component was viewed standalone with mocked results and in the live browser run. No push or deployment. |
| 2026-11-14 | Sealed-note review fixes on `feat/sealed-note` (still flagged off) | `bun run typecheck`; `bun run test` 250 pass/15699 assertions; `cargo test --manifest-path contracts/Cargo.toml --workspace` 123 pass/2 ignored; `make build`, `bun run build:release`, `make browser` (Chromium/WebKit), `make evidence` (15 signatures) pass; mocked note UI at 390×844 and 1440×900 (all five states, no horizontal overflow, no console errors); offline in-browser seal check in Chromium and WebKit with a locally signed `provider_tee` record | Relay: the note-once lock is replaced by 3 notes per account per UTC day plus 3/hour per account and 120/hour overall, so a broken note can be asked again; the completion call aborts after 35 s and signature polling runs for up to 10 s (tests cover the daily reset, a hung upstream and the polling window). Browser: a missing signature is a distinct "seal not recorded yet" state that is shown, retryable and never stored; the final Ed25519 check is the SDK's `verifyModelResponse` (tweetnacl), and the offline browser check sealed in both engines with `crypto.subtle.verify`/`importKey` disabled and rejected a flipped signature. The back of each note states only what that note established (sealed: full claim and shared-key limit; not sealed/unrecorded: attestation, encryption and the exact reason; broken: model and what happened). Keyboard focus moves to the note and a polite status region announces the outcome (checked in Chromium via the mocked fixture; no screen reader was run). No live NEAR AI completion was made for these fixes; no push or deployment. |
| 2026-11-14 | Sealed-note second review fixes | Independent re-review (2 reviewers, each finding verified) confirmed 5 issues; `bun test services/relayer/src/sealed-note.test.ts web/src/note` 18 pass; full `bun run test`, `make build`, `make browser` (Chromium/WebKit), `make evidence` pass | All three note allowances are checked before any is charged (a refusal no longer uses up the next day); daily refusal is `QUOTA_DAY`, hourly/global `QUOTA` keeps Ask again; register reads (8 s each), completion and signature lookup are bounded from request start (55 s budget) and a late request is refused before charging; invite copy back to “One note per harbor.” to match the component; unrecorded notes offer “Ask for a new note”. Final check of these fixes confirmed two more and both are fixed: a failed retry keeps the readable unrecorded note and says so visibly and to screen readers, and a request refused for lack of time returns `NOTE_LATE` instead of claiming the register was unreadable. The retry-keeps-note path is typechecked but not exercised in a browser. Not run against live NEAR AI. |

## Recorded discrepancies (NEAR AI, 2026-11-13)

- **E2EE version.** docs.near.ai's E2EE guide documents `X-Encryption-Version: 2` with no associated data. `@nearai/inference-sdk` 0.3.0 and nearai/inference-proxy `docs/e2ee.md` (commit 724cf65) use v3, which binds the reply key and a field label into each field's AEAD associated data, and say clients must not downgrade. The live gateway accepted v3 for `z-ai/glm-5.3-flash`. Familiar uses the SDK's v3 encryption; its test TEE reproduces the inference-proxy Ed25519 v3 vector. The SDK also sends `X-Encrypt-All-Fields: true`; the relay forwards it.
- **Attestation key.** The installed NEAR AI Cloud skill and model-verification notes say model attestation reports require an API key. The current E2EE guide says the gateway attestation endpoint needs none, and keyless model reports returned 200 today. Familiar fetches them keyless from the browser. A future 401 makes the note broken; no relay attestation fallback exists.
- **Reasoning control.** `chat_template_kwargs.enable_thinking:false` did not stop GLM-5.3 Flash reasoning (two live notes broke at `max_tokens`). docs.near.ai's reasoning-models page names `thinking_token_budget` for this model; `0` produced content.
- **Signature URL.** The skill shows `/v1/signature/{id}?model=…&signing_algo=…`; the SDK and Familiar omit `model`, and the signature was found on the first try.
- **Model tier.** `/v1/models` has no explicit tier field (`owned_by:"nearai"`). The SDK's attestation criterion (`/v1/model/{id}`: `providerType:"vllm"`, `attestationSupported:true`) is what Familiar checks.
- **Brief vs repository.** The handoff said `.env.example` already had a `NEAR_AI_API_KEY` placeholder; it did not. The placeholder was added (empty).
Loading