Merge build/109-one-as-tester: one test principal at @repo/protocol/testing
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by oscabriel · committed by oscabriel · parents b8af4b1, e88697b · Browse files · 6 files·+28 added−22 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+28 added−22 removed
- tests:+6 added−21 removed
- other:+22 added−1 removed
Provenance
- Commit
3b0df19- Tree
b05617e- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
b8af4b1- Parent 2
e88697b
6 files changed+28 added−22 removed
modified:apps/cli/test/stdio.ts+1 added-9 removed
12343456710 unmodified lines18192021232425262728292223242559 unmodified linesimport { NodeServices } from "@effect/platform-node";import { Client, Contracts } from "@repo/protocol/contracts";import { Handle } from "@repo/protocol/ids";import { Authenticated, CurrentPrincipal } from "@repo/protocol/principal";import { asTester } from "@repo/protocol/testing";import { Effect, Fiber, Layer,10 unmodified linesimport { RpcTest } from "effect/rpc";
import { mcp } from "../src/surfaces.ts";
/** A server side that takes every call as one person. */const asTester = Layer.succeed(Authenticated, (effect) => Effect.provideService(effect, CurrentPrincipal, { handle: Handle.make("tester"), }));
const Message = Schema.fromJsonString( Schema.Struct({ id: Schema.optionalKey(Schema.Union([Schema.String, Schema.Int])), result: Schema.optionalKey(Schema.Unknown),59 unmodified linesadded:packages/protocol/src/testing.ts+20 added
1234567891011121314151617181920/** * Server sides for tests. Test code alone imports this module: other * workspaces through `@repo/protocol/testing`, protocol's own tests by * relative path. Nothing under any `src/` may. */import { Effect, Layer } from "effect";
import { Handle } from "./ids.ts";import { Authenticated, CurrentPrincipal } from "./principal.ts";
/** A server side that takes every call as `handle`, for tests with several people. */export const asPerson = (handle: Handle): Layer.Layer<Authenticated> => Layer.succeed(Authenticated, (effect) => Effect.provideService(effect, CurrentPrincipal, { handle }) );
/** A server side that takes every call as one person, for tests about other things. */export const asTester: Layer.Layer<Authenticated> = asPerson( Handle.make("tester"));modified:packages/protocol/test/cli.test.ts+2 added-1 removed
8 unmodified lines9 import { toCommand } from "../src/cli.ts";10 import { Client, Contracts, ListAsks, SubmitAnswer } from "../src/contracts.ts";11 import { CommitSha } from "../src/ids.ts";12 import { StaleBase } from "../src/refusal.ts";13-import { asTester, ask, base, main, path } from "./examples.ts";13+import { asTester } from "../src/testing.ts";14+import { ask, base, main, path } from "./examples.ts";15 16 const head = CommitSha.make("3333333333333333333333333333333333333333");17 18 /** Handlers that never refuse; `listAsks` echoes its project as the territory. */139 unmodified linesmodified:packages/protocol/test/examples.ts+2 added-10 removed
112343456727 unmodified lines35363738404142434445463940414232 unmodified linesimport { DateTime, Effect, Layer } from "effect";import { DateTime } from "effect";
import { AskId, CommitSha, Handle, RepoPath } from "../src/ids.ts";import { Authenticated, CurrentPrincipal } from "../src/principal.ts";import { AskId, CommitSha, RepoPath } from "../src/ids.ts";import { AskFull, AttemptsExhausted, CapReached,27 unmodified linesexport const main = CommitSha.make("2222222222222222222222222222222222222222");
export const path = RepoPath.make("src/a.ts");
/** A server side that takes every call as one person, for tests about other things. */export const asTester = Layer.succeed(Authenticated, (effect) => Effect.provideService(effect, CurrentPrincipal, { handle: Handle.make("tester"), }));
// One of each member, in the union's order.export const examples: readonly Refusal[] = [ NotClaimed.of(ask), ClaimLapsed.of(ask),32 unmodified linesmodified:packages/protocol/test/mcp.ts+1 added-1 removed
4 unmodified lines5 import { RpcTest } from "effect/rpc";6 7 import { Client, Contracts } from "../src/contracts.ts";8 import { toToolkit } from "../src/mcp.ts";9-import { asTester } from "./examples.ts";9+import { asTester } from "../src/testing.ts";10 11 const endpoint = "http://localhost/mcp";12 13 const protocol = McpProtocol.v2026_07_28;101 unmodified linesmodified:packages/protocol/package.json+2 added-1 removed
8 unmodified lines9 "./mcp": "./src/mcp.ts",10 "./posture": "./src/posture.ts",11 "./principal": "./src/principal.ts",12 "./refusal": "./src/refusal.ts",13- "./render": "./src/render.ts"13+ "./render": "./src/render.ts",14+ "./testing": "./src/testing.ts"15 },16 "scripts": {17 "typecheck": "tsc --noEmit -p tsconfig.json",18 "test": "vitest run"14 unmodified lines