Merge perf/whoami into main
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by oscabriel · committed by oscabriel · parents 6763f53, 9244ea8 · Browse files · 29 files·+348 added−36 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
29 files+348 added−36 removed
- tests:+278 added−30 removed
- other:+70 added−6 removed
Provenance
- Commit
ceaf566- Tree
485fada- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
6763f53- Parent 2
9244ea8
29 files changed+348 added−36 removed
modified:apps/cli/src/local/login.ts+1 added-1 removed
439 unmodified lines440 Effect.scoped(441 Effect.gen(function* () {442 const client = yield* (yield* PlatformClient).connect({ token, url });443 444- return (yield* client.status({})).handle;444+ return (yield* client.whoami({})).handle;445 })446 ).pipe(447 Effect.mapError(448 () =>207 unmodified linesmodified:apps/cli/src/render.ts+6 added
13 unmodified lines14 Status,15 SubmitAnswer,16 TodayOf,17 VerdictOf,18+ WhoAmI,19 } from "@repo/protocol/contracts";20 import type { Contract } from "@repo/protocol/contracts";21 import { LandReceipt } from "@repo/protocol/domain/answer";22 import type { AnswerReceipt } from "@repo/protocol/domain/answer";253 unmodified lines276 };277 278 export const isClaimed = Schema.is(Claim.successSchema);279 280+const whoami = viewOf(WhoAmI.successSchema, ({ handle }) =>281+ prose(`Signed in as ${handle}.`)282+);283+284 const status = viewOf(Status.successSchema, ({ answers, claims, handle }) =>285 joined(286 prose(`Signed in as ${handle}.`),287 prose("Claims:"),298 unmodified lines586 status,587 submitAnswer: submitted,588 today,589 verdict,590+ whoami,591 } as const satisfies Readonly<592 Partial<593 Record<594 Contract["_tag"],4 unmodified linesmodified:apps/cli/test/local/login.test.ts+4 added-4 removed
106 unmodified lines107 );108 109 const isPerson = Schema.is(Person);110 111-const statusHandler = Contracts.toLayerHandler("status", () =>111+const whoamiHandler = Contracts.toLayerHandler("whoami", () =>112 Effect.flatMap(Effect.service(CurrentPrincipal), (principal) =>113 isPerson(principal)114- ? Effect.succeed({ answers: [], claims: [], handle: principal.handle })115- : Effect.die("status is for people signed in")114+ ? Effect.succeed({ handle: principal.handle })115+ : Effect.die("whoami is for people signed in")116 )117 );118 119 const refusesEveryone = Layer.succeed(Authenticated, () =>20 unmodified lines140 ...all,141 { token: Redacted.value(token), url: at },142 ]),143 RpcTest.makeClient(Contracts).pipe(144- Effect.provide(Layer.mergeAll(unanswered, statusHandler, server))144+ Effect.provide(Layer.mergeAll(unanswered, whoamiHandler, server))145 )146 ),147 }),148 Layer.succeed(Browser, {627 unmodified linesmodified:apps/cli/test/commands-doc.test.ts+1 added
161 unmodified lines162 rows.map(words).toSorted()163 );164 // Known commands, so an empty tree and an empty list can't agree.165 expect(commands.has("asks")).toBeTruthy();166+ expect(commands.has("whoami")).toBeTruthy();167 expect(commands.has("env set")).toBeTruthy();168 expect(commands.has("env")).toBeFalsy();169 }),170 30_00092 unmodified linesmodified:apps/cli/test/remote.test.ts+21 added
32 unmodified lines333435363738394041424357 unmodified lines10110210310410510610710810911011111211311411511611711811912012112212312412512674 unmodified lines32 unmodified lines }) ), Contracts.toLayerHandler("status", () => Effect.succeed({ answers: [], claims: [], handle: Handle.make("tester") }) ), Contracts.toLayerHandler("whoami", () => Effect.succeed({ handle: Handle.make("tester") }) ));
const holding = (profile: Option.Option<Profile>) =>57 unmodified lines }).pipe(Effect.scoped) );
it.live( "whoami says whom the platform takes the caller for, and no more", () => Effect.gen(function* () { const platform = yield* httpPlatform(handlers);
const run = yield* runProgram(["whoami"], { client: remote( holding(Option.some(profileOn(platform.origin, knownToken))) ), handlers, });
expect(run.code).toBe(0); expect(run.out).toStrictEqual(["Signed in as tester."]); }).pipe(Effect.scoped) );
it.live( "without a profile sends no credential: a public contract answers, a signed-in one says to log in", () => Effect.gen(function* () { const platform = yield* httpPlatform(handlers);74 unmodified linesmodified:apps/platform/src/adapters/do-projects.ts+25 added-1 removed
1 import { envSchemaMethod } from "@repo/project/deciders";2+import { FrontPage } from "@repo/project/front-page";3 import type { ProjectApi } from "@repo/project/project";4 import { Projects } from "@repo/project/projects";5 import { keyOf } from "@repo/protocol/ids";6 import type { ProjectName } from "@repo/protocol/ids";119 unmodified lines126 };127 128 export const DoProjects = (129 namespace: ProjectNamespace129-): Layer.Layer<Projects> =>130+): Layer.Layer<Projects, never, FrontPage> =>131 Layer.effect(132 Projects,133 Effect.gen(function* () {134+ const frontPage = yield* FrontPage;135 const known = yield* Ref.make<ReadonlySet<ProjectName>>(new Set());136 137+ // Every project the front page lists was made, so its listing, read once138+ // per isolate on the first name not yet known, stands in for a probe of139+ // each: a fan-out over every listed project then wakes each DO once, for140+ // its own call alone. A name the listing lacks is probed, as before.141+ const listed = yield* Effect.cached(142+ Effect.map(143+ frontPage.projects(),144+ (listing) => new Set(listing.map(({ project }) => project))145+ )146+ );147+148 const isMade = (project: ProjectName) =>149 Effect.gen(function* () {150 if ((yield* Ref.get(known)).has(project)) {151 return true;152 }153 154+ const names = yield* listed;155+156+ const seeded = yield* Ref.updateAndGet(157+ known,158+ (all) => new Set([...all, ...names])159+ );160+161+ if (seeded.has(project)) {162+ return true;163+ }164+165 const found = yield* remote(namespace, project)("listAsks", [166 Anonymous.make({}),167 ]).pipe(168 Effect.as(true),26 unmodified linesmodified:apps/platform/src/handlers.ts+2 added
393 unmodified lines394 watch: (payload) =>395 Stream.unwrap(396 Effect.map(servedFramed, (live) => watchHandler(payload, { live }))397 ).pipe(Stream.provideService(Projects, projects)),398+ // The session names the caller; no project is woken for it.399+ whoami: () => Effect.map(person, ({ handle }) => ({ handle })),400 why: ({ at, path, project }) =>401 code(project, (of) => whyOf(of, Option.fromUndefinedOr(at), path)),402 };403 })1 unmodified linemodified:apps/platform/src/ports.ts+13 added-3 removed
75 unmodified lines76 ProjectionMemory,77 ProjectDescriptionsMemory78 );79 80-const corePorts = (config: PlatformConfig): Layer.Layer<WorkerPorts> =>80+const projections = (config: PlatformConfig) =>81 Layer.mergeAll(82 memoryFrontPage,83 // The D1 cartridge: delete this entry and the platform falls back to the memory84 // front page.4 unmodified lines89 ProjectDescriptionsD190 ).pipe(91 Layer.provide(D1Client.layer({ db: config.FRONT_PAGE })),92 Layer.orDie93- ),93+ )94+ );95+96+const corePorts = (config: PlatformConfig): Layer.Layer<WorkerPorts> => {97+ // One layer, built once: the handlers read the front page, and the Project98+ // DO adapter reads its listing to know which projects were made.99+ const listed = projections(config);100+101+ return Layer.mergeAll(102+ listed,103 UpstreamRepoHost,104 CheckRunnerSandbox(config.SANDBOX),105 config.LANDER_ADAPTER === "isogit"106 ? LanderIsogit107 : LanderSandbox(config.SANDBOX),108 RulesEvaluatorWorker(config.LOADER).pipe(109 Layer.provide(FinishersFromChecks)110 ),102- DoProjects(config.PROJECT),111+ DoProjects(config.PROJECT).pipe(Layer.provide(listed)),112 Layer.succeed(ProjectSockets, Option.some(config.PROJECT)),113 WorkerRateLimits({114 claim: config.CLAIM_LIMIT,115 draft: config.DRAFT_LIMIT,8 unmodified lines124 ).pipe(125 Layer.provideMerge(RepoHostBinding.layer(config.ARTIFACTS)),126 Layer.provideMerge(WorkerFetch)127 );128+};129 130 export const workerPorts = (config: PlatformConfig): Layer.Layer<WorkerPorts> =>131 plugIn(config, corePorts(config), Object.values(cartridges));132 26 unmodified linesmodified:apps/platform/test/visibility/env-values.test.ts+3 added-1 removed
175 unmodified lines176 );177 178 const ports = Context.merge(179 base,180- yield* Layer.build(DoProjects(namespace))180+ yield* Layer.build(181+ DoProjects(namespace).pipe(Layer.provide(Layer.succeedContext(base)))182+ )183 );184 185 const { dispose, handler } = serve(186 platformOn(config, Layer.succeedContext(ports))189 unmodified linesmodified:apps/platform/test/do-projects.test.ts+78 added-2 removed
1 import { describe, expect, expectTypeOf, it } from "@effect/vitest";2 import { LogRef } from "@repo/checks/evidence-store";3 import { envSchemaMethod } from "@repo/project/deciders";4 import { DraftResult } from "@repo/project/draft-runs";5+import { FrontPageMemory } from "@repo/project/front-page/memory";6 import { LandingCommand } from "@repo/project/landing";7 import type { ProjectApi } from "@repo/project/project";8 import { Projects } from "@repo/project/projects";9 import { ProjectsMemory } from "@repo/project/projects/memory";34 unmodified lines44 namespaceOf,45 outcomeOf,46 parseIso,47 project,48+ unlisted,49 world,50 } from "./project-do.fixtures.ts";51 52 const other = ProjectName.make("alice/other");182 unmodified lines235 it.effect("routes each project name to a DO of its own", () =>236 Effect.gen(function* () {237 const { names, namespace } = yield* namespaceOf;238 237- const outcome = yield* script.pipe(Effect.provide(DoProjects(namespace)));239+ const outcome = yield* script.pipe(240+ Effect.provide(DoProjects(namespace).pipe(Layer.provide(unlisted)))241+ );242 243 expect(outcome.before).toStrictEqual({244 refused: new UnknownProject({ project }),245 });7 unmodified lines253 }).pipe(Effect.provide(world))254 );255 256 it.effect(257+ "takes a project the front page lists as made without a probe, and probes only a name it does not list",258+ () =>259+ Effect.gen(function* () {260+ const { namespace } = yield* namespaceOf;261+262+ // Made before any listing, as a project is until its first projection.263+ yield* Effect.gen(function* () {264+ const made = yield* (yield* Projects).create(project);265+266+ yield* made.initProject(alice, {});267+ }).pipe(268+ Effect.provide(DoProjects(namespace).pipe(Layer.provide(unlisted)))269+ );270+271+ const calls: string[] = [];272+273+ const recording: ProjectNamespace = {274+ get: (id) => {275+ const stub = namespace.get(id);276+277+ return {278+ call: (request) => {279+ calls.push(`${id.toString()} ${request.method}`);280+281+ return stub.call(request);282+ },283+ };284+ },285+ idFromName: (name) => namespace.idFromName(name),286+ };287+288+ const listing = FrontPageMemory.layer({289+ credits: [],290+ entries: [],291+ projects: [{ openAsks: 0, posture: "open", project }],292+ });293+294+ const outcome = yield* Effect.gen(function* () {295+ const projects = yield* Projects;296+ const api = yield* projects.get(project);297+298+ yield* api.status(bob);299+300+ yield* Effect.flatMap(projects.get(project), (again) =>301+ again.status(bob)302+ );303+304+ return {305+ again: yield* outcomeOf(projects.create(project)),306+ other: yield* outcomeOf(projects.get(other)),307+ };308+ }).pipe(309+ Effect.provide(DoProjects(recording).pipe(Layer.provide(listing)))310+ );311+312+ expect(outcome.again).toStrictEqual({313+ refused: new ProjectExists({ project }),314+ });315+ expect(outcome.other).toStrictEqual({316+ refused: new UnknownProject({ project: other }),317+ });318+ expect(calls).toStrictEqual([319+ `${keyOf(project)} status`,320+ `${keyOf(project)} status`,321+ `${keyOf(other)} listAsks`,322+ ]);323+ }).pipe(Effect.provide(world))324+ );325+326+ it.effect(327 "answers every ProjectApi method as the project's service does in process",328 () =>329 Effect.gen(function* () {330 yield* advanceTo("2026-10-07T12:00:00Z");4 unmodified lines335 336 const throughDo = yield* Effect.gen(function* () {337 const { namespace } = yield* namespaceOf;338 265- return yield* script.pipe(Effect.provide(DoProjects(namespace)));339+ return yield* script.pipe(340+ Effect.provide(DoProjects(namespace).pipe(Layer.provide(unlisted)))341+ );342 }).pipe(Effect.provide(world));343 344 const died = yield* Effect.filter(projectMethods, (method) =>345 Effect.map(13 unmodified linesmodified:apps/platform/test/fake-env.ts+2 added-1 removed
128 unmodified lines129 DRAFT_LIMIT: untouchable("DRAFT_LIMIT"),130 DRAFT_MODEL: "@cf/moonshotai/kimi-k2.7-code",131 EMAIL: untouchable("EMAIL"),132 EVIDENCE: untouchable("EVIDENCE"),133- FRONT_PAGE: untouchable("FRONT_PAGE"),133+ // Lists nothing: the Project DO adapter reads the listing before it probes a project.134+ FRONT_PAGE: emptyFrontPage(),135 LANDER_ADAPTER: "container",136 LOADER: untouchable("LOADER"),137 MASTER_KEY: masterKey,138 METRICS: untouchable("METRICS"),26 unmodified linesmodified:apps/platform/test/mcp.test.ts+27 added
904 unmodified lines905 sessions906 );907 908 describe("the platform's MCP resources and prompts, over scripted contracts", () => {909+ it.effect(910+ "answers whoami with the caller's handle, from the session alone, and refuses it with no credential",911+ () =>912+ Effect.gen(function* () {913+ const { fetch } = yield* served(naming);914+915+ const answered = yield* resultOf(916+ fetch,917+ Answered,918+ "tools/call",919+ { arguments: {}, name: "whoami" },920+ "bob-token"921+ );922+923+ const anonymous = yield* Effect.map(924+ fetch(mcpRequest("tools/call", { arguments: {}, name: "whoami" })),925+ ({ status }) => status926+ );927+928+ expect(answered).toStrictEqual({929+ isError: false,930+ structuredContent: { handle: "bob" },931+ });932+ expect(anonymous).toBe(401);933+ })934+ );935+936 it.effect("read through the Client the tools use, as the caller", () =>937 Effect.gen(function* () {938 const { fetch } = yield* served(naming);939 53 unmodified linesmodified:apps/platform/test/project-do.fixtures.ts+8 added
4 unmodified lines5 import { memoryFs } from "@repo/artifacts/repo-host/memory-fs";6 import { CheckAt } from "@repo/checks/check-runner";7 import { CheckRunnerMemory, scriptKey } from "@repo/checks/check-runner/memory";8 import { EvidenceStoreMemory } from "@repo/checks/evidence-store/memory";9+import { FrontPageMemory } from "@repo/project/front-page/memory";10 import { Lander } from "@repo/project/lander";11 import { LanderIsogit } from "@repo/project/lander/isogit";12 import { FinishersFromChecks } from "@repo/project/project";13 import { ProjectionMemory } from "@repo/project/projection/memory";403 unmodified lines417 onSuccess: (value) => ({ value }),418 })419 );420 421+/** A front page that lists nothing, so every project is probed as it was before listings seeded the adapter. */422+export const unlisted = FrontPageMemory.layer({423+ credits: [],424+ entries: [],425+ projects: [],426+});427+428 export const namespaceOf = inProcessNamespace((name) =>429 shellOver(":memory:", Option.some(name))430 );modified:apps/platform/test/telemetry.test.ts+15 added-3 removed
26 unmodified lines27 bob,28 namespaceOf,29 parseIso,30 project,31+ unlisted,32 world,33 } from "./project-do.fixtures.ts";34 35 const telemetry = () => {137 unmodified lines173 requestId,174 LandingCommand.Start({ main: LandedSha.make("a".repeat(40)) })175 )176 );176- }).pipe(Effect.provide(DoProjects(namespace)));177+ }).pipe(178+ Effect.provide(DoProjects(namespace).pipe(Layer.provide(unlisted)))179+ );180 181 const logged = JSON.stringify(console.written());182 183 const withheld = /^Error: <withheld>\n\s+at /u;70 unmodified lines254 return yield* Effect.flip(255 made.claim(bob, parseIso).pipe(Effect.withErrorReporting)256 );257 }).pipe(255- Effect.provide(Layer.merge(DoProjects(namespace), caller.layer))258+ Effect.provide(259+ Layer.merge(260+ DoProjects(namespace).pipe(Layer.provide(unlisted)),261+ caller.layer262+ )263+ )264 );265 266 expect(refused._tag).toBe("UnknownAsk");267 expect(caller.console.errors()).toStrictEqual([]);51 unmodified lines319 }).pipe(320 invocation({ project, requestId }),321 instance("Answer.run"),322 Effect.provide(315- Layer.mergeAll(DoProjects(namespace), engine, caller.layer)323+ Layer.mergeAll(324+ DoProjects(namespace).pipe(Layer.provide(unlisted)),325+ engine,326+ caller.layer327+ )328 ),329 Effect.exit330 );331 60 unmodified linesmodified:apps/platform/test/w9-contracts.test.ts+47 added-1 removed
1 import { describe, expect, it } from "@effect/vitest";2+import { Projects } from "@repo/project/projects";2-import { AskId, ProposalId, RepoPath } from "@repo/protocol/ids";3+import { AskId, Handle, ProposalId, RepoPath } from "@repo/protocol/ids";4 import { Unauthenticated } from "@repo/protocol/principal";5 import { advanceTo } from "@repo/testkit/clock";6 import { aProject, withAsk, withVouches } from "@repo/testkit/scenarios";7 import { Effect, Exit, Layer } from "effect";99 unmodified lines107 })108 );109 });110 111+// Projects a handler must not wake: a call to one is a defect, so a test over it fails.112+const asleep = Layer.succeed(113+ Projects,114+ Projects.of({115+ create: (name) => Effect.die(`a handler made ${name}`),116+ get: (name) => Effect.die(`a handler woke ${name}`),117+ })118+);119+120+const sleeping = Effect.gen(function* () {121+ const world = yield* Layer.build(worldOf([datekit]));122+123+ const ports = Layer.mergeAll(asleep, Layer.succeedContext(world));124+125+ return yield* served(126+ Layer.mergeAll(127+ Handlers.pipe(Layer.provide(ports)),128+ ports,129+ MemorySessions.layer({ "bob-token": Handle.make("bob") })130+ )131+ );132+});133+134+describe("whoami over /rpc", () => {135+ it.effect("names the caller from the session, and wakes no project", () =>136+ Effect.gen(function* () {137+ const { handler } = yield* sleeping;138+ const bob = yield* rpcClient(handler, "bob-token");139+140+ expect(yield* bob.whoami({})).toStrictEqual({ handle: "bob" });141+ })142+ );143+144+ it.effect("refuses a caller with no session", () =>145+ Effect.gen(function* () {146+ const { handler } = yield* sleeping;147+ const anyone = yield* rpcClient(handler);148+149+ expect(yield* Effect.exit(anyone.whoami({}))).toStrictEqual(150+ Exit.fail(new Unauthenticated())151+ );152+ })153+ );154+});155+156 describe("the host page and raw files routes", () => {157 it.effect(158 "answer / and a project's raw files from their slots, a stale bearer or not",159 () =>46 unmodified linesmodified:apps/platform/test/watch.test.ts+2 added-1 removed
50 unmodified lines51 parseIso as doParseIso,52 project as doProject,53 shellOver,54 through,55+ unlisted,56 world as doWorld,57 } from "./project-do.fixtures.ts";58 import { coreLoopWorld } from "./world.ts";59 import type { CoreLoopWorld } from "./world.ts";601 unmodified lines661 662 const relayedFrom = (namespace: ProjectNamespace & WatchNamespace, since = 0) =>663 watchHandler({ project: doProject, since }, { live: true }).pipe(664 Stream.provideService(ProjectSockets, Option.some(namespace)),664- Stream.provide(DoProjects(namespace))665+ Stream.provide(DoProjects(namespace).pipe(Layer.provide(unlisted)))666 );667 668 describe("the Worker's relay of a Project DO's watch socket", () => {669 it.live(121 unmodified linesmodified:apps/platform/test/world.ts+5 added-1 removed
325 unmodified lines326 })327 );328 329 const core = base.pipe(330- Context.merge(yield* Layer.build(DoProjects(namespace)))330+ Context.merge(331+ yield* Layer.build(332+ DoProjects(namespace).pipe(Layer.provide(Layer.succeedContext(base)))333+ )334+ )335 );336 337 const ports = core.pipe(338 Context.merge(246 unmodified linesmodified:apps/web/src/dev/handlers.ts+1 added
364 unmodified lines365 ])366 )367 )368 ),369+ whoami: () => Effect.map(person, ({ handle }) => ({ handle })),370 why: ({ at, path, project }) =>371 code(project, (of) => whyOf(of, Option.fromUndefinedOr(at), path)),372 };373 })1 unmodified linemodified:apps/web/src/server/session.ts+1 added-1 removed
160 unmodified lines161 origin: string,162 token: string163 ) =>164 Effect.service(Client).pipe(165- Effect.flatMap((client) => client.status({})),165+ Effect.flatMap((client) => client.whoami({})),166 Effect.map(({ handle }) => handle),167 Effect.provide(168 clientFor(169 new Request(`${origin}/auth/whoami`, {289 unmodified linesmodified:apps/web/test/dev-backend.test.ts+28 added
2 unmodified lines3 import { Client, Contracts } from "@repo/protocol/contracts";4 import { forkRev } from "@repo/protocol/domain/code";5 import { ProjectEvent } from "@repo/protocol/domain/event";6 import { Handle, ProjectName } from "@repo/protocol/ids";7+import { Unauthenticated } from "@repo/protocol/principal";8 import {9 Context,10 DateTime,11 Duration,12 Effect,13 Equal,14+ Exit,15 Layer,16 Stream,17 } from "effect";18 import type { Scope } from "effect";160 unmodified lines179 };180 })181 );182 183+const sessionsNamed = inFreshWorld((as) =>184+ Effect.gen(function* () {185+ const ines = yield* clientOf(as(decider));186+ const bram = yield* clientOf(as(contributor));187+ const anyone = yield* clientOf(as());188+189+ return {190+ anyone: yield* Effect.exit(anyone.whoami({})),191+ bram: yield* bram.whoami({}),192+ ines: yield* ines.whoami({}),193+ };194+ })195+);196+197 const listedWithLedgers = inFreshWorld((as) =>198 Effect.gen(function* () {199 const anyone = yield* clientOf(as());200 const { projects } = yield* anyone.listProjects({});53 unmodified lines254 expect(Equal.equals(first, second)).toBeTruthy();255 })256 );257 258+ it.live("names each session's person by whoami, and nobody with none", () =>259+ Effect.gen(function* () {260+ const { anyone, bram, ines } = yield* sessionsNamed;261+262+ expect({ bram, ines }).toStrictEqual({263+ bram: { handle: "bram" },264+ ines: { handle: "ines-v" },265+ });266+ expect(anyone).toStrictEqual(Exit.fail(new Unauthenticated()));267+ })268+ );269+270 it.live("adds none of the fixtures without their switch", () =>271 Effect.gen(function* () {272 const { entries, projects } = yield* pages;273 const listed = new Set(projects.map(({ project }) => project));296 unmodified linesmodified:apps/web/test/session.test.ts+14 added-16 removed
139 unmodified lines140 },141 });142 };143 144-const statusReply = (exit: string) => (request: Request) =>144+const whoamiReply = (exit: string) => (request: Request) =>145 new Response(146 (request.clone().body ?? new Blob().stream())147 .pipeThrough(new TextDecoderStream())148 .pipeThrough(replyingWith(exit))149 .pipeThrough(new TextEncoderStream()),150 { headers: { "content-type": "application/json" } }151 );152 153-const STATUS_OF_INES =154- '{"_tag":"Success","value":{"answers":[],"claims":[],"handle":"ines-v"}}';153+const INES = '{"_tag":"Success","value":{"handle":"ines-v"}}';154 155 const UNAUTHENTICATED =156 '{"_tag":"Failure","cause":[{"_tag":"Fail","error":{"_tag":"Unauthenticated"}}]}';157 230 unmodified lines388 const signInAndBack = (389 path: string,390 code: string,391 answer: () => Response = () => Response.json(TOKEN_ANSWER),393- status: (request: Request) => Response = statusReply(STATUS_OF_INES)392+ who: (request: Request) => Response = whoamiReply(INES)393 ) =>394 Effect.gen(function* () {395 const { location, state } = yield* signIn(path);396 397 const platform = recorder((request) =>399- new URL(request.url).pathname.startsWith("/rpc")400- ? status(request)401- : answer()398+ new URL(request.url).pathname.startsWith("/rpc") ? who(request) : answer()399 );400 401 const env = envWith(platform.fetch);402 77 unmodified lines480 481 const [exchange, ...more] = seen;482 const form = new URLSearchParams(exchange?.body);483 487- // Then once, with the new token, `status`: the handle it names is488- // kept beside the session, so no page asks the platform again.484+ // Then once, with the new token, `whoami`: the handle it names is485+ // kept beside the session, so no page asks the platform again, and486+ // no project is woken to learn it.487 expect(488 more.map(({ authorization, body, cookie, url }) => [489 new URL(url).pathname.replace(/\/$/u, ""),490 authorization,491 cookie,494- body.includes('"tag":"status"'),492+ body.includes('"tag":"whoami"'),493 ])494 ).toStrictEqual([495 ["/rpc", `Bearer ${TOKEN_ANSWER.access_token}`, null, true],496 ]);212 unmodified lines709 })710 );711 712 it.effect(715- "answers the handle the platform's status names for the session",713+ "answers the handle the platform's whoami names for the session",714 () =>715 Effect.gen(function* () {718- const platform = recorder(statusReply(STATUS_OF_INES));716+ const platform = recorder(whoamiReply(INES));717 718 const response = yield* whoami(envWith(platform.fetch), {719 cookie: `${SESSION_COOKIE}=tok123`,720 });3 unmodified lines724 ({ authorization, body, cookie, url }) => ({725 authorization,726 cookie,727 path: new URL(url).pathname.replace(/\/$/u, ""),730- status: body.includes('"tag":"status"'),728+ whoami: body.includes('"tag":"whoami"'),729 })730 )731 ).toStrictEqual([732 {733 authorization: "Bearer tok123",734 cookie: null,735 path: "/rpc",738- status: true,736+ whoami: true,737 },738 ]);739 expect(response.headers.get("cache-control")).toBe("no-store");740 expect(yield* textOf(response)).toBe('{"handle":"ines-v"}');24 unmodified lines765 Effect.gen(function* () {766 const platform = recorder((request) =>767 request.headers.has("authorization")768 ? new Response(null, { status: 401 })771- : statusReply(UNAUTHENTICATED)(request)769+ : whoamiReply(UNAUTHENTICATED)(request)770 );771 772 const response = yield* whoami(envWith(platform.fetch), {773 cookie: `${SESSION_COOKIE}=stale`,76 unmodified lines850 const handle = cookiesOf(response).find(851 ({ name }) => name === HANDLE_COOKIE852 );853 856- const platform = recorder(statusReply(STATUS_OF_INES));854+ const platform = recorder(whoamiReply(INES));855 856 const who = yield* whoami(envWith(platform.fetch), {857 cookie: `${SESSION_COOKIE}=another-token; ${handle?.pair ?? ""}`,858 });170 unmodified linesmodified:packages/agent-kit/test/golden/full-llms.txt+1 added
42 unmodified lines43 - `__CLI__ login`: Sign in to a platform.44 - `__CLI__ status`: Show your claims and answers. Only reads.45 - `__CLI__ submit <ask>`: Offer a commit as an answer to a claimed ask.46 - `__CLI__ verdict <ask>`: Show the verdict on an answer to an ask. Only reads.47+- `__CLI__ whoami`: Show who the platform takes you for. Only reads.48 49 ## Projects50 51 - [oscabriel/datekit](https://web-test.example.workers.dev/oscabriel/datekit/llms.txt): Open, 3 open asks.147 unmodified linesmodified:packages/agent-kit/test/full-llms.test.ts+1 added
72 unmodified lines73 row(["verdict"], "Show the verdict on an answer to an ask.", {74 flags: ["--head", "--project", "--json"],75 positional: ["ask"],76 }),77+ row(["whoami"], "Show who the platform takes you for."),78 ];79 80 const projects: readonly ProjectListing[] = [81 {174 unmodified linesmodified:packages/protocol/src/contracts.ts+20 added
153 unmodified lines154 today: SurfaceName.literals,155 verdict: SurfaceName.literals,156 vouch: ["rpc", "mcp", "cli"],157 watch: ["rpc", "web"],158+ // The handle alone, read from the session: no project is woken for it.159+ whoami: ["rpc", "mcp", "cli"],160 why: ["rpc", "mcp", "web"],161 } as const satisfies Record<string, readonly SurfaceName[]>;162 163 // An empty `Schema.Struct` has no object root in JSON Schema, which an MCP137 unmodified lines301 .annotate(NeedsApproval, false)302 .annotate(Cli, { name: "status" })303 .annotate(Surfaces, servedOn.status) {}304 305+export class WhoAmI extends Rpc.make("whoami", {306+ payload: NoPayload,307+ success: Schema.Struct({ handle: Handle }),308+})309+ .annotate(310+ Description,311+ "Show who the caller is: the handle the platform takes them for, from the session alone."312+ )313+ .annotate(Audience, "signedIn")314+ .annotate(Visibility, "public")315+ .annotate(ReadOnly, true)316+ .annotate(Idempotent, true)317+ .annotate(Destructive, false)318+ .annotate(NeedsApproval, false)319+ .annotate(Cli, { name: "whoami" })320+ .annotate(Surfaces, servedOn.whoami) {}321+322 export class VerdictOf extends Rpc.make("verdict", {323 error: Schema.Union([UnknownProject, UnknownAsk]),324 payload: {325 ask: AskId,785 unmodified lines1111 FrontPage,1112 ListAsks,1113 ShowAsk,1114 Status,1115+ WhoAmI,1116 VerdictOf,1117 LandingOf,1118 Credits,1119 TodayOf,76 unmodified linesmodified:packages/protocol/src/testing.ts+1 added
54 unmodified lines55 today: uncalled,56 verdict: uncalled,57 vouch: uncalled,58 watch: uncalled,59+ whoami: uncalled,60 why: uncalled,61 });modified:packages/protocol/test/fixtures/contracts.json+6 added
1210 unmodified lines1211 "at": "2026-10-07T12:00:00.000Z",1212 "seq": 421213 }1214 },1215+ "whoami": {1216+ "payload": {},1217+ "success": {1218+ "handle": "alice"1219+ }1220+ },1221 "why": {1222 "payload": {1223 "at": "main",1224 "path": "src/parse/iso.ts",114 unmodified linesmodified:packages/protocol/test/cli.test.ts+1 added
589 unmodified lines590 "front",591 "asks",592 "ask",593 "status",594+ "whoami",595 "verdict",596 "landing",597 "credits",598 "today",34 unmodified linesmodified:packages/protocol/test/contracts.test.ts+8 added
83 unmodified lines84 on: "RMCW",85 tag: "status",86 },87 {88+ audience: "signedIn",89+ cli: "whoami",90+ errors: [],91+ flags: "RI",92+ on: "RMC",93+ tag: "whoami",94+ },95+ {96 audience: "public",97 cli: "verdict <ask>",98 errors: ["UnknownProject", "UnknownAsk"],99 flags: "RI",550 unmodified linesmodified:packages/protocol/test/mcp.test.ts+6 added
8 unmodified lines9 Contracts,10 ListAsks,11 SubmitAnswer,12 surfaced,13+ WhoAmI,14 } from "../src/contracts.ts";15 import { PROJECT_DESCRIPTION_CAP } from "../src/domain/front-page.ts";16 import { RECENT_LANDINGS_CAP } from "../src/domain/recent-landing.ts";17 import { AskId, CommitSha, KindName, ProjectName } from "../src/ids.ts";132 unmodified lines150 required: ["ask", "base", "head", "project", "requestId"],151 },152 name: "submitAnswer",153 });154+ expect(byName.get("whoami")).toStrictEqual({155+ description: Context.get(WhoAmI.annotations, Description),156+ inputSchema: {},157+ name: "whoami",158+ });159 })160 );161 162 it.effect(297 unmodified lines