Merge branch 'build/707-adr-glossary-agents-fold-ins'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by oscabriel · committed by oscabriel · parents 4de6bd1, f8985b9 · Browse files · 14 files·+369 added−18 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
14 files+369 added−18 removed
- tests:+202 added−0 removed
- other:+167 added−18 removed
Provenance
- Commit
2b1fd3c- Tree
fcd4dc1- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
4de6bd1- Parent 2
f8985b9
14 files changed+369 added−18 removed
modified:docs/adr/0001-bun-workspaces-and-turborepo.md+4 added
14 unmodified lines151617181920212214 unmodified lines
We keep pnpm's supply-chain guarantees by configuration rather than by tool: `--frozen-lockfile` in CI and in acceptance runs, exact pins, a minimum release age, and `trustedDependencies` for install scripts.
Rat Stack, which we port from (ADR 0013), says not to replace pnpm with Bun. That rule is about cold installs of Rat Stack's own template. The guarantees it protects are the ones kept above.
## Amended (2026-10-08)
There is no CI workflow and no acceptance script (ADR 0011's note). The lockfile guarantee is `bun run lockfile:check` (`bun install --frozen-lockfile --dry-run`), the first step of `bun run verify`. `bunfig.toml` keeps exact pins and a one-day minimum release age, and the root `package.json` names no `trustedDependencies`.modified:docs/adr/0002-wrangler-deploys-every-worker.md+5 added
45 unmodified lines46474849505152535445 unmodified lines- **Config:** local state, telemetry off (`ALCHEMY_TELEMETRY_DISABLED=1`) and an exact pin.- **Frozen Durable Object names:** Alchemy deletes a removed Durable Object by default, so a rename is a delete and loses data. A test pins the class list.
Watch [#1950](https://github.com/alchemy-run/alchemy/pull/1950) (an events-trigger resource) and [#1916](https://github.com/alchemy-run/alchemy/pull/1916) (Artifacts reads).
## Amended (2026-10-08)
- The push-event trigger is declared in `apps/platform/wrangler.jsonc` (`triggers.events`), and Wrangler deploys it with the platform. `infra/bootstrap.ts --check-triggers`, which `infra/deploy.ts` runs after the deploy, reads it back (`GET /triggers/platform-<stage>`) and compares; Artifacts adds a `script_name` to each target, which the comparison expects.- The hook that refused cf's project commands is gone (ADR 0011's note). The rule stands in AGENTS.md's Boundaries and is held by review: cf runs only as `bun run ops -- …`, and any `delete` or `revoke` goes to the maintainer. In a non-interactive shell `wrangler delete` answers its own prompt yes, and cf's deletes abort unless given `--force`.modified:docs/adr/0003-rpcgroup-is-the-one-schema.md+4 added
26 unmodified lines272829303132333426 unmodified lines - Amended (2026-10-07): that record is gone (ADR 0013's note); `protocol/{cli,mcp}` each carry Rat Stack's MIT notice in their own header.- Wire schemas use `Schema.Int` or `Schema.Finite`, never bare `Schema.Number`, and `Schema.optionalKey`, never `Schema.optional`. Effect's `Schema.toJsonSchemaDocument`, which `McpServer` uses for tool schemas, turns `Schema.Number` into an `anyOf` that admits the strings `"Infinity"`, `"-Infinity"` and `"NaN"`, and turns `Schema.optional(Schema.String)` into string-or-`null`.- Every `effect/rpc` API is marked `@stability unstable`, so each package that uses one allows it explicitly in `allowedUnstableApis`.- A public REST SDK, if one is wanted later, comes from an `HttpApi` projection of the `RpcGroup`, not from a second source.
## Amended (2026-10-08)
There is no `bun run gen` and no generated `skills/`, `plugins/` or `docs/reference/` (ADR 0011's note). Every surface still derives from the group, in code: the platform's handlers and the web's client from the contracts, the CLI's commands and the MCP tools through the ported projections in `protocol/{cli,mcp}`, and the CLI's command list as `commandDocs` in `@repo/agent-kit`, which the platform's skill, the CLI's MCP prompt and the web's `/llms.txt` all read. `packages/protocol/test/mcp.test.ts` holds every MCP tool's schemas free of JSON Schema leaks. The `capability` fallback was never needed: the port passed within its first quarter hour.modified:docs/adr/0004-git-gateway-owns-custody.md+13 added
14 unmodified lines151617181920212223242526272829303114 unmodified lines
- For an answer, the gateway forwards the push to the answerer's own fork, then rewrites git's report-status with the verdict of the cheap stages of the gate (ADR 0006).- A git credential helper ships so that tokens stay out of remote URLs.- If the gateway cannot be built, the fallback is raw per-fork tokens plus the push-event backstop, and the `git-remote-<name>` helper returns to put refusals in push output.
## Amended (2026-10-08)
What the gateway spike against live Artifacts (Oct 6–7) and the build since have shown:
- **A push lands whole or not at all.** Any refusal turns every ref in the push away. Custody judges twice: `admit` runs before forwarding, so a refused push never reaches storage, and `review` runs after storage took the push into the answerer's fork, which keeps the commit while git still shows the refusal.- **Four headers are forwarded, and no credential.** The gateway passes only `accept`, `content-encoding`, `content-type` and `git-protocol` upstream; the upstream adapter adds the platform's own token.- **Storage's rejections are translated by their text.** `stale ref` (Artifacts) and `incorrect old value provided` (git's receive-pack) become `StaleBase`, with `main` read from a fresh ref advertisement; `artifacts_git_receive_pack_busy` becomes `RepoBusy`, which is retryable. `fetch first` never reaches a server: git decides it on the client.- **A direct push to a canonical `main` is `DirectPush`.** It is final, and its next step lists the asks. `StaleBase` read backwards there and `NoAsk` said nothing about why. The only direct push admitted is the initializer's first push to an empty project; after that, `main` moves only by a landing (ADR 0014).- **Anonymous clones of public repos work** through the gateway, which holds the read token; Artifacts itself refuses anonymous reads.- **Cost.** A push through the gateway took a median 0.355 s against 0.340 s direct (+4.6%, ten pushes each). Ten clones at once took +69% (2.0 s against 1.2 s wall time), most likely because each new isolate mints a token before its first upstream call; the two were not timed apart.- **The fallback is not built.** There are no raw per-fork tokens and no `git-remote-<name>` helper. The push-event backstop is built: OnPush turns any move of a canonical `main` that the platform did not make into a `StrayPush` decision whose default is revert.- Later stages of the gate answer after the push returns, not in its report-status (ADR 0015).modified:docs/adr/0005-rules-read-from-the-landed-sha.md+4 added
8 unmodified lines9101112131415168 unmodified lines## Considered Options
- **Read rules from a landed ref pushed atomically with `main`.** This was the earlier design, and it made an atomic two-ref push a requirement of every landing. Artifacts' `readFile` accepts a commit ID as its `ref` ([Workers binding](https://developers.cloudflare.com/artifacts/api/workers-binding/)), so reading by SHA needs no second ref.- **Read rules from the tip of `main`.** A push that reached `main` outside the gateway would then rewrite the rules that judge the next push.
## Amended (2026-10-08)
The first spike against live Artifacts (Oct 6) settled the question this ADR turned on: Artifacts has no atomic multi-ref push. `git push --atomic` is refused ("the receiving end does not support --atomic push"), and its receive-pack advertises no `atomic` capability. So the landed SHA in the Project DO is the only truth. A landing pushes `main` alone, then the mirror ref and the verdict note each follow in a push of their own (ADR 0014), and either may trail `main` for a moment. Artifacts' Workers binding also resolves only short branch names and commit SHAs, never a custom ref, so the DO keeps the SHAs of the refs it writes.modified:docs/adr/0006-landing-is-a-parse.md+6 added
16 unmodified lines1718192021222324252616 unmodified lines- Text for git `remote:` lines, the CLI and MCP comes from one renderer, `protocol/render`.- Stage-1 (shape) refusals accumulate, so one push gets every shape problem at once. Costly stages stop at the first failure. The `ng` line names the first tag; `remote:` lines, CLI JSON and MCP JSON list them all.- The union is a public contract. A `_tag` is renamed only with an alias.- `Flake` and `VerifierBlocked` never count against the answerer.
## Amended (2026-10-08)
- **`PatchId` is the platform's own**, not `git patch-id`: SHA-256 over the answer's change set as sorted `path`, blob-before, blob-after lines (an absent blob as empty), computed with WebCrypto in a Worker that has no diff engine (`packages/git/src/patch-id.ts`). It ignores commit order and moves only when a blob the answer touches moves, which is when a held-back lane must run again; a verdict records it, and only held-back results may carry over, when both it and the pinned held-back suite are unchanged. Open: the change set is taken against the answer's own base, so a re-merge onto a `main` that changed one of those files keeps the same id.- **Waiting is not refusing.** An answer's `Outcome` is `Checking`, `Landed`, `WaitingOnParent`, `AwaitingFinish`, `AwaitingDecision` or `Refused`. The three waiting states carry no refusal: nothing failed, and the answer needs no new push. Only `Refused` carries refusals, all from the cheapest failing stage.- Stages 0 and 1 answer inside the push; the merge, the project's commands, held-back checks and the human stage answer afterwards (ADR 0015).modified:docs/adr/0008-claims-are-exclusive-by-default.md+5 added
11 unmodified lines12131415161718192011 unmodified lines
## Consequences
The front page shows an ask as either claimed or open.
## Amended (2026-10-08)
- **Fork names carry their parts.** A claim's fork is `<project>--<ask>--<handle>` and a person's working fork `<project>--me--<handle>`, the handle in lowercase; a layer's repo is `<project>--<layer>`. A project name or an ask id is lowercase words joined by single hyphens, so neither can hold `--`, and a claim fork's or a working fork's name splits back into its parts. A layer's name follows the config folder's looser grammar, which does not refuse `--`. `me` and `layer` are reserved ask ids, as are `open` and `flag`, which the CLI's `ask` subcommands take.- **Making a claim's fork is safe to retry, and converges on one repo.** Ten claims at once against live Artifacts (Oct 7) were all ready within 9.9 s, so no pool of pre-made forks is needed. Under that load 4 of 10 fork calls first answered HTTP 500, then 409 "repo already exists" when retried under the same name, and each still ended as exactly one repo. So a 500 is read as "maybe made" and tried once more, and an already-exists on the claim's own name counts as made once that repo holds `main`. The name comes from the claim, so claiming again finds the same fork.added:docs/adr/0014-landing-is-a-cas-push-of-main-then-bookkeeping-refs.md+21 added
1+---2+status: accepted3+---4+5+# Landing is a CAS push of main, then the bookkeeping refs, each on its own6+7+The platform lands a checked tree as one new commit on canonical `main`, whose parent is the landed SHA the Project DO last recorded, pushed with a plain push: never forced and never atomic. If `main` moved since, storage refuses it, and the landing re-merges onto the new `main` or ends as `StaleBase`. Only once `main` has moved does the platform push its bookkeeping: the mirror ref (ADR 0005) and the verdict note, each in a push of its own. Artifacts has no atomic multi-ref push, and any write token can force-push `main`, so the one push that matters is the compare-and-swap on `main`, and only the platform holds a token that can make it.8+9+## Considered Options10+11+- **One atomic push of `main`, the mirror ref and the note.** This was the earlier design. Artifacts refuses `--atomic` (spike, Oct 6), and its receive-pack advertises no `atomic` capability.12+- **`--force-with-lease` on `main`.** It is a compare-and-swap too, but it is a forced push: once the expected value matches, any commit replaces `main`, even one that does not descend from it, so a landing built on the wrong parent would rewrite history instead of failing. A plain push of a commit whose parent is the old tip can only move `main` forward. The Lander uses a lease only for its own compose refs, never for `main`.13+- **Bookkeeping first, `main` last.** A mirror or a note naming a commit that never landed would mislead its readers, and Artifacts accepts a notes ref naming a commit the repo lacks, then fails the fetch of that commit.14+15+## Consequences16+17+- The landed SHA in the Project DO, written in the same transaction as the landing record, is the only truth (ADR 0005). The mirror ref and the note may trail `main` for a moment, and nothing decides by them.18+- A bookkeeping push that fails stays in the DO's outbox, and the next alarm lands the same request again. The Lander finds its own commit already on `main`, by the commit's `Request-Id` trailer, and writes only what is missing, so a replayed landing never makes a second commit.19+- Artifacts fires one push event per ref, so `OnPush` reads the ref and ignores the pushes the platform made.20+- Write tokens for a canonical repo never leave the platform. Answers go to forks, and tokens are per repo.21+- The serial landing queue lands one request per project at a time. A landing that meets `RepoBusy` waits and tries again, from a second up to five minutes.added:docs/adr/0015-submitting-an-answer-is-asynchronous.md+19 added
1+---2+status: accepted3+---4+5+# Submitting an answer is asynchronous: the push hears the cheap stages, and the rest arrives later6+7+An answer is offered by `git push` to the claim fork, or by the `submitAnswer` contract (the CLI's `submit`, the MCP tool). Either way, the call runs only the gate's first two stages: the parse (who may push what, and where) and the shape (territory, judge custody, weakening, reached internals). A clean answer then starts the `Answer` Workflow and returns at once with the outcome `Checking`, which git shows as `remote: checking <ask> at <head>; follow with <cli> status`. The merge, the project's own commands in a container, the held-back checks and any human stage run after the call has returned. Their outcome arrives as the verdict note on the answer's head, in `status` and `watch`, and through MCP. A container check takes minutes, and a push must not hold a request open that long.8+9+## Considered Options10+11+- **Hold the push open until the verdict.** Every refusal would then reach `git push` output, but one request would hold the git client, the gateway and a container for minutes, and a dropped connection would leave the pusher with nothing to read.12+- **Accept the push and say nothing until a later read.** Shape refusals are cheap and the most common kind, so they belong in git's own output, before the answerer moves on.13+14+## Consequences15+16+- Every offer carries a `requestId` (a push's is `push-<head>-<handle>`), so offering the same answer again returns the same receipt and starts no second run.17+- A push hears every stage-1 refusal at once (ADR 0006). `submitAnswer` fails with one error, so it returns the first of them.18+- Refusals from the later stages, such as `ChecksFailed`, `Flake`, `StaleBase` from a re-merge, or `HeldBackFailed`, never appear in the push's own output. They are read from `status`, `watch`, MCP or the verdict note (`git fetch` of the notes ref, then `git notes show`).19+- An answer's `Outcome` says where it stands meanwhile: `Checking`, then `Landed`, a waiting state, or `Refused` (ADR 0006's amendment).added:docs/adr/0016-a-person-is-a-platform-account.md+19 added
1+---2+status: accepted3+---4+5+# A person is a platform account, and nobody signs in with GitHub6+7+A person is a handle in the platform's own accounts. They sign up and sign in with a handle and a password on the platform's own pages, and the platform is its own OAuth authorization server, for the CLI's login (PKCE) and for MCP clients. Google sign-in is an optional second way in, linked to a handle, and never the identity itself. There is no GitHub sign-in, no GitHub handle lookup and no GitHub key in any env. The product's point is to leave GitHub, so who a person is must not depend on it, and accounts that need no third party let every stage sign people in with nothing to register first.8+9+## Considered Options10+11+- **GitHub OAuth as the only sign-in.** This was the earlier plan. People would arrive with an account and a handle they already have, but every stage would need an OAuth app registered by hand, and identity on a platform built to replace GitHub would be GitHub's.12+- **Named sessions alone:** a sensitive env value mapping bearer tokens to handles. It stays beside accounts, behind the same sessions port, for the operator and the demo's fictional people, who need several accountable identities without signing up one by one. It is not how real people join.13+14+## Consequences15+16+- Handles are the platform's own. Credit trailers, the vouch file (where a handle with no provider prefix is a platform handle) and fork names spell them, and two handles that differ only in case are one person.17+- A password is HMAC'd with a pepper held as a Worker secret, then hashed with PBKDF2, so a copy of the accounts table alone is useless. `COOKIE_KEY` and `PASSWORD_PEPPER` are required on every stage, and changing the pepper makes every stored password fail.18+- Agents have no identity of their own. An agent works through its person's token, and the harness it names is audit metadata that a landing discloses as `Assisted-by:`, never identity or credit.19+- Importing a public repo from GitHub once, to start a project, is unaffected (ADR 0010).added:docs/adr/0017-rules-evaluate-once-per-landed-sha-in-a-sandbox.md+20 added
1+---2+status: accepted3+---4+5+# A project's rules are evaluated once per landed SHA, in a Dynamic Worker that can reach nothing6+7+A project writes its process as TypeScript in the config folder. At each landing the Lander bundles the folder with Bun, with macros off so nothing in it runs while it is bundled. The platform then evaluates the bundle once, in a Dynamic Worker made by the Worker Loader. That Worker has no bindings, no outbound network (`fetch` and `connect` throw), no subrequests and a CPU limit, and a prelude freezes its clock and randomness to the landed commit's time and a hash of its SHA. The result is the project's policy: plain data, decoded with Schema as it leaves the sandbox, and cached in the Project DO beside the landed SHA it came from. Most rules are data. The few that are functions (whether a proposal opens without a decider, whether a claimant is admitted) are called on demand in the same kind of sandbox, with their facts passed in and the clock at zero. A project with no config folder runs on the defaults.8+9+## Considered Options10+11+- **Config as data only (JSON or YAML).** There would be nothing to sandbox, but a project could not compute its rules, and the typed SDK would have nothing to check them against. `packages/rules` keeps a JSON evaluator (a committed `policy.json`, or the defaults) as a fallback adapter.12+- **Bundle inside the platform Worker** with Cloudflare's worker bundler. A bundler would sit in the Worker that serves git, and it would bundle on every evaluation instead of once per landing.13+- **Evaluate on every push.** Every push would pay a sandbox start, and two pushes judged against the same landing could see different rules.14+15+## Consequences16+17+- Only a landing changes a project's rules, and no answer changes what judges it: the config folder is in the judge closure, and rules are read only at the landed SHA (ADR 0005).18+- Evaluating the same SHA twice gives the same policy (principle 8; `packages/rules/test/replay.test.ts`).19+- A config folder that fails to bundle or to evaluate leaves the policy of the previous landed SHA in place, and the failure is logged.20+- The SDK a project imports must run with no clock, no randomness and no network of its own, so rules get time and identity only through their facts.added:packages/config/test/docs-public.test.ts+202 added
1+/**2+ * The repo's own docs are the public record (issue 707): AGENTS.md,3+ * GLOSSARY.md, the ADRs and the agent docs point at nothing outside the4+ * repo, AGENTS.md says what holds today, every decision has a numbered ADR5+ * with a status, and the glossary defines the terms the code is written in.6+ * File reads and string checks only.7+ */8+import { NodeServices } from "@effect/platform-node";9+import { describe, expect, it } from "@effect/vitest";10+import { Array, Effect, FileSystem, Order, Path, Schema } from "effect";11+12+import { repoRoot } from "./root.ts";13+14+/**15+ * What a pointer to something only the maintainer can open looks like: a16+ * home folder, the private research repo or the host that serves it, or the17+ * build's own plan folder (gitignored).18+ */19+const PRIVATE = [20+ "~/",21+ "/home/",22+ "wanted-explainer",23+ "plans.gneiss.run",24+ ".scratch/build",25+] as const;26+27+/**28+ * What a reference into the build's private plan looks like, which a reader29+ * with only the repo cannot follow: a section of its spec (`spec §8`) or one30+ * of its issues by wave (`W3 313`).31+ */32+const PLAN_REFERENCES = [/\bspec §/u, /\bW\d \d{3}\b/u] as const;33+34+/** Terms the code uses in public names, each of which GLOSSARY.md defines. */35+const TERMS = [36+ "Claim fork",37+ "Decision",38+ "Family",39+ "Landed SHA",40+ "Outcome",41+ "Patch id",42+ "Policy",43+ "Proposal",44+ "Today",45+ "Working fork",46+] as const;47+48+const RootPackage = Schema.Struct({49+ scripts: Schema.Record(Schema.String, Schema.String),50+});51+52+/** A file's text, by its path from the repo root. */53+const read = (relative: string) =>54+ Effect.gen(function* () {55+ const fs = yield* FileSystem.FileSystem;56+ const path = yield* Path.Path;57+ const root = yield* repoRoot;58+59+ return yield* fs.readFileString(path.join(root, relative));60+ });61+62+/** The markdown files in a folder, by their paths from the repo root, in name order. */63+const markdownIn = (folder: string) =>64+ Effect.gen(function* () {65+ const fs = yield* FileSystem.FileSystem;66+ const path = yield* Path.Path;67+ const root = yield* repoRoot;68+ const names = yield* fs.readDirectory(path.join(root, folder));69+70+ return Array.sort(71+ names.filter((name) => name.endsWith(".md")),72+ Order.String73+ ).map((name) => `${folder}/${name}`);74+ });75+76+/** Each file with its text. */77+const withText = (paths: readonly string[]) =>78+ Effect.forEach(paths, (path) =>79+ Effect.map(read(path), (text) => ({ path, text }))80+ );81+82+/** Every public doc this test reads, with its text. */83+const publicDocs = Effect.gen(function* () {84+ return yield* withText([85+ "AGENTS.md",86+ "GLOSSARY.md",87+ ...(yield* markdownIn("docs/adr")),88+ ...(yield* markdownIn("docs/agents")),89+ ]);90+});91+92+/** Frontmatter that opens the file and holds a `status:` line. */93+const STATUS_FRONTMATTER =94+ /^---\n(?:[^\n]*\n)*?status: \S[^\n]*\n(?:[^\n]*\n)*?---\n/u;95+96+/** The lines of a `## <title>` section, up to the next heading of its level or above. */97+const sectionOf = (text: string, title: string): readonly string[] => {98+ const lines = text.split("\n");99+ const start = lines.indexOf(`## ${title}`);100+101+ if (start === -1) {102+ return [];103+ }104+105+ const rest = lines.slice(start + 1);106+ const end = rest.findIndex((line) => /^#{1,2} /u.test(line));107+108+ return end === -1 ? rest : rest.slice(0, end);109+};110+111+/** The command a list item opens with: `ops` in "- `ops -- <command>`: …". */112+const commandOf = (line: string) =>113+ /^- `(?<name>[^`\s]+)/u.exec(line)?.groups?.name;114+115+describe("the repo's public docs", () => {116+ it.live("point at no home folder and no private plan", () =>117+ Effect.gen(function* () {118+ const docs = yield* publicDocs;119+120+ expect(121+ docs.flatMap(({ path, text }) =>122+ [123+ ...PRIVATE.filter((pointer) => text.includes(pointer)),124+ ...PLAN_REFERENCES.flatMap((reference) =>125+ reference.test(text) ? [reference.source] : []126+ ),127+ ].map((found) => `${path}: ${found}`)128+ )129+ ).toStrictEqual([]);130+ }).pipe(Effect.provide(NodeServices.layer))131+ );132+133+ it.live("AGENTS.md describes today, with no Day 0 paragraph", () =>134+ Effect.gen(function* () {135+ const agents = yield* read("AGENTS.md");136+137+ expect(138+ agents.split("\n").filter((line) => /\bDay 0\b/u.test(line))139+ ).toStrictEqual([]);140+ }).pipe(Effect.provide(NodeServices.layer))141+ );142+143+ it.live(144+ "AGENTS.md's Commands section names every root script, and only those",145+ () =>146+ Effect.gen(function* () {147+ const agents = yield* read("AGENTS.md");148+149+ const { scripts } = yield* Schema.decodeEffect(150+ Schema.fromJsonString(RootPackage)151+ )(yield* read("package.json"));152+153+ expect(154+ Array.sort(155+ sectionOf(agents, "Commands").flatMap((line) => {156+ const name = commandOf(line);157+158+ return name === undefined ? [] : [name];159+ }),160+ Order.String161+ )162+ ).toStrictEqual(Array.sort(Object.keys(scripts), Order.String));163+ }).pipe(Effect.provide(NodeServices.layer))164+ );165+166+ it.live("every ADR opens with a status line", () =>167+ Effect.gen(function* () {168+ const adrs = yield* withText(yield* markdownIn("docs/adr"));169+170+ expect(171+ adrs.flatMap(({ path, text }) =>172+ STATUS_FRONTMATTER.test(text) ? [] : [path]173+ )174+ ).toStrictEqual([]);175+ }).pipe(Effect.provide(NodeServices.layer))176+ );177+178+ it.live("ADRs are numbered from 0001 with no gap", () =>179+ Effect.gen(function* () {180+ const numbers = (yield* markdownIn("docs/adr")).map((path) =>181+ path.slice("docs/adr/".length, "docs/adr/".length + 5)182+ );183+184+ expect(numbers).toStrictEqual(185+ Array.makeBy(186+ numbers.length,187+ (index) => `${String(index + 1).padStart(4, "0")}-`188+ )189+ );190+ }).pipe(Effect.provide(NodeServices.layer))191+ );192+193+ it.live("GLOSSARY.md defines each term the code uses", () =>194+ Effect.gen(function* () {195+ const glossary = (yield* read("GLOSSARY.md")).split("\n");196+197+ expect(198+ TERMS.filter((term) => !glossary.includes(`**${term}**:`))199+ ).toStrictEqual([]);200+ }).pipe(Effect.provide(NodeServices.layer))201+ );202+});modified:AGENTS.md+13 added-12 removed
1 # Myr2 3-Myr is a whole Git platform on Cloudflare. Everything a project ships is public, the contribution process is typed code, and a push lands only by passing a typed gate. It is our entry to Cloudflare's "Build the next GitHub" competition, which closes Wed Oct 14, 11:59 PM PDT.3+Myr is a Git platform on Cloudflare. Everything a project ships is public, its contribution process is typed code on main, and a push lands only by passing a typed gate. It is our entry to Cloudflare's "Build the next GitHub" competition, which closes Wed Oct 14, 11:59 PM PDT.4 5+The core loop runs on Cloudflare today: a person claims an ask, pushes an answer through the platform's git gateway, and the platform checks it and lands it, or refuses it: the cheap stages answer in git's own output, and the rest arrive later in `status`, `watch`, MCP and the verdict note. The CLI, MCP and the web all serve the same contracts, and typed visibility (layers, held-back checks, posture, the ledger and write-only env values) plugs in as one cartridge. `README.md` says how to run it, check it and cut it; `docs/adr/` records each decision and why; `GLOSSARY.md` defines the words.6+7 `bun run verify` is the gate. The principles table names the check that holds each rule; a rule marked "No fence" is held by review.8 7-The plan is the synthesis: `~/Developer/projects/wanted-explainer/notes/git-platform-research/zoom-out/synthesis.md`, published at https://plans.gneiss.run/wanted-explainer/zoom-out/synthesis.html. Read the section your task touches:8-9-- the concept: §3;10-- the repo tree and stack: §4, with the final tree in §13.3;11-- dependency versions: §4.4;12-- the day plan and cut lines: §7.2;13-- the GLOSSARY.md and ADR drafts: §8.14-9 ## Principles10 11 A check wins over prose: if this file and a check disagree, fix this file.12 5 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); `packages/protocol/test/mcp.test.ts` (every MCP tool's schemas, with no JSON Schema leak); 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/web/test/production-bundle.test.ts` (no dev-world module in the web's production build); `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). 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 or Artifacts binding) and `apps/platform/test/env.test-d.ts` (only the platform's has both) |28-| 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`. No fence yet: one push deduped by (repo, sha) across the gateway's record and OnPush's (W3 313 #2) |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`. 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`) |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); `apps/platform/test/project-do.test.ts`. No fence: `Effect.sleep` and `Effect.delay` in `packages/project/src` |12 unmodified lines39 - a cut that follows the README's "Keep or cut".40 41 **Needs the user's sign-off:**42 49-- a dependency outside the synthesis §4.4 adopt list;43+- a dependency that no `package.json` in the repo has yet;44 - any version change to effect, wrangler or pi;45 - loosening `oxlint.config.ts`, `tsconfig.base.json` (map, overrides, allow-lists), `bunfig.toml`, `turbo.json` or `package.json` scripts;46 - renaming or removing a DO class;47 - deleting any Cloudflare resource;48 - any deploy during a recording.49 50 ## Commands51 58-Run each as `bun run <name>` from the repo root.52+Run each as `bun run <name>` from the repo root; `--` passes flags to the script.53 54 - `verify`: the gate (see Verify).55 - `check`: lints and checks formatting; an unused escape directive fails it.56 - `fix`: applies lint fixes and formatting.1 unmodified line58 - `test`: runs every workspace's tests.59 - `brand:check`: fails when the name appears outside `packages/brand` and prose.60 - `bytes:check`: fails when a Worker's bundle grows past its byte budget.61 - `lockfile:check`: fails when `bun.lock` is out of date with the manifests.62+- `prepare`: runs on `bun install` and patches TypeScript with the Effect language service.63 - `env:check`: shows the env with its values redacted.64 - `ops -- <command>`: runs cf with the ops credentials (see Boundaries).65+- `bootstrap -- --stage <stage>`: makes a stage's Cloudflare resources; a second run creates nothing, and `--dry-run` only prints the plan.66+- `deploy -- --stage <stage>`: the one way to deploy. It runs `verify`, deploys the three Workers with Wrangler, reads the push trigger back, then runs `smoke`.67+- `smoke -- --stage <stage>`: read-only probes against a live stage.68+- `seed`: puts the two example projects on a platform (`--world node` on this machine, or `--stage <stage>`); a second run changes nothing.69+- `swarm`: not built yet, so it says so and exits 1. Once built, it runs fictional contributors, on several harnesses, against one split family on a stage.70+- `release`: not built yet, so it says so and exits 1. Once built, it builds the CLI's package and binaries, which the platform serves from its own bucket. Only a person publishes.71 72 ## Nouns73 74 Each code noun has one home:71 unmodified linesmodified:GLOSSARY.md+34 added-6 removed
18 unmodified lines19 **Claim**:20 One person's exclusive, expiring right to answer an ask, made of a fork and a scoped token; kept alive only by pushes.21 _Avoid_: lease, lock, assignment22 23+**Claim fork**:24+The fork a claim is made of, named `<project>--<ask>--<handle>`, to which the claimant pushes answers.25+_Avoid_: branch, feature branch26+27+**Working fork**:28+A person's own fork of a project, named `<project>--me--<handle>`, that holds a decider's own changes before they land and a proposer's sealed answers.29+_Avoid_: personal fork, scratch repo30+31 **Check**:32 The predicate that judges an answer: the ask's own check plus the project's checks, run by the platform on the exact merged tree.33 _Avoid_: test (when the whole judgement is meant), CI, eval34 1 unmodified line36 The rule that an ask opens only if its check fails on main twice in the same way, by an assertion rather than a load error.37 _Avoid_: failing test requirement38 39 **Check kind**:32-The shape of an ask's check: redThenGreen, lintToZero, ratchet or migrate.40+The shape of an ask's check: redThenGreen, lintToZero, ratchet, migrate, or symbolAbsent (a family's delete child).41 42+**Family**:43+A migrate ask whose old name is used in two or more modules, opened as one child ask per module that uses it, each with that module as its territory, plus a delete child that waits on every child and checks the name is gone; the parent closes when its last child lands.44+_Avoid_: epic, subtasks, batch45+46 **Territory**:47 The module (by default a workspace package) an answer may change.48 _Avoid_: scope (when meaning paths), lane, footprint49 1 unmodified line51 One or more members of the closed, typed union the platform returns instead of landing, all from the cheapest failing stage, each with a reason, a reproducing command, a next step, and whether retrying can help.52 _Avoid_: rejection, error, failure, CI failure53 54 **Proposal**:43-A request to open an ask, from anyone not denounced, that expires unless a decider accepts it.55+A request to open an ask, or to flag an existing one, from anyone not denounced; it expires unless a decider accepts it.56 _Avoid_: feature request, suggestion57 58 **Sealed answer**:59 An answer recorded with a proposal and judged after the ask opens, without the decider reading its diff.12 unmodified lines72 The platform's commit of a checked tree to main, written by the platform with credit trailers.73 _Avoid_: merge, ship74 75 **Landed SHA**:64-The commit the platform itself last landed; the only place rules are read from.76+The commit the platform itself last landed on main; the only commit a project's rules are read from.77 _Avoid_: HEAD, tip of main78 79+**Outcome**:80+Where an offered answer stands: Checking, Landed, WaitingOnParent, AwaitingFinish, AwaitingDecision or Refused; only Refused carries refusals, and waiting is not a refusal.81+_Avoid_: result, build state, CI status82+83 **Judge closure**:84 Every file that decides what the checks do (check files, test and lint config including lint plugin sources and rule fixture tests, CI files, git and harness hook configs, scripts, the config folder, .env.schema and committed .env.* files); no answer may change it.85 _Avoid_: protected paths86 4 unmodified lines91 A counted budget per territory, recorded at landing and lowered automatically, that answers may lower but never raise; only a decider raises it.92 _Avoid_: baseline (alone), suppression file93 94 **Verdict**:79-The record of one check run: base, head, patch-id, level and the platform as verifier, kept with the landing.95+The record of one check run: base, head, patch id, level and the platform as verifier, kept with the landing.96 _Avoid_: approval, review97 98+**Patch id**:99+The platform's own fingerprint of an answer's change set: a hash over each path the answer changes, with its content before and after, so the same change gives the same id however its commits were made.100+_Avoid_: git patch-id, diff hash101+102 ## People and attention103 104 **Asker**:105 The person credited with deciding a change was worth making.5 unmodified lines111 **Decider**:112 A person whose decisions open asks, accept proposals and finish answers for an area.113 _Avoid_: reviewer, approver, owner114 115+**Decision**:116+One choice put to a project's deciders, with its evidence and a safe default that is taken if nobody decides before it expires.117+_Avoid_: approval, vote, review request118+119 **Today**:96-A decider's daily page of decisions with evidence and safe defaults, held to a budget.120+A decider's daily page of open decisions, ordered by expiry and held to their budget; the overflow waits for a later day.121 _Avoid_: inbox, queue, dashboard122 123 **Budget**:100-The number of decisions a decider takes per day; overflow waits and expires.124+The number of decisions a decider takes per day; a decision past it waits, and one that expires undecided takes its default.125 126 **Vouch**:127 A line in the project's vouch file by which a member admits a person to claim and to submit sealed answers.128 _Avoid_: approval, whitelist61 unmodified lines190 **Config folder**:191 The .myr/ folder on main holding the project's process as TypeScript: project.ts, kinds, asks, visibility.ts, the vouch file.192 _Avoid_: settings, workflow files193 194+**Policy**:195+A project's rules as the platform evaluated them from the config folder at one landed SHA, or the defaults when the project has no config folder.196+_Avoid_: settings, config (when meaning the evaluated result)197+198 **Run block**:199 The config folder's declaration of the project's own commands: setup, doctor, test, checks.200 201 **Gateway**:6 unmodified lines