Merge build/1316-adoption-heard 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 6b9699a, 4165fa3 · Browse files · 10 files·+193 added−56 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+193 added−56 removed
- tests:+152 added−35 removed
- other:+41 added−21 removed
Provenance
- Commit
2f3d065- Tree
79fd13a- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
6b9699a- Parent 2
4165fa3
10 files changed+193 added−56 removed
modified:apps/platform/test/front-page.test.ts+28 added
168 unmodified lines169 /** A client of the contracts over HTTP at `/rpc`, as anyone. */170 readonly anyone: Client["Service"];171 /** bob's answer to `parse-iso` landed, as his claim, push and submission make it. */172 readonly landAnswer: Effect.Effect<void>;173+ /** quietkit made and first pushed, and nothing else: no ask, no policy evaluated. */174+ readonly makeQuiet: Effect.Effect<void>;175 }176 177 const frontPageWorld: Effect.Effect<FrontPageWorld, never, Scope.Scope> =178 Effect.gen(function* () {82 unmodified lines261 forget: Effect.sync(() => {262 calls.length = 0;263 }),264 landAnswer,265+ makeQuiet: seeded(aProject({ name: "quietkit" })).pipe(266+ Effect.provideContext(ports)267+ ),268 };269 });270 271 describe("the project list and credits over the platform's /rpc", () => {272 it.effect(273+ "lists a project that was only made and first pushed, its adoption the one event it has",274+ () =>275+ Effect.gen(function* () {276+ yield* advanceTo(noon);277+278+ const world = yield* frontPageWorld;279+280+ yield* world.makeQuiet;281+282+ const { projects } = yield* world.anyone.listProjects({});283+284+ expect(285+ projects.find(({ project: listed }) => listed === "quietkit")286+ ).toStrictEqual({287+ landedAt: at(noon),288+ openAsks: 0,289+ posture: "open",290+ project: "quietkit",291+ });292+ }).pipe(Effect.scoped)293+ );294+295+ it.effect(296 "after a landing, lists the project from D1, asking it only its posture and only once, and its people's credits without calling a project",297 () =>298 Effect.gen(function* () {299 yield* advanceTo(noon);42 unmodified linesmodified:apps/platform/test/handlers.test.ts+7 added-5 removed
178 unmodified lines179 const later = yield* Stream.runCollect(180 bob.watch({ project: datekit.project, since: 1 })181 );182 183- // 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 lines202 203 const api = yield* (yield* Projects).get(datekit.project);204 const bobs = Person.make({ handle: Handle.make("bob") });205 204- // 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 lines221 bob.watch({ project: datekit.project })222 );223 224 const tail = yield* Stream.runCollect(223- bob.watch({ project: datekit.project, since: 122 })225+ bob.watch({ project: datekit.project, since: 123 })226 );227 228 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 linesmodified:apps/platform/test/watch.test.ts+41 added-23 removed
320 unmodified lines321 },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 lines445 const noon = "2026-10-07T12:00:00Z";446 447 describe("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);453 454 const { accepted, state } = fakeState();455 const room = watchRoom(state, yield* shellOver(":memory:"));456 const call = through(room);457 458- // 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 lines477 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 lines508 const fromNow = doSocket();509 const gone = doSocket();510 511 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);515 516 yield* call("claim", [bob, doParseIso]);517 yield* call("listAsks", [anyone]);3 unmodified lines521 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 lines602 yield* opening(call);603 604 const watched = doSocket();605 600- 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);609 610 yield* call("claim", [bob, doParseIso]);611 606- 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 lines742 yield* opening(call);743 744 const heard = yield* hearing(relayedFrom(namespace));745 740- 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]);749 750 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_0009 unmodified lines776 yield* call("claim", [bob, doParseIso]);777 778 const heard = yield* hearing(relayedFrom(namespace));779 768- yield* heardUntil(heard, (events) => events.length >= 3);780+ yield* heardUntil(heard, (events) => events.length >= 4);781 782 // The DO restarts: its end of the socket closes.783 (yield* server)?.close(1012, "restarting");784 8 unmodified lines793 yield* call("release", [bob, doParseIso]);794 795 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 lines824 yield* call("claim", [bob, doParseIso]);825 826 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_00022 unmodified linesmodified:packages/agent-kit/src/llms-sections.ts+2 added-1 removed
118 unmodified linesExpand all11912012112212312312412512612712815 unmodified lines118 unmodified linesExpand all AskOpened: "A new ask opened.", Claimed: "Someone claimed an ask.", Decided: "A decider took a decision.", Judged: "An answer was checked, with the outcome its verdict holds.", Landed: "A landing reached `main`.", Landed: "A landing reached `main`, a project's adoption (its first push or its import) among them.", Lapsed: "A claim lapsed: no push for too long.", LedgerAppended: "The project's public ledger gained an entry.", ProposalDrafted: "A proposal's draft settled: ready for a decider, or failed.",15 unmodified linesmodified:packages/agent-kit/test/golden/full-llms.txt+1 added-1 removed
159 unmodified lines160 - `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`, a project's adoption (its first push or its import) among them.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 linesmodified:packages/project/src/project.ts+38 added-19 removed
1174 unmodified lines1175 writes.ratchets.size,1176 ].every((count) => count === 0);1177 1178 /** A row's key in its table, as the store keys it. */1179+/**1180+ * Keeps `landing` and hears it as `Landed`: every landing that moves main1181+ * is heard, so a watcher and the front page see it (a project's row is1182+ * written on its first event).1183+ */1184+const keepLanding = (1185+ writes: Writes,1186+ landing: LandingView,1187+ now: DateTime.Utc1188+) => {1189+ writes.landings.push(landing);1190+ writes.events.push(ProjectEventInput.Landed({ at: now, landing }));1191+};1192+1193 const keyIn = <A>(table: Table<A>, row: A) => {1194 const columns = table.columns(row);1195 1196 return JSON.stringify(table.key.map((name) => columns[name]));1541 unmodified lines2738 };2739 2740 const moved = yield* withPolicyAt({ ...row, landed: sha }, sha, now);2741 2728- writes.landings.push(view);2729- writes.events.push(2730- ProjectEventInput.Landed({ at: now, landing: view })2731- );2742+ keepLanding(writes, view, now);2743 writes.project.set("row", moved);2744 });2745 2746 /**1050 unmodified lines3797 // ------------------------------------------------------------ writes3798 3799 /**3800 * 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.3801+ * import's tip. It answers no ask, has no parent and credits no one;3802+ * its row lets `landing` (and so OnPush) know the commit as the3803+ * platform's own, and its event lists the project on the front page3804+ * even when no policy evaluates and nothing else happens in it.3805 */3793- const adoption = (3806+ const landAdoption = (3807+ writes: Writes,3808 author: Handle,3809 sha: LandedSha,3810 now: DateTime.Utc3811+ ) => {3812+ keepLanding(3813+ writes,3797- ): LandingView => ({3798- assisted: [],3799- author,3800- credits: [],3801- landedAt: now,3802- project: name,3803- sha,3804- });3814+ {3815+ assisted: [],3816+ author,3817+ credits: [],3818+ landedAt: now,3819+ project: name,3820+ sha,3821+ },3822+ now3823+ );3824+ };3825 3826 const initBody =3827 (3828 caller: Person,28 unmodified lines3857 }3858 3859 const landed = yield* adopt(input.import);3860 3841- writes.landings.push(adoption(caller.handle, landed, now));3861+ landAdoption(writes, caller.handle, landed, now);3862 writes.project.set(3863 "row",3864 yield* withPolicyAt({ ...made, landed, state: "live" }, landed, now)3865 );29 unmodified lines3895 ? { landed }3896 : yield* refused;3897 }3898 3879- writes.landings.push(adoption(row.initializer, landed, now));3899+ landAdoption(writes, row.initializer, landed, now);3900 writes.project.set(3901 "row",3902 yield* withPolicyAt({ ...row, landed, state: "live" }, landed, now)3903 );535 unmodified lines4439 requestId: landed.requestId,4440 sha: landed.sha,4441 };4442 4423- writes.landings.push(landing);4443 // Heard as every landing is (main moved), so a list of landings4444 // shows the opening; it answers no ask, so it credits nothing.4426- writes.events.push(ProjectEventInput.Landed({ at: now, landing }));4445+ keepLanding(writes, landing, now);4446 writes.project.set(4447 "row",4448 yield* withPolicyAt({ ...row, landed: landed.sha }, landed.sha, now)4449 );1413 unmodified linesmodified:packages/project/test/do-reads.test.ts+2 added-1 removed
129 unmodified lines130 const world = Layer.mergeAll(worldOf(scenario, "memory"), NoVisibility, NoEnv);131 132 describe("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 linesmodified:packages/project/test/import.test.ts+65 added-2 removed
1 /**2 * A project adopted from a public repo, whatever its default branch, and3 * adopted again by a retry when the first import died after Artifacts made4- * the repo.4+ * the repo; and each adoption, an import's or a first push's, heard once5+ * as a landing.6 */7 import { describe, expect, it } from "@effect/vitest";8 import { RefName, RepoHost } from "@repo/artifacts/repo-host";9 import { memoryFs } from "@repo/artifacts/repo-host/memory-fs";10+import { ProjectEvent } from "@repo/protocol/domain/event";11 import { LandedSha, RepoName } from "@repo/protocol/ids";12 import { Person } from "@repo/protocol/principal";13 import { ProjectExists } from "@repo/protocol/refusal";14 import { advanceTo } from "@repo/testkit/clock";15 import { gitClient } from "@repo/testkit/git-client";16 import { aProject } from "@repo/testkit/scenarios";15-import { Effect, Exit, Option, Ref } from "effect";17+import { DateTime, Effect, Exit, Option, Ref } from "effect";18 19 import { ProjectStore } from "../src/project-store.ts";20 import { projectService } from "../src/project.ts";21 import { worldOf } from "./world.ts";125 unmodified lines147 });148 }).pipe(Effect.provide(worldOf(scenario, "memory")))149 );150 151+ it.effect(152+ "is heard as its adoption's landing, so a project whose policy never evaluates is listed",153+ () =>154+ Effect.gen(function* () {155+ yield* advanceTo("2026-10-08T12:00:00Z");156+157+ const { tip, url } = yield* upstreamOnMaster;158+ const api = yield* projectService(project);159+160+ yield* api.initProject(alice, { import: { url } });161+162+ const heard = yield* api.events(0, 10);163+164+ expect(heard.map(({ event }) => event._tag)).toStrictEqual(["Landed"]);165+ expect(166+ heard.flatMap(({ event }) =>167+ ProjectEvent.guards.Landed(event) ? [event.landing] : []168+ )169+ ).toStrictEqual([170+ {171+ assisted: [],172+ author: alice.handle,173+ credits: [],174+ landedAt: DateTime.makeUnsafe("2026-10-08T12:00:00Z"),175+ project,176+ sha: LandedSha.make(tip),177+ },178+ ]);179+ }).pipe(Effect.provide(worldOf(scenario, "memory")))180+ );181+182 it.effect("still answers ProjectExists for a project that exists", () =>183 Effect.gen(function* () {184 yield* advanceTo("2026-10-08T12:00:00Z");185 7 unmodified lines193 ).toStrictEqual(new ProjectExists({ project }));194 }).pipe(Effect.provide(worldOf(scenario, "memory")))195 );196 });197+198+describe("a first push", () => {199+ it.effect(200+ "is heard once as the adoption's landing, however often it is recorded",201+ () =>202+ Effect.gen(function* () {203+ yield* advanceTo("2026-10-08T12:00:00Z");204+205+ const api = yield* projectService(project);206+ const client = yield* gitClient(memoryFs());207+208+ const first = yield* client.commit("Start", [209+ ["README.md", "# start\n"],210+ ]);211+212+ yield* api.initProject(alice, {});213+ yield* (yield* RepoHost)214+ .push(repo, client.source, [215+ { from: Option.none(), ref: mainRef, to: first },216+ ])217+ .pipe(Effect.orDie);218+ yield* api.recordFirstPush(alice, first);219+ yield* api.recordFirstPush(alice, first);220+221+ const heard = yield* api.events(0, 10);222+223+ expect(heard.map(({ event }) => event._tag)).toStrictEqual(["Landed"]);224+ }).pipe(Effect.provide(worldOf(scenario, "memory")))225+ );226+});modified:packages/project/test/project.test.ts+8 added-3 removed
890 unmodified lines891 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 lines1222 ({ 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 it1229+ // again, after the later events (the memory projection keeps no1230+ // cursor).1231 expect(after).toStrictEqual({1232 fork: true,1233 outbox: [],1229- projected: ["Claimed", "AskOpened", "Landed"],1234+ projected: ["AskOpened", "Landed", "Claimed", "Landed"],1235 });1236 }1237 )1238 );211 unmodified linesmodified:GLOSSARY.md+1 added-1 removed
71 unmodified lines72 The cost-ordered chain of stages that narrows a push to a checked tree or a refusal.73 _Avoid_: CI, pipeline, merge queue74 75 **Landing**:76-The platform's commit of a checked tree to main, written by the platform with credit trailers. An ask's opening is a landing too: it opens an ask and answers none.76+The platform's commit of a checked tree to main, written by the platform with credit trailers. An ask's opening is a landing too: it opens an ask and answers none. So is a project's adoption, its first `main` from the initializer's first push or an import: it answers no ask, has no parent and credits no one.77 _Avoid_: merge, ship78 79 **Landed SHA**:80 The commit the platform itself last landed on main; the only commit a project's rules are read from.139 unmodified lines