Skip to content
Merged
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
1 change: 1 addition & 0 deletions PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ Full earlier progress and acceptance records are preserved in the [archive](docs
- **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).
| 2026-11-14 | One tide: the tide run and the Tidekeeper's ask as one game, on local branch `feat/one-tide` (merges `feat/one-tide-ui` `e7b29fe` into familiar-bb's `f5643c5`). On device harbors the daily is the tide run: Today's tide shows the day's card, Bram's guess and three stamps (home, guess, dry); the Home sheet celebrates the result; the tide log keeps run pages beside old three-ask pages; Bram's shelf offers today's reed and glass, up to 3 each, and pearls stay with Mochi. Signed-in harbors keep the three-ask court. Not pushed or deployed | At `f67d9fe`: `bun run typecheck`; `bun run test` 485 pass/0 fail/40232 assertions; `bun --no-env-file run build:release`; `cargo test --manifest-path contracts/Cargo.toml --workspace`; `test:tide-browser` (390×844, 412×860, 844×390, 1280×800, 1440×900), `test:tide-run-browser`, `test:season-browser`, `test:expedition-harbor-browser`, `test:expedition-touch-browser`, `test:routing-browser`, `test:records-browser` all pass. `test:expedition-browser` (320 harbor brand clickable) and `test:expedition-qa-browser` (home controls obscured at 9 sizes, 667×375 court) fail with the same messages at the base `57d8565`. At `b95ae9d`, `test:expedition-lifecycle-browser` reaches the court through the Chart and then fails at the same "Familiar home" obscured assertion as the base. Chromium screenshots from a fresh harbor through chapter one, the lit harbor, today's tide, the Home sheet, the log, Bram's shelf and the harbor after at 390×844, 844×390 and 1280×800, with no page errors. Browser emulation only: no real device, no human playtest, signed-in shelf not exercised |
| 2026-11-14 | Slice B verification (uncommitted working tree on `feat/keep-wrens-light-onboarding`, base `ca01a92`): Keep Wren's Light prologue and in-run teaching. **Not committed: the Chromium tide-run suite fails** | `bun run typecheck` pass; `bun run test` 555 pass/0 fail/41739 assertions across 76 files; `bun run build` pass. **`test:tide-run-browser` fails in Chromium** (first engine, first scenario `destinationEdgeTaps`, `scripts/test-tide-run-browser.ts:230` via `:170`): `open controls before destination-edge taps: Mochi’s body is exposed` `'DIV' !== 'CANVAS'`. At 390×844 with Button controls open, `.tide-tray-reading` (objective/forecast) covers Mochi on the dock at y≈503, and a screenshot shows Mochi and the dock hidden behind the tray. It failed the same way when run on its own (3 s), so WebKit was never reached. When all 13 browser processes ran at once, `routing`, `tide`, `season`, `records` and `expedition-qa` passed. `tide-run` ×3, `expedition`, `expedition-touch`, `expedition-lifecycle`, `passage` and `expedition-harbor` failed under that load, mostly 5 s readiness timeouts. Run one at a time afterwards, `expedition-harbor`, `expedition`, `expedition-touch`, `expedition-lifecycle` and `passage` all passed. Only `tide-run` still fails. A Chromium 390×844 touch walkthrough on a fresh device with the network blocked by the fixtures: the prologue copy matches the plan; the objective line is partly hidden behind the actions at first paint but can be scrolled into view (panel overflow 47 px); the first cue and the lens-safe decision copy match the plan; Help Mochi, Sail, and Keep gathering respond to taps; no page errors. Browser emulation only |
12 changes: 12 additions & 0 deletions scripts/browser-controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,15 @@ export async function sailStory(page:Page){
await page.getByRole("button",{name:/^Prepare Chapter \d+$/}).click();
await page.getByRole("button",{name:"Sail with Mochi",exact:true}).click();
}

/** A repair stays on each earned beat until the player chooses to continue. */
export async function continueStoryExchange(page:Page){
const dialog=page.getByRole("dialog").filter({has:page.getByRole("button",{name:/^Continue(?: with Mochi)?$/,exact:true})});
await dialog.waitFor();
for(let beat=0;beat<4;beat++){
const next=dialog.getByRole("button",{name:"Continue",exact:true});
if(await next.count())await next.click();
else{await dialog.getByRole("button",{name:"Continue with Mochi",exact:true}).click();return;}
}
throw Error("Story exchange did not reach its final confirmation");
}
27 changes: 23 additions & 4 deletions scripts/browser-fixtures.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { expect, test } from "bun:test";
import type { Page, Route } from "@playwright/test";
import { runInNewContext } from "node:vm";
import { BROWSER_DAY, prepareBrowser, seasonRpcFixture } from "./browser-fixtures";
import { BROWSER_DAY, prepareBrowser, seasonRpcFixture, seedGameplayGuidance } from "./browser-fixtures";
import { GUIDANCE_KEY } from "../web/src/run/guidance";

