Skip to content
Myr

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

29 files+348 added−36 removed

modified:apps/cli/src/local/login.ts+1 added-1 removed
439 unmodified lines
440 Effect.scoped(441 Effect.gen(function* () {442 const client = yield* (yield* PlatformClient).connect({ token, url });443444 return (yield* client.status({})).handle;444 return (yield* client.whoami({})).handle;445 })446 ).pipe(447 Effect.mapError(448 () =>
207 unmodified lines
modified:apps/cli/src/render.ts+6 added
13 unmodified lines
14 Status,15 SubmitAnswer,16 TodayOf,17 VerdictOf,18 WhoAmI,19} from "@repo/protocol/contracts";20import type { Contract } from "@repo/protocol/contracts";21import { LandReceipt } from "@repo/protocol/domain/answer";22import type { AnswerReceipt } from "@repo/protocol/domain/answer";
253 unmodified lines
276};277278export const isClaimed = Schema.is(Claim.successSchema);279280const whoami = viewOf(WhoAmI.successSchema, ({ handle }) =>281 prose(`Signed in as ${handle}.`)282);283284const status = viewOf(Status.successSchema, ({ answers, claims, handle }) =>285 joined(286 prose(`Signed in as ${handle}.`),287 prose("Claims:"),
298 unmodified lines
586 status,587 submitAnswer: submitted,588 today,589 verdict,590 whoami,591} as const satisfies Readonly<592 Partial<593 Record<594 Contract["_tag"],
4 unmodified lines
modified:apps/cli/test/local/login.test.ts+4 added-4 removed
106 unmodified lines
107 );108109const isPerson = Schema.is(Person);110111const statusHandler = Contracts.toLayerHandler("status", () =>111const 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);118119const refusesEveryone = Layer.succeed(Authenticated, () =>
20 unmodified lines
140 ...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 lines
modified:apps/cli/test/commands-doc.test.ts+1 added
161 unmodified lines
162 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_000
92 unmodified lines
modified:apps/cli/test/remote.test.ts+21 added
modified:apps/platform/src/adapters/do-projects.ts+25 added-1 removed
1import { envSchemaMethod } from "@repo/project/deciders";2import { FrontPage } from "@repo/project/front-page";3import type { ProjectApi } from "@repo/project/project";4import { Projects } from "@repo/project/projects";5import { keyOf } from "@repo/protocol/ids";6import type { ProjectName } from "@repo/protocol/ids";
119 unmodified lines
126};127128export 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());136137 // 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 );147148 const isMade = (project: ProjectName) =>149 Effect.gen(function* () {150 if ((yield* Ref.get(known)).has(project)) {151 return true;152 }153154 const names = yield* listed;155156 const seeded = yield* Ref.updateAndGet(157 known,158 (all) => new Set([...all, ...names])159 );160161 if (seeded.has(project)) {162 return true;163 }164165 const found = yield* remote(namespace, project)("listAsks", [166 Anonymous.make({}),167 ]).pipe(168 Effect.as(true),
26 unmodified lines
modified:apps/platform/src/handlers.ts+2 added
393 unmodified lines
394 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 line
modified:apps/platform/src/ports.ts+13 added-3 removed
75 unmodified lines
76 ProjectionMemory,77 ProjectDescriptionsMemory78);7980const corePorts = (config: PlatformConfig): Layer.Layer<WorkerPorts> =>80const 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 lines
89 ProjectDescriptionsD190 ).pipe(91 Layer.provide(D1Client.layer({ db: config.FRONT_PAGE })),92 Layer.orDie93 ),93 )94 );9596const 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);100101 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 lines
124 ).pipe(125 Layer.provideMerge(RepoHostBinding.layer(config.ARTIFACTS)),126 Layer.provideMerge(WorkerFetch)127 );128};129130export const workerPorts = (config: PlatformConfig): Layer.Layer<WorkerPorts> =>131 plugIn(config, corePorts(config), Object.values(cartridges));132
26 unmodified lines
modified:apps/platform/test/visibility/env-values.test.ts+3 added-1 removed
175 unmodified lines
176 );177178 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 );184185 const { dispose, handler } = serve(186 platformOn(config, Layer.succeedContext(ports))
189 unmodified lines
modified:apps/platform/test/do-projects.test.ts+78 added-2 removed
1import { describe, expect, expectTypeOf, it } from "@effect/vitest";2import { LogRef } from "@repo/checks/evidence-store";3import { envSchemaMethod } from "@repo/project/deciders";4import { DraftResult } from "@repo/project/draft-runs";5import { FrontPageMemory } from "@repo/project/front-page/memory";6import { LandingCommand } from "@repo/project/landing";7import type { ProjectApi } from "@repo/project/project";8import { Projects } from "@repo/project/projects";9import { ProjectsMemory } from "@repo/project/projects/memory";
34 unmodified lines
44 namespaceOf,45 outcomeOf,46 parseIso,47 project,48 unlisted,49 world,50} from "./project-do.fixtures.ts";5152const other = ProjectName.make("alice/other");
182 unmodified lines
235 it.effect("routes each project name to a DO of its own", () =>236 Effect.gen(function* () {237 const { names, namespace } = yield* namespaceOf;238237 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 );242243 expect(outcome.before).toStrictEqual({244 refused: new UnknownProject({ project }),245 });
7 unmodified lines
253 }).pipe(Effect.provide(world))254 );255256 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;261262 // 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);265266 yield* made.initProject(alice, {});267 }).pipe(268 Effect.provide(DoProjects(namespace).pipe(Layer.provide(unlisted)))269 );270271 const calls: string[] = [];272273 const recording: ProjectNamespace = {274 get: (id) => {275 const stub = namespace.get(id);276277 return {278 call: (request) => {279 calls.push(`${id.toString()} ${request.method}`);280281 return stub.call(request);282 },283 };284 },285 idFromName: (name) => namespace.idFromName(name),286 };287288 const listing = FrontPageMemory.layer({289 credits: [],290 entries: [],291 projects: [{ openAsks: 0, posture: "open", project }],292 });293294 const outcome = yield* Effect.gen(function* () {295 const projects = yield* Projects;296 const api = yield* projects.get(project);297298 yield* api.status(bob);299300 yield* Effect.flatMap(projects.get(project), (again) =>301 again.status(bob)302 );303304 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 );311312 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 );325326 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 lines
335336 const throughDo = yield* Effect.gen(function* () {337 const { namespace } = yield* namespaceOf;338265 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));343344 const died = yield* Effect.filter(projectMethods, (method) =>345 Effect.map(
13 unmodified lines
modified:apps/platform/test/fake-env.ts+2 added-1 removed
128 unmodified lines
129 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 lines
modified:apps/platform/test/mcp.test.ts+27 added
904 unmodified lines
905 sessions906);907908describe("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);914915 const answered = yield* resultOf(916 fetch,917 Answered,918 "tools/call",919 { arguments: {}, name: "whoami" },920 "bob-token"921 );922923 const anonymous = yield* Effect.map(924 fetch(mcpRequest("tools/call", { arguments: {}, name: "whoami" })),925 ({ status }) => status926 );927928 expect(answered).toStrictEqual({929 isError: false,930 structuredContent: { handle: "bob" },931 });932 expect(anonymous).toBe(401);933 })934 );935936 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 lines
modified:apps/platform/test/project-do.fixtures.ts+8 added
4 unmodified lines
5import { memoryFs } from "@repo/artifacts/repo-host/memory-fs";6import { CheckAt } from "@repo/checks/check-runner";7import { CheckRunnerMemory, scriptKey } from "@repo/checks/check-runner/memory";8import { EvidenceStoreMemory } from "@repo/checks/evidence-store/memory";9import { FrontPageMemory } from "@repo/project/front-page/memory";10import { Lander } from "@repo/project/lander";11import { LanderIsogit } from "@repo/project/lander/isogit";12import { FinishersFromChecks } from "@repo/project/project";13import { ProjectionMemory } from "@repo/project/projection/memory";
403 unmodified lines
417 onSuccess: (value) => ({ value }),418 })419 );420421/** A front page that lists nothing, so every project is probed as it was before listings seeded the adapter. */422export const unlisted = FrontPageMemory.layer({423 credits: [],424 entries: [],425 projects: [],426});427428export const namespaceOf = inProcessNamespace((name) =>429 shellOver(":memory:", Option.some(name))430);
modified:apps/platform/test/telemetry.test.ts+15 added-3 removed
26 unmodified lines
27 bob,28 namespaceOf,29 parseIso,30 project,31 unlisted,32 world,33} from "./project-do.fixtures.ts";3435const telemetry = () => {
137 unmodified lines
173 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 );180181 const logged = JSON.stringify(console.written());182183 const withheld = /^Error: <withheld>\n\s+at /u;
70 unmodified lines
254 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 );265266 expect(refused._tag).toBe("UnknownAsk");267 expect(caller.console.errors()).toStrictEqual([]);
51 unmodified lines
319 }).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 lines
modified:apps/platform/test/w9-contracts.test.ts+47 added-1 removed
1import { describe, expect, it } from "@effect/vitest";2import { Projects } from "@repo/project/projects";2import { AskId, ProposalId, RepoPath } from "@repo/protocol/ids";3import { AskId, Handle, ProposalId, RepoPath } from "@repo/protocol/ids";4import { Unauthenticated } from "@repo/protocol/principal";5import { advanceTo } from "@repo/testkit/clock";6import { aProject, withAsk, withVouches } from "@repo/testkit/scenarios";7import { Effect, Exit, Layer } from "effect";
99 unmodified lines
107 })108 );109});110111// Projects a handler must not wake: a call to one is a defect, so a test over it fails.112const 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);119120const sleeping = Effect.gen(function* () {121 const world = yield* Layer.build(worldOf([datekit]));122123 const ports = Layer.mergeAll(asleep, Layer.succeedContext(world));124125 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});133134describe("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");139140 expect(yield* bob.whoami({})).toStrictEqual({ handle: "bob" });141 })142 );143144 it.effect("refuses a caller with no session", () =>145 Effect.gen(function* () {146 const { handler } = yield* sleeping;147 const anyone = yield* rpcClient(handler);148149 expect(yield* Effect.exit(anyone.whoami({}))).toStrictEqual(150 Exit.fail(new Unauthenticated())151 );152 })153 );154});155156describe("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 lines
modified:apps/platform/test/watch.test.ts+2 added-1 removed
50 unmodified lines
51 parseIso as doParseIso,52 project as doProject,53 shellOver,54 through,55 unlisted,56 world as doWorld,57} from "./project-do.fixtures.ts";58import { coreLoopWorld } from "./world.ts";59import type { CoreLoopWorld } from "./world.ts";
601 unmodified lines
661662const 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 );667668describe("the Worker's relay of a Project DO's watch socket", () => {669 it.live(
121 unmodified lines
modified:apps/platform/test/world.ts+5 added-1 removed
325 unmodified lines
326 })327 );328329 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 );336337 const ports = core.pipe(338 Context.merge(
246 unmodified lines
modified:apps/web/src/dev/handlers.ts+1 added
364 unmodified lines
365 ])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 line
modified:apps/web/src/server/session.ts+1 added-1 removed
160 unmodified lines
161 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 lines
modified:apps/web/test/dev-backend.test.ts+28 added
2 unmodified lines
3import { Client, Contracts } from "@repo/protocol/contracts";4import { forkRev } from "@repo/protocol/domain/code";5import { ProjectEvent } from "@repo/protocol/domain/event";6import { Handle, ProjectName } from "@repo/protocol/ids";7import { Unauthenticated } from "@repo/protocol/principal";8import {9 Context,10 DateTime,11 Duration,12 Effect,13 Equal,14 Exit,15 Layer,16 Stream,17} from "effect";18import type { Scope } from "effect";
160 unmodified lines
179 };180 })181);182183const 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());188189 return {190 anyone: yield* Effect.exit(anyone.whoami({})),191 bram: yield* bram.whoami({}),192 ines: yield* ines.whoami({}),193 };194 })195);196197const listedWithLedgers = inFreshWorld((as) =>198 Effect.gen(function* () {199 const anyone = yield* clientOf(as());200 const { projects } = yield* anyone.listProjects({});
53 unmodified lines
254 expect(Equal.equals(first, second)).toBeTruthy();255 })256 );257258 it.live("names each session's person by whoami, and nobody with none", () =>259 Effect.gen(function* () {260 const { anyone, bram, ines } = yield* sessionsNamed;261262 expect({ bram, ines }).toStrictEqual({263 bram: { handle: "bram" },264 ines: { handle: "ines-v" },265 });266 expect(anyone).toStrictEqual(Exit.fail(new Unauthenticated()));267 })268 );269270 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 lines
modified:apps/web/test/session.test.ts+14 added-16 removed
139 unmodified lines
140 },141 });142};143144const statusReply = (exit: string) => (request: Request) =>144const 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 );152153const STATUS_OF_INES =154 '{"_tag":"Success","value":{"answers":[],"claims":[],"handle":"ines-v"}}';153const INES = '{"_tag":"Success","value":{"handle":"ines-v"}}';154155const UNAUTHENTICATED =156 '{"_tag":"Failure","cause":[{"_tag":"Fail","error":{"_tag":"Unauthenticated"}}]}';157
230 unmodified lines
388const 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);396397 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 );400401 const env = envWith(platform.fetch);402
77 unmodified lines
480481 const [exchange, ...more] = seen;482 const form = new URLSearchParams(exchange?.body);483487 // 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 lines
709 })710 );711712 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));717718 const response = yield* whoami(envWith(platform.fetch), {719 cookie: `${SESSION_COOKIE}=tok123`,720 });
3 unmodified lines
724 ({ 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 lines
765 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 );771772 const response = yield* whoami(envWith(platform.fetch), {773 cookie: `${SESSION_COOKIE}=stale`,
76 unmodified lines
850 const handle = cookiesOf(response).find(851 ({ name }) => name === HANDLE_COOKIE852 );853856 const platform = recorder(statusReply(STATUS_OF_INES));854 const platform = recorder(whoamiReply(INES));855856 const who = yield* whoami(envWith(platform.fetch), {857 cookie: `${SESSION_COOKIE}=another-token; ${handle?.pair ?? ""}`,858 });
170 unmodified lines
modified:packages/agent-kit/test/golden/full-llms.txt+1 added
42 unmodified lines
43- `__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.4849## Projects5051- [oscabriel/datekit](https://web-test.example.workers.dev/oscabriel/datekit/llms.txt): Open, 3 open asks.
147 unmodified lines
modified:packages/agent-kit/test/full-llms.test.ts+1 added
72 unmodified lines
73 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];7980const projects: readonly ProjectListing[] = [81 {
174 unmodified lines
modified:packages/protocol/src/contracts.ts+20 added
153 unmodified lines
154 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[]>;162163// An empty `Schema.Struct` has no object root in JSON Schema, which an MCP
137 unmodified lines
301 .annotate(NeedsApproval, false)302 .annotate(Cli, { name: "status" })303 .annotate(Surfaces, servedOn.status) {}304305export 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) {}321322export class VerdictOf extends Rpc.make("verdict", {323 error: Schema.Union([UnknownProject, UnknownAsk]),324 payload: {325 ask: AskId,
785 unmodified lines
1111 FrontPage,1112 ListAsks,1113 ShowAsk,1114 Status,1115 WhoAmI,1116 VerdictOf,1117 LandingOf,1118 Credits,1119 TodayOf,
76 unmodified lines
modified:packages/protocol/src/testing.ts+1 added
54 unmodified lines
55 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 lines
1211 "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 lines
modified:packages/protocol/test/cli.test.ts+1 added
589 unmodified lines
590 "front",591 "asks",592 "ask",593 "status",594 "whoami",595 "verdict",596 "landing",597 "credits",598 "today",
34 unmodified lines
modified:packages/protocol/test/contracts.test.ts+8 added
83 unmodified lines
84 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 lines
modified:packages/protocol/test/mcp.test.ts+6 added
8 unmodified lines
9 Contracts,10 ListAsks,11 SubmitAnswer,12 surfaced,13 WhoAmI,14} from "../src/contracts.ts";15import { PROJECT_DESCRIPTION_CAP } from "../src/domain/front-page.ts";16import { RECENT_LANDINGS_CAP } from "../src/domain/recent-landing.ts";17import { AskId, CommitSha, KindName, ProjectName } from "../src/ids.ts";
132 unmodified lines
150 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 );161162 it.effect(
297 unmodified lines