Merge perf/agent-skills-index 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 2858640, e5c5257 · Browse files · 3 files·+146 added−44 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+146 added−44 removed
- tests:+57 added−20 removed
- other:+89 added−24 removed
Provenance
- Commit
25f9e66- Tree
b6155e4- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
2858640- Parent 2
e5c5257
3 files changed+146 added−44 removed
modified:apps/platform/src/well-known.ts+88 added-23 removed
1-import { describedIn } from "@repo/agent-kit/generated-file";1+import { contentHash, describedIn } from "@repo/agent-kit/generated-file";2 import {3 contributeDescription,4 contributeSkillName,5 contributeSkillPaths,4 unmodified lines10 import { CodeCache } from "@repo/project/code/cache";11 import { FrontPage } from "@repo/project/front-page";12 import { landedRef } from "@repo/project/lander";13 import { Projects } from "@repo/project/projects";14+import type { ProjectListing } from "@repo/protocol/domain/front-page";15 import {16 keyOf,17 nameOfKey,18 ProjectKey,5 unmodified lines24 import {25 Array as Arr,26 Cause,27 Context,28+ DateTime,29 Effect,30 Option,31 Order,32 Schema,119 unmodified lines152 );153 154 const decodeKey = Schema.decodeUnknownOption(ProjectKey);155 154-const index = Effect.gen(function* () {155- const listed = yield* FrontPage.use((frontPage) => frontPage.projects());156+const INDEX_VERSION = 1;157 157- const projects = Arr.sort(158- Arr.dedupe(listed.map(({ project }) => project)),159- Order.String158+const KeptIndex = Schema.fromJsonString(159+ Schema.Struct({ content: Schema.String })160+);161+162+const decodeKeptIndex = Schema.decodeOption(KeptIndex);163+164+const encodeKeptIndex = Schema.encodeEffect(KeptIndex);165+166+const indexOf = (projects: readonly ProjectName[]) =>167+ Effect.gen(function* () {168+ const found = yield* Effect.forEach(169+ projects,170+ (project) =>171+ Effect.map(172+ landedSkill(project),173+ Option.map((content) => ({174+ content,175+ description: Option.getOrElse(describedIn(content), () =>176+ contributeDescription(project)177+ ),178+ name: contributeSkillName(project),179+ url: skillUrl(project),180+ }))181+ ),182+ { concurrency: FAN_OUT }183+ );184+185+ return (yield* wellKnownSkills(Arr.getSomes(found))).content;186+ });187+188+// A project's main moves by a landing alone, and each listing carries the189+// instant of its project's last one, so the index is the same while no listed190+// project lands. It is kept under the listing's digest: a request then reads191+// one listing and one kept file, and wakes no project. No project's key holds192+// `--`, so the kept index shares no key with a project's.193+const indexKey = (listed: readonly ProjectListing[]) =>194+ Effect.map(195+ contentHash(196+ JSON.stringify(197+ listed.map(({ landedAt, project }) => [198+ project,199+ landedAt === undefined ? null : DateTime.formatIso(landedAt),200+ ])201+ )202+ ),203+ (digest) => `agent-skills--index/v${INDEX_VERSION}/${digest}`204 );205 162- const found = yield* Effect.forEach(163- projects,164- (project) =>165- Effect.map(166- landedSkill(project),167- Option.map((content) => ({168- content,169- description: Option.getOrElse(describedIn(content), () =>170- contributeDescription(project)171- ),172- name: contributeSkillName(project),173- url: skillUrl(project),174- }))175- ),176- { concurrency: FAN_OUT }206+const byProject = Order.mapInput(207+ Order.String,208+ ({ project }: ProjectListing) => project209+);210+211+const index = Effect.gen(function* () {212+ const listed = Arr.sort(213+ Arr.dedupeWith(214+ yield* FrontPage.use((frontPage) => frontPage.projects()),215+ (a, b) => a.project === b.project216+ ),217+ byProject218 );219 179- const file = yield* wellKnownSkills(Arr.getSomes(found));220+ const cache = yield* CodeCache;221+ const store = yield* CodeStore;222+ const key = yield* indexKey(listed);223 224+ const content = yield* cache.through(225+ key,226+ Effect.gen(function* () {227+ const kept = Option.flatMap(yield* store.get(key), decodeKeptIndex);228+229+ if (Option.isSome(kept)) {230+ return kept.value.content;231+ }232+233+ const built = yield* indexOf(listed.map(({ project }) => project));234+235+ yield* encodeKeptIndex({ content: built }).pipe(236+ Effect.flatMap((text) => store.put(key, text)),237+ Effect.catch((error) =>238+ Effect.logWarning("the agent skills index was not kept", error)239+ )240+ );241+242+ return built;243+ })244+ );245+181- return new Response(file.content, {246+ return new Response(content, {247 headers: { "cache-control": BRIEFLY, "content-type": "application/json" },248 });249 });250 78 unmodified linesmodified:apps/platform/test/well-known.test.ts+57 added-20 removed
1 unmodified line2 import { RefName, RepoHost } from "@repo/artifacts/repo-host";3 import { RepoHostMemory } from "@repo/artifacts/repo-host/memory";4 import { memoryFs } from "@repo/artifacts/repo-host/memory-fs";5 import { CodeStoreMemory } from "@repo/project/code-store/memory";6+import { FrontPage } from "@repo/project/front-page";7 import { FrontPageMemory } from "@repo/project/front-page/memory";8 import { landedRef } from "@repo/project/lander";9 import type { ProjectApi } from "@repo/project/project";10 import { Projects } from "@repo/project/projects";11+import type { ProjectListing } from "@repo/protocol/domain/front-page";12 import { keyOf, LandedSha, ProjectName, RepoName } from "@repo/protocol/ids";13 import { UnknownProject } from "@repo/protocol/refusal";14 import { gitClient } from "@repo/testkit/git-client";15 import { untouchable } from "@repo/testkit/untouchable";14-import { Effect, Layer, Option, Ref, Schema } from "effect";16+import { DateTime, Effect, Layer, Option, Ref, Schema } from "effect";17 18 import { agentSkills } from "../src/well-known.ts";19 import { coreLoopWorld } from "./world.ts";20 243 unmodified lines264 });265 })266 ).pipe(Layer.provide(RepoHostMemory));267 266-const landedWhere = (landed: Ref.Ref<ReadonlyMap<ProjectName, LandedSha>>) =>268+const landedWhere = (269+ landed: Ref.Ref<ReadonlyMap<ProjectName, LandedSha>>,270+ heads: Ref.Ref<number>271+) =>272 Layer.succeed(273 Projects,274 Projects.of({275 create: () => Effect.die("the skills make no project"),276 get: (project) =>277 Effect.succeed(278 untouchable<ProjectApi>("ProjectApi", {279 head: () =>280+ Effect.andThen(281+ Ref.update(heads, (n) => n + 1),275- Effect.map(Ref.get(landed), (all) =>276- Option.match(Option.fromUndefinedOr(all.get(project)), {277- onNone: () => ({}),278- onSome: (sha) => ({ landed: sha }),279- })282+ Effect.map(Ref.get(landed), (all) =>283+ Option.match(Option.fromUndefinedOr(all.get(project)), {284+ onNone: () => ({}),285+ onSome: (sha) => ({ landed: sha }),286+ })287+ )288 ),289 })290 ),291 })292 );293 294+const listedFrom = (listings: Ref.Ref<readonly ProjectListing[]>) =>295+ Layer.succeed(296+ FrontPage,297+ FrontPage.of({298+ credits: () => Effect.succeed([]),299+ entries: () => Effect.succeed([]),300+ projects: () => Ref.get(listings),301+ recentLandings: () => Effect.succeed([]),302+ })303+ );304+305 describe("the agent skills index, kept by each project's landed commit", () => {306 it.effect(288- "reads each skill once while no main moves, and again only for a project whose main moved",307+ "reads each skill once while no main moves, wakes no project while no listed project lands, and reads again only the skill whose main moved",308 () =>309 Effect.gen(function* () {310 const counts = yield* Ref.make({ files: 0, refs: 0 });311+ const heads = yield* Ref.make(0);312 313 const landed = yield* Ref.make<ReadonlyMap<ProjectName, LandedSha>>(314 new Map()315 );316 317+ const firstLanding = DateTime.makeUnsafe("2026-10-01T09:00:00Z");318+319+ const listings = yield* Ref.make<readonly ProjectListing[]>([320+ { ...listing(burrow), landedAt: firstLanding },321+ { ...listing(datekit), landedAt: firstLanding },322+ ]);323+324 yield* Effect.gen(function* () {325 const host = yield* RepoHost;326 const client = yield* gitClient(memoryFs());327 34 unmodified lines362 ),363 ({ skills }) => skills.map(({ description }) => description)364 );365 339- const reads = Effect.flatMap(340- Ref.getAndSet(counts, { files: 0, refs: 0 }),341- Effect.succeed366+ const reads = Effect.map(367+ Effect.all({368+ files: Ref.getAndSet(counts, { files: 0, refs: 0 }),369+ heads: Ref.getAndSet(heads, 0),370+ }),371+ ({ files, heads: woken }) => ({ ...files, heads: woken })372 );373 374 const once = yield* described;375 const readOnce = yield* reads;376 const twice = yield* described;377 const readTwice = yield* reads;378 379+ // A landing moves the project's main and its listing's instant.380 yield* Ref.update(381 landed,382 (all) => new Map([...all, [datekit, LandedSha.make(moved)]])383 );384+ yield* Ref.update(listings, (all) =>385+ all.map((each) =>386+ each.project === datekit387+ ? {388+ ...each,389+ landedAt: DateTime.makeUnsafe("2026-10-02T09:00:00Z"),390+ }391+ : each392+ )393+ );394 395 const afterMove = yield* described;396 397 expect({5 unmodified lines403 twice,404 }).toStrictEqual({405 afterMove: ["Answer any one of datekit's asks."],406 once: ["Answer one of datekit's asks."],366- readAfterMove: { files: 1, refs: 0 },367- readOnce: { files: 2, refs: 0 },368- readTwice: { files: 0, refs: 0 },407+ readAfterMove: { files: 1, heads: 2, refs: 0 },408+ readOnce: { files: 2, heads: 2, refs: 0 },409+ readTwice: { files: 0, heads: 0, refs: 0 },410 twice: ["Answer one of datekit's asks."],411 });412 }).pipe(413 Effect.provide(414 Layer.mergeAll(415 countedHost(counts),416 CodeStoreMemory,376- landedWhere(landed),377- FrontPageMemory.layer({378- credits: [],379- entries: [],380- projects: [listing(burrow), listing(datekit)],381- })417+ landedWhere(landed, heads),418+ listedFrom(listings)419 )420 )421 );422 })2 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); `packages/agent-kit/test/install-channels.test.ts` and `apps/web/test/agents.test.tsx` (every snippet, command and link on the Install page is `@repo/agent-kit`'s, and the old `/agents` answers a 301 to `/install`); `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, limit, endpoint 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`); `packages/protocol/test/project-name.test.ts` (`ProjectName` is the one parser of a project's name for every surface: lowercase, a legacy key read as its full name, encoded only in the full form, and a key that reads back to its name); 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`); `apps/web/test/shell.test.tsx` (the footer's wordmark is `Brand.domain`, read from `@repo/brand`, never typed) |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); `apps/platform/test/mailer.test.ts` (sign-in's `Mailer` port, its `/memory` adapter and its Email Service adapter over the `EMAIL` 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); `packages/project/test/metrics.test.ts` (the `Metrics` port's `/memory` adapter, `packages/project/src/metrics/memory.ts`, and its Analytics Engine adapter over `METRICS`, which drops a point the dataset refuses and fails nothing; `apps/platform/test/worker-init.test.ts` writes through the Worker's own ports); `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); `packages/project/test/description.test.ts` and `packages/project/test/description-d1.test.ts` (the `ProjectDescriptions` port's `/memory` adapter, `packages/project/src/description/memory.ts`, and its D1 adapter, whose unreadable rows and missing table are misses); `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); `packages/telemetry/test/spans.test.ts` (the spans port: Effect's `Tracer`, bridged onto a Worker's `tracing` by `packages/telemetry/src/spans/binding.ts`, with its `/memory` adapter, `packages/telemetry/src/spans/memory.ts`, on which every span opens under the invocation's root, a sibling of the runtime's own, and an ended span is traced no more, as in workerd; only a Worker's composition imports `tracing` from `cloudflare:workers`). 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); `packages/config/test/observability.test.ts` (a Checker's container logs are off in every stage, and every container sets its own; the platform's traces are kept in the account and sent to no destination, since the runtime's own spans record each Project DO statement's bound values and each fetch's full URL); `packages/config/test/alerts.test.ts` (an alert's query counts rows of its own stage's Workers and datasets, never a layer's or another stage's); `packages/telemetry/test/spans.test.ts` (a span carries only the listed ids onto a trace, never a repo, a path or a query, and Issues reads ids alone), `packages/telemetry/test/logger.test.ts` and `packages/telemetry/test/defects.test.ts` (no line, report or span carries a Worker secret or a write-only value, and where a Worker keeps a defect by its name, no line it logs carries the defect's text), with `apps/platform/test/telemetry.test.ts` (every secret the platform's env decodes, each session token included, and a route's or a Project DO's defect kept by its name and frames alone, since its text may name a layer's repo, on a report and on any line whose cause holds it, a warning's included), `apps/platform/test/sandbox-adapters.test.ts` (a sandbox job's defect logged by its name and frames alone), and `apps/sandbox/test/telemetry.test.ts` (a sandbox job's lines carry none of its tokens, and a Checker's span keeps a defect by its name alone, since its text may quote a sealed path); `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); `packages/protocol/test/fork-address.test.ts` (a fork's address is a closed parse that never joins text into a ref path), with `packages/project/test/code.test.ts` and `apps/platform/test/code-reads.test.ts` (a fork is read only at the address of a claim fork the project lists, and a layer's repo, an unlisted fork or a repo's name is `UnknownRevision`); `packages/protocol/test/recent-landing.test.ts` and `packages/project/test/recent-landings-d1.test.ts` (a kept refusal is its tag and area alone); `packages/project/test/metrics.test.ts` (a metric names a project, a refusal's tag and area, a stage and a lane, with numbers: never a path, a command, a log or a held-back check); `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's latest landings name each by its project, and a refused answer by its tag and its area alone, never a check's name, suite, lane, path or log) and `apps/web/test/explore.test.tsx` (each project's card shows the posture its listing gives); `apps/web/test/ledger.test.tsx` (the Visibility tab's ledger adds no path, check name or file name, and the tab's views import nothing from the visibility cartridge) and `apps/web/test/env.test.tsx` (its Environment shows no value and no control to set or read one, and the old `/env` and `/ledger` answer a 301 to the tab); `apps/web/test/home.test.tsx`, `apps/web/test/today.test.tsx` and `apps/web/test/edge-cache.test.ts` (`/inbox` is read with the reader's own session and kept by no cache, and the old `/home` and `/today` answer a 301 to it); `apps/web/test/theme.test.ts` and `apps/web/test/settings.test.tsx` (the theme preference lives in `localStorage` and never in a cookie, so it makes no page personal); `apps/platform/test/pages.test.ts` (the sign-in page, as an MCP client's consent, escapes every value a client supplies, and every sign-in form shown again escapes what the person typed); `apps/platform/test/oauth.test.ts` (no account is written, and no grant given, until its email is proved by a mailed code, and a password reset reads the same for an address no account has); `apps/platform/test/gateway-owner.test.ts` (the gateway reads a full name, a source path, a legacy key or a fork's address to the repo its project's key names, and an owner alone or a name under a page's word to none) |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); `packages/project/test/recent-landings-d1.test.ts` (the same rows heard again change nothing, and at most `RECENT_LANDINGS_CAP` rows are kept); `packages/project/test/description.test.ts` (a landed project is read once while its last landing stands); `packages/project/test/metrics.test.ts` (each landing, refusal, checked lane, wait before checks and draft round is written at most once, from the outbox of the commit that keeps it, however often its push, report or settle is heard, and when a call's settle and the alarm's both hold its row), with `packages/project/test/project-store.contract.ts` (of two acks of one outbox row, only the first takes it). 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); `packages/project/test/recent-landings-d1.test.ts` (the same rows heard again change nothing, and at most `RECENT_LANDINGS_CAP` rows are kept); `packages/project/test/description.test.ts` (a landed project is read once while its last landing stands); `apps/platform/test/well-known.test.ts` (the agent skills index is kept by its listing's projects and last landings, so while no listed project lands it wakes no project, and a landing reads again only its own skill); `packages/project/test/metrics.test.ts` (each landing, refusal, checked lane, wait before checks and draft round is written at most once, from the outbox of the commit that keeps it, however often its push, report or settle is heard, and when a call's settle and the alarm's both hold its row), with `packages/project/test/project-store.contract.ts` (of two acks of one outbox row, only the first takes it). 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. Effect marks its unstable modules (`effect/http`, `effect/sql`, `effect/observability` and the rest) in place, with no `effect/unstable/*` path: one is off limits outside the paths its package's allow-list names. Off limits too: v3 `@effect/platform` and `@effect/cli`, and `effect/workflow` or `effect/cluster` on Workers. | `outdatedApi`; `unstableApiUsage` at error, with per-path `allowedUnstableApis` in `tsconfig.base.json`; `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, which fails on any exception or error-level line the stage's Workers logged since the first upload, or on a token that can't read them (`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` |113 unmodified lines