Merge build/imported-from 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 e3cfe48, 93641b3 · Browse files · 20 files·+638 added−62 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
20 files+638 added−62 removed
- tests:+307 added−3 removed
- other:+331 added−59 removed
Provenance
- Commit
f224a14- Tree
0dfaac3- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
e3cfe48- Parent 2
93641b3
20 files changed+638 added−62 removed
modified:apps/cli/src/render.ts+21 added-3 removed
1 unmodified line2 * The CLI's prose for the contracts' results: Markdown for an agent (and a3 * script), and plain text for a person where a table reads better padded.4 * A contract without a view here prints its encoded JSON in a fenced block.5 */6+import { IMPORTED_NOTE } from "@repo/agent-kit/docs/imported-note";7 import { Brand } from "@repo/brand";8 import type { View } from "@repo/protocol/cli";9 import {10 Claim,14 unmodified lines25 import { LandReceipt } from "@repo/protocol/domain/answer";26 import type { AnswerReceipt } from "@repo/protocol/domain/answer";27 import { DecisionSubject } from "@repo/protocol/domain/decision";28 import { Outcome } from "@repo/protocol/domain/outcome";28-import type { PolicyPending, PublicPolicy } from "@repo/protocol/domain/policy";29+import type {30+ ImportSource,31+ PolicyPending,32+ PublicPolicy,33+} from "@repo/protocol/domain/policy";34 import { LedgerEntry } from "@repo/protocol/domain/visibility";35 import type { Refusal } from "@repo/protocol/refusal";36 import { receiptLine } from "@repo/protocol/render";37 import { DateTime, Option, Result, Schema } from "effect";404 unmodified lines442 `Fix it by landing a change to ${Brand.configDir}/; it is evaluated again at every landing.`,443 ];444 };445 441-const policy = viewOf(PolicyOf.successSchema, (read) => {446+/** Where an imported project came from, and what a copy is (ADR 0031). */447+const importedText = ({ branch, url }: ImportSource) =>448+ prose(449+ `Imported from ${url}${branch === undefined ? "" : ` (branch ${branch})`}: this project is ${IMPORTED_NOTE}.`450+ );451+452+/** The policy's own view: evaluated, why not yet, or nothing landed. */453+const policyText = (read: typeof PolicyOf.successSchema.Type): View => {454 if (read.policy !== undefined) {455 return evaluated(read.policy);456 }457 5 unmodified lines463 464 const lines = pendingText(read.unevaluated);465 466 return { markdown: lines.join("\n\n"), text: lines.join("\n") };455-});467+};468 469+const policy = viewOf(PolicyOf.successSchema, (read) =>470+ read.importedFrom === undefined471+ ? policyText(read)472+ : joined(importedText(read.importedFrom), policyText(read))473+);474+475 const ledger = viewOf(LedgerOf.successSchema, (book) =>476 joined(477 prose(`${book.project}: ${book.postureLabel}.`),478 table(104 unmodified linesmodified:apps/cli/test/policy-view.test.ts+32 added
179 unmodified lines180 unanswered,181 Contracts.toLayerHandler("projectPolicy", () => Effect.succeed(success))182 );183 184+describe("policy's view of an imported project", () => {185+ const imported = decodeSuccess({186+ importedFrom: {187+ branch: "master",188+ url: "https://github.com/dtolnay/anyhow",189+ },190+ unevaluated: { at: sha, reason: "noConfig" },191+ });192+193+ it("leads with where it came from and its branch, as a copy read-only here, then the policy", () => {194+ const lines = linesOf(textOf(imported));195+196+ expect(lines[0]).toBe(197+ "Imported from https://github.com/dtolnay/anyhow (branch master): this project is a copy of a public repo, read-only here and not run by its maintainers."198+ );199+ expect(200+ lines.some((line) => line.includes("has not been evaluated"))201+ ).toBeTruthy();202+ });203+204+ it("names no branch when the import named none, and no source for a project that started empty", () => {205+ expect(206+ textOf(207+ decodeSuccess({208+ importedFrom: { url: "https://codeberg.org/dnkl/fuzzel" },209+ })210+ )211+ ).toContain("Imported from https://codeberg.org/dnkl/fuzzel: this project");212+ expect(textOf(noConfig)).not.toContain("Imported from");213+ });214+});215+216 describe("policy on the command line", () => {217 it.effect("prints the text view for a person", () =>218 Effect.gen(function* () {219 const run = yield* runProgram(["policy", "--project", "datekit"], {26 unmodified linesmodified:apps/web/src/features/project/project-page.tsx+39 added-1 removed
6 unmodified lines7 * from them. Props in, markup out: the route reads the asks, the ledger,8 * the events, the policy and the code on the server and keeps them live in9 * the browser, and hands them here.10 */11+import { IMPORTED_NOTE } from "@repo/agent-kit/docs/imported-note";12 import { Brand } from "@repo/brand";13 import type { Ask, AskListing } from "@repo/protocol/domain/ask";14 import type { FileView, TreeListing } from "@repo/protocol/domain/code";15 import type { Glob } from "@repo/protocol/domain/common";16 import type { ProjectListing } from "@repo/protocol/domain/front-page";17 import type { LandingView } from "@repo/protocol/domain/landing";18+import type { ImportSource } from "@repo/protocol/domain/policy";19 import { LedgerEntry } from "@repo/protocol/domain/visibility";20 import type { Ledger } from "@repo/protocol/domain/visibility";21 import type { AreaName, AskId, Handle, ProjectName } from "@repo/protocol/ids";22 import type { Posture } from "@repo/protocol/posture";12 unmodified lines35 import { finaleOf, stillWaiting } from "../front/families.ts";36 import { ledeOf } from "../front/head.ts";37 import { ProposeLink } from "../propose/propose-link.tsx";38 import type { AskProgress } from "../shared/ask-progress.ts";39+import { LINK } from "../shared/classes.ts";40 import { CommandLine } from "../shared/command.tsx";41 import { EmptyState } from "../shared/empty.tsx";42 import {43 FactBlock,111 unmodified lines155 /** What it holds back, from its ledger; none while it is read. */156 readonly heldBack?: readonly HeldBackArea[] | undefined;157 /** Who decides for which paths; none while the policy is read or when it has none. */158 readonly deciders?: readonly Deciders[] | undefined;159+ /** Where it was imported from; none for a project that started empty, or while the policy is read. */160+ readonly importedFrom?: ImportSource | undefined;161 readonly now: DateTime.Utc;162 readonly platformUrl: string;163 /** The root folder at main and its README, once read. */164 readonly code?: ProjectCode | undefined;46 unmodified lines211 </FactBlock>212 );213 };214 215+/** Where an imported project came from: its source, the branch adopted, and what a copy is. */216+const ImportedFrom = ({ source }: { readonly source: ImportSource }) => (217+ <FactBlock label="Imported from">218+ <p className="text-ui">219+ <a220+ className={`${LINK} [overflow-wrap:anywhere]`}221+ href={source.url}222+ rel="noreferrer"223+ >224+ {source.url}225+ </a>226+ {source.branch === undefined ? null : (227+ <>228+ {" "}229+ · branch <MetaCode>{source.branch}</MetaCode>230+ </>231+ )}232+ </p>233+ <p className="text-ui text-muted-foreground">234+ This project is {IMPORTED_NOTE}.235+ </p>236+ </FactBlock>237+);238+239 /** The four commands that take part, in the order a newcomer runs them. */240 const TakePart = ({241 platformUrl,242 project,70 unmodified lines313 /** How a change lands here: the facts with nothing selected. */314 const HowItLands = ({315 deciders,316 heldBack,317+ importedFrom,318 landedAt,319 landings,320 listing,321 now,322 platformUrl,323 posture,324 }: Pick<325 ProjectViewProps,296- "deciders" | "heldBack" | "landings" | "listing" | "now" | "platformUrl"326+ | "deciders"327+ | "heldBack"328+ | "importedFrom"329+ | "landings"330+ | "listing"331+ | "now"332+ | "platformUrl"333 > & {334 readonly posture: KnownPosture | undefined;335 readonly landedAt: DateTime.Utc | undefined;336 }) => (9 unmodified lines346 )}347 <GateFacts />348 <WhoDecides deciders={deciders} project={listing.project} />349 {heldBack === undefined ? null : <HeldBackFacts areas={heldBack} />}350+ {importedFrom === undefined ? null : <ImportedFrom source={importedFrom} />}351 <TakePart platformUrl={platformUrl} project={listing.project} />352 <RecentLandings353 landedAt={landedAt}354 landings={landings}134 unmodified lines489 return (490 <HowItLands491 deciders={props.deciders}492 heldBack={props.heldBack}493+ importedFrom={props.importedFrom}494 landedAt={landedAt}495 landings={props.landings}496 listing={listing}497 now={props.now}148 unmodified linesmodified:apps/web/src/routes/$project/index.tsx+5 added-2 removed
186 unmodified lines187 data.code,188 (read) => read189 );190 191- const deciders = valueOr(191+ const policyRead = valueOr(192 useAtomValue(projectPolicyAtom(project)),193 data.policy,194 (read) => read195- )?.policy?.deciders;195+ );196 197+ const deciders = policyRead?.policy?.deciders;198+199 const reads = useMemo(200 () => new Map(events === undefined ? [] : [[project, events]]),201 [events, project]202 );8 unmodified lines211 asks={asks}212 code={code}213 deciders={deciders}214 heldBack={ledger === undefined ? undefined : heldBackOf(ledger)}215+ importedFrom={policyRead?.importedFrom}216 landings={landings}217 lastLanded={latest?.landedAt}218 listing={homeListing({ asks, ledger, project })}219 now={data.now}96 unmodified linesmodified:apps/web/src/server/project-page.ts+3 added-9 removed
2 unmodified lines3456778910111112131428 unmodified lines4344454648495051525354474849505152119 unmodified linesExpand all2 unmodified lines * its loader reads (its asks, its own ledger, its events, its policy, its * root folder and README, then each family's parent in full), and its GET, * which gives a request for Markdown the project's `llms.txt`. */import { Client } from "@repo/protocol/contracts";import { Client, PolicyOf } from "@repo/protocol/contracts";import { Ask, AskListing } from "@repo/protocol/domain/ask";import { FileView, TreeListing } from "@repo/protocol/domain/code";import { ProjectEvent } from "@repo/protocol/domain/event";import { PolicyPending, PublicPolicy } from "@repo/protocol/domain/policy";import { Ledger } from "@repo/protocol/domain/visibility";import { ProjectName } from "@repo/protocol/ids";import { UnknownProject } from "@repo/protocol/refusal";import { notFound } from "@tanstack/react-router";28 unmodified lines events: Schema.optionalKey(Schema.Array(ProjectEvent)), ledger: Schema.optionalKey(Ledger), now: Schema.DateTimeUtcFromString, parents: Schema.Array(Ask), /** The project's policy, as `projectPolicy` gives it. */ policy: Schema.optionalKey( Schema.Struct({ policy: Schema.optionalKey(PublicPolicy), unevaluated: Schema.optionalKey(PolicyPending), }) ), /** The project's policy, and where it was imported from, as `projectPolicy` gives them. */ policy: Schema.optionalKey(PolicyOf.successSchema), project: ProjectName,});
export type ProjectPageData = typeof ProjectPageData.Type;119 unmodified linesExpand allmodified:apps/web/test/project.test.tsx+33 added
391 unmodified lines392 })393 );394 395 it.effect(396+ "names where an imported project came from, with its branch, as a copy read-only here; and nothing for one that started empty",397+ () =>398+ Effect.gen(function* () {399+ const facts = inspectorOf(400+ yield* page({401+ importedFrom: {402+ branch: "master",403+ url: "https://github.com/dtolnay/anyhow",404+ },405+ })406+ );407+408+ const text = textIn(facts);409+410+ expect(411+ missingFrom(text, [412+ "Imported from",413+ "https://github.com/dtolnay/anyhow",414+ "branch master",415+ "This project is a copy of a public repo, read-only here and not run by its maintainers.",416+ ])417+ ).toStrictEqual([]);418+ expect(facts).toMatch(419+ /<a[^>]*href="https:\/\/github\.com\/dtolnay\/anyhow"[^>]*rel="noreferrer"/u420+ );421+ expect(textIn(inspectorOf(yield* page()))).not.toContain(422+ "Imported from"423+ );424+ })425+ );426+427+ it.effect(428 "gives the four commands that take part, numbered, and the last three landings as one-line credits",429 () =>430 Effect.gen(function* () {431 const facts = inspectorOf(yield* page());217 unmodified lines649 asks={data.asks}650 code={data.code}651 deciders={data.policy?.policy?.deciders}652 heldBack={data.ledger === undefined ? undefined : heldBackOf(data.ledger)}653+ importedFrom={data.policy?.importedFrom}654 landings={recentLandings(events)}655 lastLanded={latest?.landedAt}656 listing={homeListing({657 asks: data.asks,250 unmodified linesadded:docs/adr/0031-an-import-keeps-its-source-and-a-repeat-by-the-initializer-converges.md+21 added
123456789101112131415161718192021---status: accepted---
# An import keeps its source, and a repeat by the initializer converges
An imported project (ADR 0010) is a copy of a public repo, read-only here and not run by its maintainers, and its own page said nothing of where it came from: the import's URL and branch arrived in `initProject` and were dropped once the tip was adopted. The project's row now keeps them as `importedFrom`, the shape `initProject` takes (`ImportSource`), and `projectPolicy` names them beside the policy, so the project's page, the CLI's `policy` and MCP show "Imported from" from one read. A project that started empty has no such field.
The thirty-eight imports already on a stage were made before the field existed, and the platform has no operator-only write to a project. Rather than add one, `initProject` converges: asked again by the project's initializer with an `import`, for a row whose adoption landed in the call that made it (its adoption landing's `landedAt` is the row's `createdAt`, where a first push lands later), it writes the source if the row keeps none, or answers as the first call did if the row keeps the same one. Any other repeat, by someone else, with another source, or for a project that started empty, is `ProjectExists` as before. `import-examples --sources` runs that call once per import the ledger records on the stage, listed by the platform or not.
## Considered Options
- **An operator-only `setSource` contract.** A second write path to a project's record, with its own audience and surface, for a one-time backfill of forty rows. Converging the write that exists keeps principle 8 (re-running an operation converges) and adds nothing to the public contract.- **Look the name up in the docs' imported list on the web.** No backend change, but it covers only the curated imports, not a project someone imports with `init --import`, and the page would state a source the platform never recorded.- **Keep the source on `ProjectListing`.** The listing is the front-page projection's, built from events; a project's own record is the right home, and the listing has no row for an import adopted before adoptions were heard.
## Consequences
- `ProjectRow` gains an optional field, decoded on read; a row without it still decodes, so no migration.- `import-examples` treats a project the ledger records as this stage's import as known, whether or not the platform lists it, so the seventeen unlisted imports are never taken for new ones.- A first push that lands in the same instant as its project's creation would read as an import's row; two separate calls never share an instant on a real clock, and tests move the clock between them.added:packages/agent-kit/src/docs/imported-note.ts+7 added
1234567/** * What an imported project is, in the words the docs' Imported projects * page, the project's own page and the CLI's `policy` share. A module of * its own, so a page that says it does not carry the imported list. */export const IMPORTED_NOTE = "a copy of a public repo, read-only here and not run by its maintainers";modified:packages/agent-kit/src/docs/reference.ts+2 added-1 removed
16 unmodified lines17 import type { CommandDoc } from "../command-doc.ts";18 import { events, gitHere, landing, refusals } from "../llms-sections.ts";19 import { exitCodeSection } from "../refusals.ts";20 import { code, table } from "../text.ts";21+import { IMPORTED_NOTE } from "./imported-note.ts";22 import { importedProjects } from "./imported.ts";23 import type { DocSource } from "./page.ts";24 import { withoutHeading } from "./page.ts";25 66 unmodified lines92 };93 94 export const importedPage: DocSource = {95 body: () => [95- "These projects are copies of public repos, imported so you can read code you know on the platform. Each is read-only here and is not run by its maintainers; its history, with its authors, came with it, and why each line is there reads as before adoption. Each stays under its own licence.",96+ `These projects were imported so you can read code you know on the platform. Each is ${IMPORTED_NOTE}; its history, with its authors, came with it, and why each line is there reads as before adoption. Each stays under its own licence.`,97 "",98 ...table(99 ["Project", "Source", "Licence", "What it is"],100 importedProjects.map(({ kind, licence, project, url }) => [10 unmodified linesmodified:packages/config/test/import-examples.test.ts+107 added
546 unmodified lines547 (yield* platform.calls).filter((call) => /ky|anyhow/u.test(call))548 ).toStrictEqual(["ls-remote anyhow", "tags anyhow"]);549 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))550 );551+552+ it.live(553+ "--sources asks initProject again for each import the ledger records, listed or not, and never for a listed project it doesn't",554+ () =>555+ Effect.gen(function* () {556+ const fs = yield* FileSystem.FileSystem;557+ const path = yield* Path.Path;558+559+ const dir = yield* fs.makeTempDirectoryScoped({ prefix: "importing-" });560+561+ const ledgerFile = path.join(dir, "created.jsonl");562+563+ // An earlier run imported anyhow and gum; the platform lists anyhow564+ // and ky (someone else's project), and gum not yet.565+ const platform = yield* fakePlatform(["anyhow", "ky"]);566+567+ yield* fs.writeFileString(568+ ledgerFile,569+ ["anyhow", "gum"]570+ .map(571+ (name) =>572+ `${JSON.stringify({ at: "2026-10-08T20:00:00.000Z", by: "import", kind: "project", name, stage: "dev-oscabriel" })}\n`573+ )574+ .join("")575+ );576+577+ const printed: string[] = [];578+579+ yield* importExamples(580+ onDev("--only", "gum", "--sources"),581+ () => platform.layer582+ ).pipe(583+ Effect.provideService(LedgerFile, ledgerFile),584+ Effect.provideService(Console.Console, {585+ ...console,586+ log: (...args: readonly unknown[]) => {587+ printed.push(args.map(String).join(" "));588+ },589+ })590+ );591+592+ yield* importExamples(onDev("--sources"), () => platform.layer).pipe(593+ Effect.provideService(LedgerFile, ledgerFile),594+ Effect.provideService(Console.Console, {595+ ...console,596+ log: () => {},597+ })598+ );599+600+ expect(601+ (yield* platform.calls).filter((call) => /gum|anyhow|ky/u.test(call))602+ ).toStrictEqual([603+ "init gum main",604+ "init anyhow master",605+ "init gum main",606+ ]);607+ expect(printed).toStrictEqual([608+ "import-examples on dev-oscabriel (https://platform.test): 0 to import, 1 listed already",609+ " skip gum: imported already, as the ledger records",610+ " gum: source kept: https://github.com/charmbracelet/gum (main)",611+ "imported 0 of 0, each recorded in infra/created.jsonl as a kept import",612+ ]);613+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))614+ );615+616+ it.live(617+ "--sources --dry-run prints each source it would keep, and keeps none",618+ () =>619+ Effect.gen(function* () {620+ const platform = yield* fakePlatform(["anyhow"]);621+622+ const { ledger, printed } = yield* ran(623+ onDev("--only", "anyhow", "--sources", "--dry-run"),624+ platform.layer625+ );626+627+ expect({628+ calls: yield* platform.calls,629+ ledger,630+ printed: printed.filter((line) => line.includes("source")),631+ }).toStrictEqual({632+ calls: ["listProjects"],633+ ledger: [],634+ printed: [],635+ });636+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))637+ );638+639+ it.live(640+ "--sources in the Node world goes over every example listed, with no ledger",641+ () =>642+ Effect.gen(function* () {643+ const platform = yield* fakePlatform(["anyhow", "ky"]);644+645+ const { printed } = yield* ran(646+ ["--world", "node", "--sources", "--dry-run"],647+ platform.layer648+ );649+650+ expect(printed.filter((line) => line.includes("source"))).toStrictEqual(651+ [652+ " would keep the source of anyhow: https://github.com/dtolnay/anyhow (master)",653+ " would keep the source of ky: https://github.com/sindresorhus/ky (main)",654+ ]655+ );656+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))657+ );658 });659 660 /** A call the platform never answered, as an edge timeout leaves it. */661 class NoAnswer extends Data.TaggedError("NoAnswer")<{72 unmodified linesmodified:packages/project/src/project-store/rows.ts+5 added-1 removed
1 unmodified line2 import { AgentTrailer } from "@repo/protocol/domain/credit";3 import { Decision } from "@repo/protocol/domain/decision";4 import { ProjectEvent } from "@repo/protocol/domain/event";5 import { LandingView } from "@repo/protocol/domain/landing";6+import { ImportSource } from "@repo/protocol/domain/policy";7 import { Proposal } from "@repo/protocol/domain/proposal";8 import { LedgerEntry } from "@repo/protocol/domain/visibility";9 import {10 AreaName,17 unmodified lines28 // service does, with the lifecycles' own schemas.29 30 /**31 * A project: whether it waits for its initializer's first push or is live,31- * the SHA the platform last landed, and the policy cached for one landed SHA.32+ * the SHA the platform last landed, the policy cached for one landed SHA,33+ * and where it was imported from, when it was.34 */35 export const ProjectRow = Schema.Struct({36 createdAt: Schema.DateTimeUtcFromString,37+ /** The public repo it was imported from; absent for a project that started empty. */38+ importedFrom: Schema.optionalKey(ImportSource),39 initializer: Handle,40 landed: Schema.optionalKey(LandedSha),41 /** The encoded `Policy` evaluated at `policyAt`. */42 policy: Schema.optionalKey(Schema.Json),212 unmodified linesmodified:packages/project/src/project.ts+111 added-11 removed
113 unmodified lines114 import type { AskKind } from "@repo/protocol/domain/kind";115 import { LandingView } from "@repo/protocol/domain/landing";116 import { Outcome } from "@repo/protocol/domain/outcome";117 import type { StageName } from "@repo/protocol/domain/outcome";118-import type { PublicPolicy } from "@repo/protocol/domain/policy";118+import type { ImportSource, PublicPolicy } from "@repo/protocol/domain/policy";119 import { Policy } from "@repo/protocol/domain/policy";120 import type { Proposal } from "@repo/protocol/domain/proposal";121 import {122 AskId,1279 unmodified lines1402 Match.whenOr("check", "territory", () => true),1403 Match.exhaustive1404 );1405 1406+/** Whether two import sources name the same repo and branch (ADR 0031). */1407+const sameSource = (a: ImportSource, b: ImportSource) =>1408+ a.url === b.url && a.branch === b.branch;1409+1410 /** An optional field as an object to spread: the field when present, nothing when not. */1411 const field = <K extends string, A>(1412 key: K,1413 value: Option.Option<A>1195 unmodified lines2609 */2610 const policyStatus: Effect.Effect<PolicyStatus> = Effect.gen(function* () {2611 const h = yield* hydrate;2612 2613+ // Where the project came from, when it was imported (ADR 0031).2614+ const origin = field(2615+ "importedFrom",2616+ Option.flatMapNullishOr(h.project, (row) => row.importedFrom)2617+ );2618+2619 if (Option.isSome(h.policy)) {2610- return { policy: publicPolicy(h.policy.value) };2620+ return { ...origin, policy: publicPolicy(h.policy.value) };2621 }2622 2623 const landed = Option.flatMapNullishOr(h.project, (row) => row.landed);2624 2625 if (Option.isNone(landed)) {2616- return {};2626+ return origin;2627 }2628 2629 const at = landed.value;2630 2631 return {2632+ ...origin,2633 unevaluated: {2634 at,2635 reason: (yield* hasConfigAt(at))2636 ? ("configFailed" as const)1196 unmodified lines3833 now3834 );3835 };3836 3826- const initBody =3827- (3828- caller: Person,3829- input: {3830- readonly import?: { readonly branch?: string; readonly url: string };3837+ /**3838+ * The project's adoption, the one landing with no parent: in the3839+ * snapshot's newest landings, else found by walking back from the last3840+ * landed SHA through each landing's parent.3841+ */3842+ const adoptionOf = (h: Hydrated, row: ProjectRow) =>3843+ Effect.gen(function* () {3844+ const kept = h.landings.find(({ parent }) => parent === undefined);3845+3846+ if (kept !== undefined || row.landed === undefined) {3847+ return Option.fromNullishOr(kept);3848 }3849+3850+ let at = Option.some<CommitSha>(row.landed);3851+3852+ while (Option.isSome(at)) {3853+ const found = yield* store.landing(at.value);3854+3855+ if (Option.isNone(found)) {3856+ return Option.none<LandingView>();3857+ }3858+3859+ if (found.value.parent === undefined) {3860+ return found;3861+ }3862+3863+ at = Option.some<CommitSha>(found.value.parent);3864+ }3865+3866+ return Option.none<LandingView>();3867+ });3868+3869+ /**3870+ * An import asked again by its initializer converges (ADR 0031): with3871+ * the source the row keeps, it answers as the first call did; for a row3872+ * that keeps no source yet, the source is written first. Only an3873+ * import's row takes one: its adoption landed in the call that made it,3874+ * so the adoption's `landedAt` is the row's `createdAt`, where a first3875+ * push lands later. Any other repeat is `ProjectExists`, as before.3876+ */3877+ const keepSource = (3878+ caller: Person,3879+ from: ImportSource,3880+ row: ProjectRow,3881+ h: Hydrated,3882+ writes: Writes3832- ) =>3883+ ) =>3884+ Effect.gen(function* () {3885+ const exists = new ProjectExists({ project: name });3886+3887+ if (3888+ row.landed === undefined ||3889+ !sameHandle(row.initializer, caller.handle)3890+ ) {3891+ return yield* exists;3892+ }3893+3894+ const answer = {3895+ landed: row.landed,3896+ project: name,3897+ remote: `${yield* GatewayUrl}/${name}.git`,3898+ };3899+3900+ if (row.importedFrom !== undefined) {3901+ return sameSource(row.importedFrom, from) ? answer : yield* exists;3902+ }3903+3904+ const adoption = yield* adoptionOf(h, row);3905+3906+ if (3907+ Option.isNone(adoption) ||3908+ DateTime.toEpochMillis(adoption.value.landedAt) !==3909+ DateTime.toEpochMillis(row.createdAt)3910+ ) {3911+ return yield* exists;3912+ }3913+3914+ writes.project.set("row", { ...row, importedFrom: from });3915+3916+ return answer;3917+ });3918+3919+ const initBody =3920+ (caller: Person, input: { readonly import?: ImportSource }) =>3921 (h: Hydrated, writes: Writes, now: DateTime.Utc) =>3922 Effect.gen(function* () {3923 if (Option.isSome(h.project)) {3836- return yield* new ProjectExists({ project: name });3924+ return input.import === undefined3925+ ? yield* new ProjectExists({ project: name })3926+ : yield* keepSource(3927+ caller,3928+ input.import,3929+ h.project.value,3930+ h,3931+ writes3932+ );3933 }3934 3935 const remote = `${yield* GatewayUrl}/${name}.git`;3936 19 unmodified lines3956 3957 landAdoption(writes, caller.handle, landed, now);3958 writes.project.set(3959 "row",3864- yield* withPolicyAt({ ...made, landed, state: "live" }, landed, now)3960+ yield* withPolicyAt(3961+ { ...made, importedFrom: input.import, landed, state: "live" },3962+ landed,3963+ now3964+ )3965 );3966 3967 return { landed, project: name, remote };3968 });1994 unmodified linesmodified:packages/project/test/import.test.ts+117 added-3 removed
6 unmodified lines7 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";11+import { Handle, 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";17-import { DateTime, Effect, Exit, Option, Ref } from "effect";17+import { DateTime, Effect, Exit, Option, Ref, Struct } from "effect";18 19 import { ProjectStore } from "../src/project-store.ts";20 import { projectService } from "../src/project.ts";21 import { worldOf } from "./world.ts";5 unmodified lines27 const repo = RepoName.make(project);28 29 const alice = Person.make({ handle: scenario.initializer });30 31+const bob = Person.make({ handle: Handle.make("bob") });32+33 const mainRef = RefName.make("refs/heads/main");34 35+/**36+ * The project's row as an import written before sources were kept left it37+ * (ADR 0031): the same row without `importedFrom`.38+ */39+const forgetSource = ProjectStore.use((store) =>40+ Effect.flatMap(store.load(), ({ project: row }) =>41+ Option.match(row, {42+ onNone: () => Effect.void,43+ onSome: (kept) =>44+ store.commit({ project: Struct.omit(kept, ["importedFrom"]) }),45+ })46+ )47+);48+49 const masterRef = RefName.make("refs/heads/master");50 51 /**52 * A public remote `upstream` whose only branch is `master`, as anyhow's141 unmodified lines194 ]);195 }).pipe(Effect.provide(worldOf(scenario, "memory")))196 );197 182- it.effect("still answers ProjectExists for a project that exists", () =>198+ it.effect(199+ "keeps where it came from on its row, and projectPolicy names it",200+ () =>201+ Effect.gen(function* () {202+ yield* advanceTo("2026-10-08T12:00:00Z");203+204+ const { url } = yield* upstreamOnMaster;205+ const api = yield* projectService(project);206+207+ yield* api.initProject(alice, { import: { branch: "master", url } });208+209+ const snapshot = yield* ProjectStore.use((store) => store.load());210+211+ expect(212+ Option.map(snapshot.project, (row) => row.importedFrom)213+ ).toStrictEqual(Option.some({ branch: "master", url }));214+ expect((yield* api.policy()).importedFrom).toStrictEqual({215+ branch: "master",216+ url,217+ });218+ }).pipe(Effect.provide(worldOf(scenario, "memory")))219+ );220+221+ it.effect(222+ "answers a repeat with the same source as the first call did, and ProjectExists for another source",223+ () =>224+ Effect.gen(function* () {225+ yield* advanceTo("2026-10-08T12:00:00Z");226+227+ const { tip, url } = yield* upstreamOnMaster;228+ const api = yield* projectService(project);229+230+ const made = yield* api.initProject(alice, { import: { url } });231+ const again = yield* api.initProject(alice, { import: { url } });232+233+ expect(again).toStrictEqual(made);234+ expect(made.landed).toStrictEqual(LandedSha.make(tip));235+ expect(236+ yield* Effect.flip(237+ api.initProject(alice, {238+ import: { url: "https://example.com/other.git" },239+ })240+ )241+ ).toStrictEqual(new ProjectExists({ project }));242+ }).pipe(Effect.provide(worldOf(scenario, "memory")))243+ );244+245+ it.effect(246+ "sets the source on a repeat by the initializer for an import adopted before sources were kept, hearing no second landing",247+ () =>248+ Effect.gen(function* () {249+ yield* advanceTo("2026-10-08T12:00:00Z");250+251+ const { tip, url } = yield* upstreamOnMaster;252+ const api = yield* projectService(project);253+254+ yield* api.initProject(alice, { import: { url } });255+ yield* forgetSource;256+257+ const retried = yield* api.initProject(alice, { import: { url } });258+ const snapshot = yield* ProjectStore.use((store) => store.load());259+260+ expect(retried.landed).toStrictEqual(LandedSha.make(tip));261+ expect(262+ Option.map(snapshot.project, (row) => row.importedFrom)263+ ).toStrictEqual(Option.some({ url }));264+ expect(265+ (yield* api.events(0, 10)).map(({ event }) => event._tag)266+ ).toStrictEqual(["Landed"]);267+ }).pipe(Effect.provide(worldOf(scenario, "memory")))268+ );269+270+ it.effect("refuses a source from anyone but the initializer", () =>271 Effect.gen(function* () {272 yield* advanceTo("2026-10-08T12:00:00Z");273 274 const { url } = yield* upstreamOnMaster;275 const api = yield* projectService(project);276 277 yield* api.initProject(alice, { import: { url } });278+ yield* forgetSource;279 280 expect(281+ yield* Effect.flip(api.initProject(bob, { import: { url } }))282+ ).toStrictEqual(new ProjectExists({ project }));283+ }).pipe(Effect.provide(worldOf(scenario, "memory")))284+ );285+286+ it.effect("refuses a source for a project that started empty", () =>287+ Effect.gen(function* () {288+ yield* advanceTo("2026-10-08T12:00:00Z");289+290+ const { url } = yield* upstreamOnMaster;291+ const api = yield* projectService(project);292+ const client = yield* gitClient(memoryFs());293+294+ const first = yield* client.commit("Start", [["README.md", "# start\n"]]);295+296+ yield* api.initProject(alice, {});297+ yield* (yield* RepoHost)298+ .push(repo, client.source, [299+ { from: Option.none(), ref: mainRef, to: first },300+ ])301+ .pipe(Effect.orDie);302+ yield* advanceTo("2026-10-08T12:01:00Z");303+ yield* api.recordFirstPush(alice, first);304+305+ expect(306 yield* Effect.flip(api.initProject(alice, { import: { url } }))307 ).toStrictEqual(new ProjectExists({ project }));308 }).pipe(Effect.provide(worldOf(scenario, "memory")))309 );31 unmodified linesmodified:packages/project/test/project-store.contract.ts+18 added
686 unmodified lines687 expect(yield* loaded).toStrictEqual(empty);688 }).pipe(Effect.provide(layer))689 );690 691+ it.effect("keeps an import's source with its row", () =>692+ Effect.gen(function* () {693+ const store = yield* ProjectStore;694+695+ const imported = {696+ ...project,697+ importedFrom: {698+ branch: "master",699+ url: "https://github.com/dtolnay/anyhow",700+ },701+ } satisfies (typeof ProjectRow)["Encoded"];702+703+ yield* store.commit({ project: decoded(ProjectRow, imported) });704+705+ expect((yield* loaded).project).toStrictEqual(imported);706+ }).pipe(Effect.provide(layer))707+ );708+709 it.effect("keeps a claim's pinned suite with its row", () =>710 Effect.gen(function* () {711 const store = yield* ProjectStore;712 42 unmodified linesmodified:packages/protocol/src/domain/policy.ts+14 added
119 unmodified lines120 121 export type PublicPolicy = typeof PublicPolicy.Type;122 123 /**124+ * Where an imported project came from: the public repo's https address,125+ * and the branch its `main` was adopted from when the import named one.126+ * The same shape `initProject` takes, kept on the project's record and127+ * shown on its page (ADR 0031). It lives beside the policy, whose read128+ * names it: a module of its own would cost the root's preloaded bytes.129+ */130+export const ImportSource = Schema.Struct({131+ branch: Schema.optionalKey(Schema.NonEmptyString),132+ url: Schema.String.check(Schema.isPattern(/^https:\/\/\S+$/u)),133+});134+135+export type ImportSource = typeof ImportSource.Type;136+137+/**138 * Why a project's policy has not evaluated at its landed commit, derived at139 * each read and never stored.140 */141 export const PolicyPending = Schema.Struct({86 unmodified linesmodified:packages/protocol/src/contracts.ts+5 added-8 removed
36 unmodified lines37 import { EnvSchemaView } from "./domain/env.ts";38 import { ProjectEvent } from "./domain/event.ts";39 import { FrontPageEntry, ProjectListing } from "./domain/front-page.ts";40 import { LandingView } from "./domain/landing.ts";41-import { PolicyPending, PublicPolicy } from "./domain/policy.ts";41+import { ImportSource, PolicyPending, PublicPolicy } from "./domain/policy.ts";42 import { DraftNote, Proposal } from "./domain/proposal.ts";43 import { CreditSummary } from "./domain/record.ts";44 import { Ledger } from "./domain/visibility.ts";45 import {515 unmodified lines561 export class PolicyOf extends Rpc.make("projectPolicy", {562 error: UnknownProject,563 payload: { project: ProjectName },564 success: Schema.Struct({565+ /** Where the project was imported from; absent for one that started empty. */566+ importedFrom: Schema.optionalKey(ImportSource),567 /** Absent while the config folder at the landed commit has not evaluated. */568 policy: Schema.optionalKey(PublicPolicy),569 /**570 * Why there is no policy at the landed commit: no config folder, or one4 unmodified lines575 }),576 })577 .annotate(578 Description,577- "Show a project's evaluated config folder at its landed commit: who decides which paths, its vouches, caps, budget and claim timing."579+ "Show a project's evaluated config folder at its landed commit: who decides which paths, its vouches, caps, budget and claim timing; for an import, its source."580 )581 .annotate(Audience, "public")582 .annotate(Visibility, "public")583 .annotate(ReadOnly, true)30 unmodified lines614 export class InitProject extends Rpc.make("initProject", {615 error: Schema.Union([ProjectExists, ImportFailed]),616 payload: {617 /** A public repo to import, instead of starting empty. */616- import: Schema.optionalKey(617- Schema.Struct({618- branch: Schema.optionalKey(Schema.NonEmptyString),619- url: Schema.String.check(Schema.isPattern(/^https:\/\/\S+$/u)),620- })621- ),618+ import: Schema.optionalKey(ImportSource),619 project: ProjectName,620 },621 success: Schema.Struct({622 /** Absent until the first push to an empty project. */529 unmodified linesmodified:scripts/lib/import/run.ts+86 added-20 removed
64 unmodified lines65 /** Print the plan, import and record nothing. */66 readonly dryRun: boolean;67 /** Backfill the tags of an import that has none. */68 readonly tags: boolean;69+ /** Keep the source of each earlier import on its record (ADR 0031). */70+ readonly sources: boolean;71 /** Warm the examples the platform lists already, as well as each new import. */72 readonly warm: boolean;73 /** The web's origin to warm through, when the stage's own can't be known. */74 readonly web: Option.Option<string>;93 unmodified lines168 );169 });170 171 const USAGE =170- "bun scripts/import-examples.ts --world node | --stage <dev-…> [--url <origin>] [--web <origin>] [--only <project>] [--tags] [--warm] [--dry-run]";172+ "bun scripts/import-examples.ts --world node | --stage <dev-…> [--url <origin>] [--web <origin>] [--only <project>] [--tags] [--sources] [--warm] [--dry-run]";173 174 /** The flags the command takes; any other is a typo, refused. */175 const FLAGS = new Set([176 "--dry-run",177 "--only",178+ "--sources",179 "--stage",180 "--tags",181 "--url",182 "--warm",80 unmodified lines263 264 return {265 dryRun: argv.includes("--dry-run"),266 only,267+ sources: argv.includes("--sources"),268 tags,269 warm: argv.includes("--warm"),270 web: Option.map(flagValue(argv, "--web"), (web) =>271 web.replace(/\/+$/u, "")87 unmodified lines359 : ` warm ${project}: no web to read through`360 );361 });362 363+/**364+ * The projects the ledger records as imports on `stage`: an import the365+ * platform does not list (one adopted before adoptions were heard) is366+ * still this stage's, never imported again.367+ */368+const recordedImports = (stage: Option.Option<Stage>) =>369+ Effect.gen(function* () {370+ if (Option.isNone(stage)) {371+ return new Set<ProjectName>();372+ }373+374+ const ledger = yield* readLedger.pipe(375+ Effect.mapError((error) =>376+ failed(`the ledger (${ledgerPath}): ${error.message}`)377+ )378+ );379+380+ const imported = ledger.filter(({ by }) => by === "import");381+382+ return new Set(383+ examples.flatMap(({ project }) =>384+ isRecorded(imported, {385+ kind: "project",386+ name: project,387+ stage: stage.value,388+ })389+ ? [project]390+ : []391+ )392+ );393+ });394+395+/**396+ * `--sources` on one earlier import: `initProject` asked again with the397+ * same source, which the platform takes as the source to keep (ADR 0031)398+ * and answers as the import did; a refusal is printed, never fatal.399+ */400+const sourceOne = (example: ImportExample) =>401+ Effect.gen(function* () {402+ const target = yield* ImportTarget;403+404+ const outcome = yield* target.initProject(example).pipe(405+ Effect.map(() => `source kept: ${example.url} (${example.branch})`),406+ Effect.catch(({ reason }) => Effect.succeed(`source not kept: ${reason}`))407+ );408+409+ yield* Console.log(` ${example.project}: ${outcome}`);410+ });411+412 /** The run itself, over a target, a backfill and a web. */413 const run = (options: ImportOptions) =>414 Effect.gen(function* () {415 const target = yield* ImportTarget;416 const listed = yield* target.listProjects;417 const stage = stageOfWhere(options.where);418+ const recorded = yield* recordedImports(stage);419+ const known = new Set([...listed, ...recorded]);420 421 const asked = planImports(examples, new Set(), options.only);367- const plan = planImports(examples, listed, options.only);368- const skipped = asked.filter(({ project }) => listed.has(project));422+ const plan = planImports(examples, known, options.only);423+ const skipped = asked.filter(({ project }) => known.has(project));424 425+ // The earlier imports `--tags` and `--sources` go back over: on a426+ // stage, those the ledger records; in the Node world, every one listed.427+ const earlier = skipped.filter(428+ ({ project }) => Option.isNone(stage) || recorded.has(project)429+ );430+431 yield* Console.log(432 `import-examples on ${target.label}: ${plan.length} to import, ${skipped.length} listed already`433 );434 yield* Effect.forEach(435 skipped,375- ({ project }) => Console.log(` skip ${project}: listed already`),436+ ({ project }) =>437+ Console.log(438+ listed.has(project)439+ ? ` skip ${project}: listed already`440+ : ` skip ${project}: imported already, as the ledger records`441+ ),442 { discard: true }443 );444 445 if (options.dryRun) {2 unmodified lines448 ({ branch, project, url }) =>449 Console.log(` would import ${project} from ${url} (${branch})`),450 { discard: true }451 );452+453+ if (options.sources) {454+ yield* Effect.forEach(455+ earlier,456+ ({ branch, project, url }) =>457+ Console.log(458+ ` would keep the source of ${project}: ${url} (${branch})`459+ ),460+ { discard: true }461+ );462+ }463+464 yield* Console.log("dry run: nothing imported, nothing recorded");465 466 return;467 }30 unmodified lines498 499 // An import from an earlier run that this run skipped is backfilled500 // too, if the ledger holds it as an import of this stage.501 if (options.tags && Option.isSome(stage)) {424- const ledger = yield* readLedger.pipe(425- Effect.mapError((error) =>426- failed(`the ledger (${ledgerPath}): ${error.message}`)427- )428- );429-430- const imported = ledger.filter(({ by }) => by === "import");431-432- const earlier = skipped.filter(({ project }) =>433- isRecorded(imported, {434- kind: "project",435- name: project,436- stage: stage.value,437- })438- );439-502 yield* Effect.forEach(503 earlier,504 (example) =>505 Effect.flatMap(target.counts(example.project), ({ tags }) =>2 unmodified lines508 { discard: true }509 );510 }511 512+ if (options.sources) {513+ yield* Effect.forEach(earlier, sourceOne, { discard: true });514+ }515+516 if (options.warm) {517 yield* Effect.forEach(skipped, ({ project }) => warmOne(project), {518 discard: true,519 });25 unmodified linesmodified:scripts/import-examples.ts+7 added-2 removed
21 unmodified lines22 * `--tags` backfills `refs/tags/*` for an import whose repo serves none:23 * the source's tags fetched into a temporary bare repo, then pushed to the24 * canonical repo with a write token minted over Artifacts' REST API for at25 * most ten minutes and revoked after, even on failure. It is the one write26- * that skips the gateway: tags only, by the operator, never `main`. The27- * core is `lib/import/`.26+ * that skips the gateway: tags only, by the operator, never `main`.27+ *28+ * `--sources` keeps the source of each earlier import on its record: the29+ * same `initProject` asked again by the operator, which the platform30+ * answers as the import did and takes as the source to keep (ADR 0031).31+ * A project the ledger records as this stage's import is never imported32+ * again, even when the platform does not list it. The core is `lib/import/`.33 */34 import { BunRuntime, BunServices } from "@effect/platform-bun";35 import { Effect, Layer, Option, Stdio } from "effect";36 38 unmodified linesmodified:AGENTS.md+1 added-1 removed
17 unmodified lines18 | 4 | **One schema, many surfaces.** Change `packages/protocol`; every surface derives from it. Projections live only in `apps/*/src/surfaces.ts`. The CLI's command list is `commandDocs` in `@repo/agent-kit`, which the platform's skill, the CLI's MCP prompt and the web's `llms.txt` all read. | `apps/cli/test/commands-doc.test.ts` (the command list against the real CLI's commands, flags and positionals, `policy`, `ask draft` and `proposal` included); `packages/protocol/test/mcp.test.ts` (every MCP tool's schemas, with no JSON Schema leak, the policy and drafting contracts included; the five capped code reads are tools, `showCommit` and `listPaths` are not); `apps/web/test/agents.test.tsx` (every snippet, command, endpoint, limit and refusal on the For agents page is `@repo/agent-kit`'s or the union's); `packages/agent-kit/test/docs.test.ts` and `apps/web/test/docs.test.tsx` (the `/docs` pages name only the CLI's commands with flags each takes and link only to pages that exist, the reference lists every command, refusal, event, MCP tool and imported project from its source, and the web draws each page and its Markdown from that one text); `apps/web/test/llms.test.ts` (`/` and `/<project>` asked for Markdown answer with the `llms.txt` texts, and their HTML names that Markdown as an alternate); `packages/agent-kit/test/full-llms.test.ts` (one `ProjectEvent` line per tag); `apps/platform/test/home.test.ts` (the platform's `/` in Markdown is the web's `llms.txt`, one text from `@repo/agent-kit`); per-package `allowedUnstableApis` with `unstableApiUsage` at error |19 | 5 | **The name lives only in `packages/brand`.** Internal packages use `@repo/*`. DO classes, Workflows, queues and databases carry job names. | `brand:check` (`scripts/brand.ts`, tested by `packages/brand/test/leaks.test.ts`) |20 | 6 | **Pure core, thin hosts.** Only `@repo/artifacts` calls Artifacts. Each beta dependency sits behind one job-named port with a `/memory` adapter in the owning package. Apps import packages only. Worker code stays free of `node:child_process`, `@effect/platform-bun` and OpenTUI. `rules` and `gate` run in both Workers and Bun. `alchemy/*` stays in `infra/`. No module-level mutable state in a package's `src/`. | Scoped `allowedUnstableApis`; `packages/artifacts/test/repo-host-contract.ts` (one RepoHost contract every adapter passes); `apps/platform/test/bindings.test.ts` and `apps/platform/test/worker-init.test.ts` (the Worker starts on its real adapters, composed in `apps/platform/src/ports.ts`); `apps/platform/test/router-build.test.ts` (both handlers are built when the Worker module loads, with no binding touched, and a layer that awaits a promise while it is built is refused there); `apps/web/test/production-bundle.test.ts` (no dev-world module in the web's production build, and no chunk every page preloads holds the Markdown renderer, under a gzip ceiling); `packages/config/test/cartridge.test.ts` (the visibility cartridge is plugged in by one marked line and reached by nothing else, so removing it is a deletion); `packages/drafting/test/memory.test.ts` (the `Drafter` port's `/memory` adapter, `packages/drafting/src/drafter/memory.ts`) and `packages/drafting/test/binding.test.ts` (its Workers AI adapter over the `AI` binding); `packages/project/test/code-store.test.ts` (the `CodeStore` port's `/memory` adapter, `packages/project/src/code-store/memory.ts`, and its R2 adapter over `CODE_CACHE`, whose failures are misses, never the read's); `apps/platform/test/code-reads.test.ts` and `apps/web/test/dev-backend.test.ts` (the platform and the web's dev world answer the code reads and raw files alike, both through `@repo/project/code`); `packages/project/test/standing-posture.test.ts` (one helper, `withStandingPosture`, gives a listing each project's own posture, for the platform and the web's dev world alike, through the `StandingPostures` port whose default keeps nothing; its D1 adapter is the platform's); `apps/web/test/seeded.test.tsx` (a loader's read seeds a registry of its own page and leaves the registry every request shares as it was); `apps/web/test/shell.test.tsx` (no plain anchor between the web's pages: every link is the router's). No fence: import direction and module-level state |21 | 7 | **Deny by default for visibility.** Land the answer's tree, never the composed tree. Nothing from a layer enters a public tree. Snapshot before held-back files are written. Public-serving Workers have no private-namespace binding. Public commits, trailers, notes and errors name public paths only. | `PrivatePathInPublicTree`, one rule for the gate's stage 1 and the landing guard (`packages/gate/test/shape.test.ts`, `packages/visibility/test/guards.test.ts`); `apps/platform/test/visibility/layer-gateway.test.ts` (only a layer's readers clone it, every read is logged, a fork push cannot carry its paths); `apps/sandbox/test/held-back.test.ts` (egress off and the snapshot taken before any sealed file is written; one bit per area, no output); `apps/platform/test/visibility/held-back.test.ts` (the `Held-back:` trailer, the landing guards, no stored value in a note or a kept log); `apps/platform/test/bindings.test.ts`; `apps/sandbox/test/checker.test.ts` (no snapshot once the held-back slot is reached); `apps/web/test/env.test-d.ts` (the web's Env has no private-namespace, Artifacts or `CODE_CACHE` binding) and `apps/platform/test/env.test-d.ts` (only the platform's has both); `packages/project/test/code-raw.test.ts` and `apps/platform/test/raw.test.ts` (raw bytes under `nosniff` and the sandboxing CSP, refusals included); `apps/platform/test/code-reads.test.ts` (no code read's payload names a repo); `packages/project/test/code-history.test.ts` (the code store is keyed under the project's canonical repo alone and holds no landing); `apps/platform/test/w9-contracts.test.ts` (`projectPolicy` answers without the policy's layers or asks, and `packages/config/test/cartridge.test.ts` keeps the cartridge removable); `packages/drafting/test/prompt.test.ts` (a draft's prompt never carries a layer's name, repo, reason or paths); `apps/web/test/markdown.test.tsx` (a README's script, handlers, unsafe URLs, iframes, styles and forms never reach the page); `apps/platform/test/gateway.test.ts` and `packages/gate/test/parse.test.ts` (a fork takes branches only: its notes, tags and the platform's refs are refused); `apps/platform/test/visibility/posture-listing.test.ts` and `apps/platform/test/home.test.ts` (the project list and the platform's `/` show the posture the project's ledger shows); `apps/web/test/landing.test.tsx` (the landing at `/` draws only the public project list, each project with the posture its listing gives); `apps/web/test/ledger.test.tsx` (the ledger page adds no path, check name or file name) and `apps/web/test/env.test.tsx` (the env page shows no value and no control to set or read one); `apps/platform/test/pages.test.ts` (the sign-in page, as an MCP client's consent, escapes every value a client supplies) |22-| 8 | **Deterministic and idempotent.** Rule evaluation sees frozen time and randomness and only injected facts. Re-running an operation converges. Check results are keyed by (tree SHA, check version), push events deduped by (repo, sha), and land requests carry a `requestId`. | `globalDate`, `globalRandom`, `globalTimers` and `cryptoRandomUUID` at error, with their in-Effect twins; `packages/rules/test/replay.test.ts`; `packages/project/test/project-store.contract.ts`; `packages/project/test/claim.model.test.ts` and `packages/project/test/landing.model.test.ts`; `apps/platform/test/workflows/answer.test.ts`; `apps/platform/test/workflows/on-push.test.ts`; `apps/platform/test/core-loop.test.ts`; `apps/platform/test/workflows/draft.test.ts` (a replayed draft round asks the model nothing more, and each round is its own instance); `packages/project/test/code.test.ts` (code reads cached by object id, only once finished, while `main` resolves every time, and a commit's diff kept by its SHA without its landing); `packages/project/test/drafting.model.test.ts` (a settle of a stale round changes nothing); `packages/project/test/import.test.ts` (a retried import adopts the repo it made); `packages/project/test/code-history.test.ts` (a why and a path's history are kept by commit, path hash and algorithm version, and the store, a step from a kept ancestor and a whole walk agree); `packages/config/test/smoke-loop.test.ts` (smoke's throwaway project is in the ledger before init makes it, and a taken name stops before anything is made); `apps/web/test/events.test.ts` (the web's fold of a project's events gives the same map when an event is heard twice or out of order, and a replay that already holds a landing stamps nothing); `packages/project/test/standing-posture.test.ts` (a kept posture is read again only for the project whose event the projection applied, or once its instant has come). No fence: one push deduped by (repo, sha) across the gateway's record and OnPush's |22+| 8 | **Deterministic and idempotent.** Rule evaluation sees frozen time and randomness and only injected facts. Re-running an operation converges. Check results are keyed by (tree SHA, check version), push events deduped by (repo, sha), and land requests carry a `requestId`. | `globalDate`, `globalRandom`, `globalTimers` and `cryptoRandomUUID` at error, with their in-Effect twins; `packages/rules/test/replay.test.ts`; `packages/project/test/project-store.contract.ts`; `packages/project/test/claim.model.test.ts` and `packages/project/test/landing.model.test.ts`; `apps/platform/test/workflows/answer.test.ts`; `apps/platform/test/workflows/on-push.test.ts`; `apps/platform/test/core-loop.test.ts`; `apps/platform/test/workflows/draft.test.ts` (a replayed draft round asks the model nothing more, and each round is its own instance); `packages/project/test/code.test.ts` (code reads cached by object id, only once finished, while `main` resolves every time, and a commit's diff kept by its SHA without its landing); `packages/project/test/drafting.model.test.ts` (a settle of a stale round changes nothing); `packages/project/test/import.test.ts` (a retried import adopts the repo it made, and a retried import keeps its source); `packages/project/test/code-history.test.ts` (a why and a path's history are kept by commit, path hash and algorithm version, and the store, a step from a kept ancestor and a whole walk agree); `packages/config/test/smoke-loop.test.ts` (smoke's throwaway project is in the ledger before init makes it, and a taken name stops before anything is made); `apps/web/test/events.test.ts` (the web's fold of a project's events gives the same map when an event is heard twice or out of order, and a replay that already holds a landing stamps nothing); `packages/project/test/standing-posture.test.ts` (a kept posture is read again only for the project whose event the projection applied, or once its instant has come). No fence: one push deduped by (repo, sha) across the gateway's record and OnPush's |23 | 9 | **Effect v4 only.** Read `node_modules/effect/src` as API truth. Off limits: `effect/unstable/*`, v3 `@effect/platform` and `@effect/cli`, and `effect/workflow` or `effect/cluster` on Workers. | `outdatedApi`; `no-restricted-imports` |24 | 10 | **Escapes need a reason.** Every `oxlint-disable`, `@effect-diagnostics` or `@ts-expect-error` carries its reason after `--`, and is added only where no idiomatic code does the job. | `check` fails on an unused directive. No fence: the reason |25 | 11 | **`bun run verify` is the authority.** Deploy only to an explicit stage, after `verify`, with smoke after. A red gate is fixed, never deployed around. | `packages/config/test/verify.test.ts` (verify's steps); `infra/deploy.ts` refuses without a known stage, runs `verify` first and `scripts/smoke.ts` after (`packages/config/test/deploy.test.ts`, `packages/config/test/smoke.test.ts`), and refuses every deploy while `infra/.recording` is there (`packages/config/test/recording.test.ts`) |26 | 12 | **Lifecycles are pure transitions.** `transition(state, command, now)`. Per DO call: hydrate, transition, persist, settle. Deadlines run on DO alarms. Call them lifecycles. | `globalTimers` and `globalTimersInEffect`; `packages/project/test/claim.model.test.ts` and `packages/project/test/landing.model.test.ts` (model tests over effect/Arbitrary histories, each seen catching its planted bug); `packages/project/test/drafting.model.test.ts` (a proposal's `DraftCommand.DraftStarted` and `DraftSettled` over generated histories; a Ready round's files survive a later failed round); `apps/platform/test/project-do.test.ts`. No fence: `Effect.sleep` and `Effect.delay` in `packages/project/src` |122 unmodified linesmodified:GLOSSARY.md+4 added
78 unmodified lines79 **Landed SHA**:80 The commit the platform itself last landed on main; the only commit a project's rules are read from.81 _Avoid_: HEAD, tip of main82 83+**Import**:84+A project adopted from a public repo: a read-only copy, not run by its maintainers, whose first `main` is the source branch's tip. The source, its address and branch, stays on the project's record and is shown as where it was imported from.85+_Avoid_: mirror, fork (of the source), sync86+87 **Outcome**:88 Where an offered answer stands: Checking, Landed, WaitingOnParent, AwaitingFinish, AwaitingDecision or Refused; only Refused carries refusals, and waiting is not a refusal.89 _Avoid_: result, build state, CI status90 133 unmodified lines