const rpc=(method:string,args:unknown={},receiver="season.familiar-game.testnet")=>JSON.stringify({jsonrpc:"2.0",id:"season",method:"query",params:{request_type:"call_function",finality:"final",account_id:receiver,method_name:method,args_base64:btoa(JSON.stringify(args))}});
test("browser RPC fixtures match endpoint, receiver, method and exact arguments",()=>{
expect(seasonRpcFixture("https://test.rpc.fastnear.com","POST",rpc("get_shelf"),BROWSER_DAY)).toMatchObject({day:BROWSER_DAY});
expect(seasonRpcFixture("https://test.rpc.fastnear.com","POST",rpc("get_today",{account_id:null}),BROWSER_DAY)).toMatchObject({day:BROWSER_DAY,content_version:"first_light_v2"});
expect(seasonRpcFixture("https://test.rpc.fastnear.com","POST",rpc("get_today",{account_id:"helper-a.familiar-game.testnet"}),BROWSER_DAY)).toMatchObject({day:BROWSER_DAY,content_version:"first_light_v2"});
for(const [method,args] of [["get_account",{account_id:"alice.familiar-game.testnet"}],["get_wish",{pet:"mochi.familiar-game.testnet"}],["get_postcard",{pet:"mochi.familiar-game.testnet"}]] as const)
expect(seasonRpcFixture("https://test.rpc.fastnear.com","POST",rpc(method,args),BROWSER_DAY)).toBeNull();
for(const [url,verb,body] of [["https://test.rpc.fastnear.com.evil/","POST",rpc("get_shelf")],["https://test.rpc.fastnear.com/other","POST",rpc("get_shelf")],["https://test.rpc.fastnear.com","GET",rpc("get_shelf")],["https://test.rpc.fastnear.com","POST",rpc("get_shelf",{},"other.testnet")],["https://test.rpc.fastnear.com","POST",rpc("unknown")],["https://test.rpc.fastnear.com","POST",rpc("get_shelf",{unexpected:true})],["https://test.rpc.fastnear.com","POST",rpc("get_today",{account_id:null,extra:true})],["https://test.rpc.fastnear.com","POST",rpc("get_today",{account_id:"unknown.testnet"})]])
Expand All @@ -19,7 +21,7 @@ test(`browser preparation shifts only the running wall clock and validates every
let dateScript!:(time:number)=>void;
let handle!:(route:Route)=>Promise<unknown>;
const page={clock:{install:async(value:unknown)=>{calls.push(["install",value]);}},addInitScript:async(callback:typeof dateScript,time:number)=>{dateScript=callback;calls.push(["date",time]);},evaluate:async(callback:typeof dateScript,time:number)=>{dateScript=callback;calls.push(["shift",time]);},route:async(pattern:string,callback:typeof handle)=>{calls.push(["route",pattern]);handle=callback;}} as unknown as Page;
const network=await prepareBrowser(page,origin,BROWSER_DAY);
const network=await prepareBrowser(page,origin,BROWSER_DAY,{guidance:false});
const noon=BROWSER_DAY*86_400_000+43_200_000;
expect(calls).toEqual([["date",noon],["route","**/*"]]);
let elapsed=10_000;
Expand Down Expand Up @@ -71,15 +73,32 @@ test(`browser preparation shifts only the running wall clock and validates every
test("only deliberate timer-control scenarios install Playwright's full clock",async()=>{
const calls:unknown[]=[];
const page={clock:{install:async(value:unknown)=>{calls.push(["manual",value]);}},addInitScript:async()=>{calls.push(["date"]);},route:async()=>{}} as unknown as Page;
const manual=await prepareBrowser(page,"http://localhost:3000",BROWSER_DAY,{clock:"manual"});
const manual=await prepareBrowser(page,"http://localhost:3000",BROWSER_DAY,{clock:"manual",guidance:false});
expect(calls).toEqual([["manual",{time:new Date(BROWSER_DAY*86_400_000+43_200_000)}]]);
calls.length=0;
const unclocked=await prepareBrowser(page,"http://localhost:3000",BROWSER_DAY,{clock:false});
const unclocked=await prepareBrowser(page,"http://localhost:3000",BROWSER_DAY,{clock:false,guidance:false});
expect(calls).toEqual([]);
await expect(manual.setTime(0)).rejects.toThrow("Date shifts require");
await expect(unclocked.setTime(0)).rejects.toThrow("Date shifts require");
});

test("gameplay fixtures seed a separate guidance choice while preserving player preferences and game saves",async()=>{
const scripts:{callback:(key:string)=>void;key:string}[]=[];
const page={addInitScript:async(callback:(key:string)=>void,key:string)=>{scripts.push({callback,key});},route:async()=>{}} as unknown as Page;
const saves=new Map([["familiar.expedition.local.v2","ORIGINAL_GAME_SAVE"]]);
const localStorage={getItem:(key:string)=>saves.get(key)??null,setItem:(key:string,value:string)=>{saves.set(key,value);}};
await prepareBrowser(page,"http://localhost:3000",BROWSER_DAY,{clock:false});
expect(scripts).toHaveLength(1);expect(scripts[0]!.key).toBe(GUIDANCE_KEY);
const apply=()=>runInNewContext(`(${scripts[0]!.callback.toString()})(key)`,{localStorage,key:GUIDANCE_KEY});
apply();expect(JSON.parse(saves.get(GUIDANCE_KEY)!)).toEqual({version:1,intro:"skip",buttons:false});
expect(saves.get("familiar.expedition.local.v2")).toBe("ORIGINAL_GAME_SAVE");
saves.set(GUIDANCE_KEY,JSON.stringify({version:1,intro:null,buttons:true}));
apply();expect(JSON.parse(saves.get(GUIDANCE_KEY)!)).toEqual({version:1,intro:null,buttons:true});
scripts.length=0;await prepareBrowser(page,"http://localhost:3000",BROWSER_DAY,{clock:false,guidance:false});
expect(scripts).toEqual([]);
await seedGameplayGuidance(page);expect(scripts).toHaveLength(1);
});

test("browser fixtures reject every hosted origin except the existing QA deployment",async()=>{
for(const origin of ["https://unexpected.example","http://familiar-two.vercel.app","https://familiar-two.vercel.app:444","https://familiar-two.vercel.app.evil"])
await expect(prepareBrowser({} as Page,origin)).rejects.toThrow("Browser fixtures require a local server or the existing hosted QA origin");
Expand Down
13 changes: 11 additions & 2 deletions scripts/browser-fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import assert from "node:assert/strict";
import type { Page } from "@playwright/test";
import type { ShelfView, TodayView } from "../web/src/season/model";
import { GUIDANCE_KEY } from "../web/src/run/guidance";

export const BROWSER_DAY=20771;
const RPC="https://test.rpc.fastnear.com/",ROOT="familiar-game.testnet";
const accounts=new Set([`alice.${ROOT}`,`bob.${ROOT}`,`harness.${ROOT}`]);
const accounts=new Set([`alice.${ROOT}`,`bob.${ROOT}`,`harness.${ROOT}`,`helper-a.${ROOT}`]);
const pets=new Set([`mochi.${ROOT}`,`mochi-harness.${ROOT}`]);

/** Public reads only. A mismatched envelope is an unexpected request, never a live fallback. */
Expand Down Expand Up @@ -44,10 +45,18 @@ function shiftBrowserDate(time:number) {
});
}

/** Gameplay fixtures choose guidance explicitly; pristine introduction tests omit this setup. */
export async function seedGameplayGuidance(page:Page) {
await page.addInitScript(key=>{
if(localStorage.getItem(key)===null)localStorage.setItem(key,JSON.stringify({version:1,intro:"skip",buttons:false}));
},GUIDANCE_KEY);
}

/** Date drives the UTC day; native frame/timer clocks must keep driving Phaser. */
export async function prepareBrowser(page:Page,origin:string|URL,day=BROWSER_DAY,{clock=true}: {clock?:boolean|"manual"}={}) {
export async function prepareBrowser(page:Page,origin:string|URL,day=BROWSER_DAY,{clock=true,guidance=true}: {clock?:boolean|"manual";guidance?:boolean}={}) {
const resourceUrl=new URL(origin),local=resourceUrl.origin,unexpected:string[]=[],rpc:string[]=[];
assert(["localhost","127.0.0.1","[::1]"].includes(resourceUrl.hostname)||local==="https://familiar-two.vercel.app","Browser fixtures require a local server or the existing hosted QA origin");
if(guidance)await seedGameplayGuidance(page);
if(clock==="manual")await page.clock.install({time:new Date(day*86_400_000+43_200_000)});
else if(clock)await page.addInitScript(shiftBrowserDate,day*86_400_000+43_200_000);
await page.route("**/*",async route=>{
Expand Down
Loading