Skip to content
Myr

Hear a project's adoption as a landing, so a project whose policy never evaluates is listed

Before adoption: this commit came in with the history the project adopted, so no landing records it.

An import or a first push kept its adopted main as a landing but emitted no event, and the front page writes a project's row on its first event: 17 of 38 imports on dev were in no list. landAdoption keeps the landing and pushes Landed for it; it credits no one. Tests that pinned event numbers move by one.

authored by oscabriel · committed by oscabriel · parent 6b9699a · Browse files · 8 files+114 added−46 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+114 added−46 removed

  • tests:+90 added−34 removed
  • other:+24 added−12 removed

8 files+114 added−46 removed

modified:apps/platform/test/handlers.test.ts+7 added-5 removed
178 unmodified lines
179 const later = yield* Stream.runCollect(180 bob.watch({ project: datekit.project, since: 1 })181 );182183 // Each ask's opening lands, so each is heard opened, then landed.183 // The adoption lands first; then each ask's opening lands, so each184 // is heard opened, then landed.185 expect(all.map(({ _tag }) => _tag)).toStrictEqual([186 "Landed",187 "AskOpened",188 "Landed",189 "AskOpened",190 "Landed",
11 unmodified lines
202203 const api = yield* (yield* Projects).get(datekit.project);204 const bobs = Person.make({ handle: Handle.make("bob") });205204 // 60 claims, each released: 120 events after datekit's two asks205 // opened, each heard opened and landed.206 // 60 claims, each released: 120 events after datekit's adoption207 // landed and its two asks opened, each heard opened and landed.208 yield* Effect.forEach(209 Array.range(1, 60),210 () =>211 Effect.andThen(
9 unmodified lines
221 bob.watch({ project: datekit.project })222 );223224 const tail = yield* Stream.runCollect(223 bob.watch({ project: datekit.project, since: 122 })225 bob.watch({ project: datekit.project, since: 123 })226 );227228 expect({229 count: all.length,230 first: all[0]?._tag,231 last: all.at(-1)?._tag,230 }).toStrictEqual({ count: 124, first: "AskOpened", last: "Released" });232 }).toStrictEqual({ count: 125, first: "Landed", last: "Released" });233 expect(tail.map(({ _tag }) => _tag)).toStrictEqual([234 "Claimed",235 "Released",236 ]);
719 unmodified lines
modified:apps/platform/test/watch.test.ts+41 added-23 removed
320 unmodified lines
321 },322 }).toStrictEqual({323 claimed: { ask: parseIso, claimant: "alice" },324 landed: { ask: parseIso, author: "alice", shown },325 replayed: ["1 AskOpened", "2 Landed"],326 resumed: ["4 Pushed", "5 Judged", "6 Landed", "7 AskClosed"],325 replayed: ["1 Landed", "2 AskOpened", "3 Landed"],326 resumed: ["5 Pushed", "6 Judged", "7 Landed", "8 AskClosed"],327 unbroken: { first: true, second: true },328 });329 // Over JSON, the same events replay and end.330 expect({ after: brief(after), kept: brief(kept) }).toStrictEqual({
114 unmodified lines
445const noon = "2026-10-07T12:00:00Z";446447describe("a Project DO's watch room, over a fake state and a real shell", () => {448 it.effect(449 "replays only the newest 500 events to a socket opened from 0 when 602 are recorded, in order, and tags it by the number it opened from",449 "replays only the newest 500 events to a socket opened from 0 when 603 are recorded, in order, and tags it by the number it opened from",450 () =>451 Effect.gen(function* () {452 yield* advanceTo(noon);453454 const { accepted, state } = fakeState();455 const room = watchRoom(state, yield* shellOver(":memory:"));456 const call = through(room);457458 // parse-iso opens and its opening lands (2 events), then 300459 // claims, each released (600).458 // The adoption lands, parse-iso opens and its opening lands (3459 // events), then 300 claims, each released (600).460 yield* opening(call);461 yield* Effect.forEach(462 Array.range(1, 300),463 () =>
13 unmodified lines
477 expect({478 count: frames.length,479 first: framed(frames.slice(0, 2)),480 last: framed(frames.slice(-1)),481 unbroken: frames.every(({ seq }, index) => seq === 103 + index),481 unbroken: frames.every(({ seq }, index) => seq === 104 + index),482 }).toStrictEqual({483 count: 500,484 first: ["103 Claimed", "104 Released"],485 last: ["602 Released"],484 first: ["104 Claimed", "105 Released"],485 last: ["603 Released"],486 unbroken: true,487 });488 expect(accepted.map(({ tags }) => tags)).toStrictEqual([489 [WATCH_TAG, "since:0"],
18 unmodified lines
508 const fromNow = doSocket();509 const gone = doSocket();510511 yield* room.admit(fromStart.socket, 0);512 yield* room.admit(fromNow.socket, 2);513 yield* room.admit(gone.socket, 2);512 yield* room.admit(fromNow.socket, 3);513 yield* room.admit(gone.socket, 3);514 close(gone.socket);515516 yield* call("claim", [bob, doParseIso]);517 yield* call("listAsks", [anyone]);
3 unmodified lines
521 fromNow: framed(yield* fromNow.frames),522 fromStart: framed(yield* fromStart.frames),523 gone: framed(yield* gone.frames),524 }).toStrictEqual({525 fromNow: ["3 Claimed", "4 Released"],526 fromStart: ["1 AskOpened", "2 Landed", "3 Claimed", "4 Released"],525 fromNow: ["4 Claimed", "5 Released"],526 fromStart: [527 "1 Landed",528 "2 AskOpened",529 "3 Landed",530 "4 Claimed",531 "5 Released",532 ],533 gone: [],534 });535 }).pipe(Effect.provide(doWorld))536 );
65 unmodified lines
602 yield* opening(call);603604 const watched = doSocket();605600 yield* room.admit(watched.socket, 2);606 yield* room.admit(watched.socket, 3);607 // Hibernation woke it without its attachment.608 watched.socket.serializeAttachment(null);609610 yield* call("claim", [bob, doParseIso]);611606 expect(framed(yield* watched.frames)).toStrictEqual(["3 Claimed"]);612 expect(framed(yield* watched.frames)).toStrictEqual(["4 Claimed"]);613 }).pipe(Effect.provide(doWorld))614 );615});616
125 unmodified lines
742 yield* opening(call);743744 const heard = yield* hearing(relayedFrom(namespace));745740 yield* heardUntil(heard, (events) => events.length >= 2);746 yield* heardUntil(heard, (events) => events.length >= 3);747 yield* call("claim", [bob, doParseIso]);748 yield* call("release", [bob, doParseIso]);749750 expect({751 heard: brief(746 yield* heardUntil(heard, (events) => events.length >= 4)752 yield* heardUntil(heard, (events) => events.length >= 5)753 ),754 opened: yield* opened,755 }).toStrictEqual({750 heard: ["1 AskOpened", "2 Landed", "3 Claimed", "4 Released"],756 heard: [757 "1 Landed",758 "2 AskOpened",759 "3 Landed",760 "4 Claimed",761 "5 Released",762 ],763 opened: [0],764 });765 }).pipe(Effect.provide(doWorld)),766 15_000
9 unmodified lines
776 yield* call("claim", [bob, doParseIso]);777778 const heard = yield* hearing(relayedFrom(namespace));779768 yield* heardUntil(heard, (events) => events.length >= 3);780 yield* heardUntil(heard, (events) => events.length >= 4);781782 // The DO restarts: its end of the socket closes.783 (yield* server)?.close(1012, "restarting");784
8 unmodified lines
793 yield* call("release", [bob, doParseIso]);794795 expect({796 heard: brief(785 yield* heardUntil(heard, (events) => events.length >= 4)797 yield* heardUntil(heard, (events) => events.length >= 5)798 ),799 opened: yield* opened,800 }).toStrictEqual({789 heard: ["1 AskOpened", "2 Landed", "3 Claimed", "4 Released"],790 opened: [0, 3],801 heard: [802 "1 Landed",803 "2 AskOpened",804 "3 Landed",805 "4 Claimed",806 "5 Released",807 ],808 opened: [0, 4],809 });810 }).pipe(Effect.provide(doWorld)),811 15_000812 );
11 unmodified lines
824 yield* call("claim", [bob, doParseIso]);825826 expect({827 heard: brief(810 yield* heardUntil(heard, (events) => events.length >= 3)828 yield* heardUntil(heard, (events) => events.length >= 4)829 ),830 opened: yield* opened,831 }).toStrictEqual({814 heard: ["1 AskOpened", "2 Landed", "3 Claimed"],832 heard: ["1 Landed", "2 AskOpened", "3 Landed", "4 Claimed"],833 opened: [],834 });835 }).pipe(Effect.provide(doWorld)),836 15_000
22 unmodified lines
modified:packages/agent-kit/src/llms-sections.ts+2 added-1 removed
modified:packages/agent-kit/test/golden/full-llms.txt+1 added-1 removed
159 unmodified lines
160- `AskOpened`: A new ask opened.161- `Claimed`: Someone claimed an ask.162- `Decided`: A decider took a decision.163- `Judged`: An answer was checked, with the outcome its verdict holds.164- `Landed`: A landing reached `main`.164- `Landed`: A landing reached `main`; the first is the project's adopted `main`, from its first push or its import.165- `Lapsed`: A claim lapsed: no push for too long.166- `LedgerAppended`: The project's public ledger gained an entry.167- `ProposalDrafted`: A proposal's draft settled: ready for a decider, or failed.168- `ProposalOpened`: A proposal opened.
26 unmodified lines
modified:packages/project/src/project.ts+22 added-11 removed
3788 unmodified lines
3789 * The first adoption as a landing: the initializer's first push, or an3790 * import's tip. It answers no ask and has no parent; its row lets3791 * `landing` (and so OnPush) know the commit as the platform's own.3792 */3793 /**3794 * The project's first landing, its adopted `main`: kept, and heard as3795 * every landing is, so the front page lists the project even when no3796 * policy evaluates and nothing else happens in it. It credits no one.3797 */3793 const adoption = (3798 const landAdoption = (3799 writes: Writes,3800 author: Handle,3801 sha: LandedSha,3802 now: DateTime.Utc3803 ) => {3797 ): LandingView => ({3798 assisted: [],3799 author,3800 credits: [],3801 landedAt: now,3802 project: name,3803 sha,3804 });3804 const landing: LandingView = {3805 assisted: [],3806 author,3807 credits: [],3808 landedAt: now,3809 project: name,3810 sha,3811 };38123813 writes.landings.push(landing);3814 writes.events.push(ProjectEventInput.Landed({ at: now, landing }));3815 };38163817 const initBody =3818 (3819 caller: Person,3820 input: {
27 unmodified lines
3848 }38493850 const landed = yield* adopt(input.import);38513841 writes.landings.push(adoption(caller.handle, landed, now));3852 landAdoption(writes, caller.handle, landed, now);3853 writes.project.set(3854 "row",3855 yield* withPolicyAt({ ...made, landed, state: "live" }, landed, now)3856 );
29 unmodified lines
3886 ? { landed }3887 : yield* refused;3888 }38893879 writes.landings.push(adoption(row.initializer, landed, now));3890 landAdoption(writes, row.initializer, landed, now);3891 writes.project.set(3892 "row",3893 yield* withPolicyAt({ ...row, landed, state: "live" }, landed, now)3894 );
1960 unmodified lines
modified:packages/project/test/do-reads.test.ts+2 added-1 removed
129 unmodified lines
130const world = Layer.mergeAll(worldOf(scenario, "memory"), NoVisibility, NoEnv);131132describe("a project's reads for its code and its people", () => {133 it.effect(134 "hear an ask's opening as a landing, naming the ask it opened, so a list of landings shows it",134 "hear the adoption and an ask's opening as landings, the opening naming the ask it opened, so a list of landings shows both",135 () =>136 Effect.map(read.pipe(Effect.provide(world)), (got) => {137 expect(138 got.landedEvents.map(({ ask, opened, sha }) => ({ ask, opened, sha }))139 ).toStrictEqual([140 { ask: undefined, opened: undefined, sha: got.adopted },141 { ask: undefined, opened: parseIso.id, sha: got.landed },142 ]);143 })144 );
181 unmodified lines
modified:packages/project/test/import.test.ts+33 added-1 removed
4 unmodified lines
5 */6import { describe, expect, it } from "@effect/vitest";7import { RefName, RepoHost } from "@repo/artifacts/repo-host";8import { memoryFs } from "@repo/artifacts/repo-host/memory-fs";9import { ProjectEvent } from "@repo/protocol/domain/event";10import { LandedSha, RepoName } from "@repo/protocol/ids";11import { Person } from "@repo/protocol/principal";12import { ProjectExists } from "@repo/protocol/refusal";13import { advanceTo } from "@repo/testkit/clock";14import { gitClient } from "@repo/testkit/git-client";15import { aProject } from "@repo/testkit/scenarios";15import { Effect, Exit, Option, Ref } from "effect";16import { DateTime, Effect, Exit, Option, Ref } from "effect";1718import { ProjectStore } from "../src/project-store.ts";19import { projectService } from "../src/project.ts";20import { worldOf } from "./world.ts";
125 unmodified lines
146 });147 }).pipe(Effect.provide(worldOf(scenario, "memory")))148 );149150 it.effect(151 "is heard as its adoption's landing, so a project whose policy never evaluates is listed",152 () =>153 Effect.gen(function* () {154 yield* advanceTo("2026-10-08T12:00:00Z");155156 const { tip, url } = yield* upstreamOnMaster;157 const api = yield* projectService(project);158159 yield* api.initProject(alice, { import: { url } });160161 const heard = yield* api.events(0, 10);162163 expect(heard.map(({ event }) => event._tag)).toStrictEqual(["Landed"]);164 expect(165 heard.flatMap(({ event }) =>166 ProjectEvent.guards.Landed(event) ? [event.landing] : []167 )168 ).toStrictEqual([169 {170 assisted: [],171 author: alice.handle,172 credits: [],173 landedAt: DateTime.makeUnsafe("2026-10-08T12:00:00Z"),174 project,175 sha: LandedSha.make(tip),176 },177 ]);178 }).pipe(Effect.provide(worldOf(scenario, "memory")))179 );180181 it.effect("still answers ProjectExists for a project that exists", () =>182 Effect.gen(function* () {183 yield* advanceTo("2026-10-08T12:00:00Z");184
11 unmodified lines
modified:packages/project/test/project.test.ts+6 added-3 removed
890 unmodified lines
891 it.effect(892 "5. its events come in order, and the projection heard every one",893 () =>894 Effect.map(seen, ({ answered }) => {895 // The ask's opening lands too, and is heard as a landing.895 // The adoption and the ask's opening land too, and are heard as896 // landings.897 expect(answered.events).toStrictEqual([898 "Landed",899 "AskOpened",900 "Landed",901 "Claimed",902 "Pushed",
319 unmodified lines
1222 ({ after, before }) => {1223 expect(before).toStrictEqual({1224 alarm: Option.some(DateTime.add(noon, { seconds: 1 })),1225 fork: false,1224 outbox: ["MakeFork", "Projected", "Projected"],1226 outbox: ["MakeFork", "Projected"],1227 });1228 // The adoption's landing is the event refused; the alarm projects it.1229 expect(after).toStrictEqual({1230 fork: true,1231 outbox: [],1229 projected: ["Claimed", "AskOpened", "Landed"],1232 projected: ["AskOpened", "Landed", "Claimed", "Landed"],1233 });1234 }1235 )1236 );
211 unmodified lines