Skip to content

Latest commit

 

History

History
85 lines (71 loc) · 25.8 KB

AGENTS.md

File metadata and controls

85 lines (71 loc) · 25.8 KB

Working on Executor

Read coding style before changing code, and test accounts for authenticated local/stage/production testing.

Boundaries & architecture

  • Effect v4 internally, ordinary values and Promises at public SDK / apps author boundaries. Derive author callback types from native contracts; compose Effects directly inside the library.
  • Product-owned authorization. Core SDK ownership is a lookup primitive, not permission enforcement. Share capabilities and UI views without forcing hosted organizations into local or adding isCloud flags.
  • Migrations must keep the app online. Cloud migrations run before the replacement server deploys; a failed deploy does not roll back SQL. Add schema first, deploy code that uses it, drop obsolete fields in a later release. Never drop/rename a required column before replacement deploys, never add a maintenance Worker, never reset data or relabel a schema version. Verify fresh setup, retained data, repeat runs, and rollback on real adapters (storage).

Tests

  • Every product change is proven from what a person or agent sees. Add or change its behavior in the feature map, then prove it with a journey or a test that ships a break, or block it with the reason. Which proof a change needs, and the whole path from map to verdict: proving a change. The pieces: feature map, journeys, lab, test policy, gate and proof.
  • Tests live in a test/ directory beside the src/ they verify and run on vitest through bun run test (one package or file: bun run test <path>); hosted tests under test/hosted/ run with bun run test:hosted. Journeys live in journeys/ and run with bun run journeys. The harness for both is lab/ (@executor-js/lab).
  • The same commit always gives the same result. A test or journey is never retried, re-run on failure, skipped, focused or marked todo.
  • Never wait on wall-clock time. No sleeps, timers, polling or time budgets. A test waits on host.clock.advance, host.clock.fork for work that waits on the clock, host.background.run, or a completion the product exposes. A journey waits on the landmark an action leads to and on the page's settle marks; when a page gives no signal, add one in the product or block the behavior. Timeouts only detect hangs.
  • One clock, owned by the test. Time comes from host.clock. If the product reads time the clock cannot reach, the test is blocked on a missing product seam: report it, never work around it. Journeys have no clock: behavior that needs time passing is proven by a test.
  • No network. Only loopback and registered stand-ins (egress.standIn, or a stand-in a journey declares); anything else fails the run and names the URL. bun run test, test:hosted, journeys and surface run in a loopback-only network namespace (scripts/no-network.ts): any name lookup or connection beyond loopback by any process they start fails the run and names the address and the process (record: network.json beside run.json). Defaults that reach the internet are turned off for every process the lab starts in lab/src/contracts/offline.ts. Where the machine allows no namespace the run says loudly that it had a network, and under CI it refuses; such a run is not a no-network result: get one with bun run remote. Images the suites build from or start must be on the machine first: bun run images:pull.
  • No shared state. Every test and journey gets its own host or instance, data directory, port and database, and passes in any order with any number of workers. Order is shuffled every run and the seed is printed; replay with LAB_SEED=<seed>. Every Cloud journey that runs executor login lives in journeys/test/cli-sign-in.journey.ts, because the CLI keeps sign-ins per host.
  • Assert on structure. Compare normalised data (host.normaliser; snapshots, accessibility trees and transcripts are normalised automatically): ids by order of first appearance, times relative to the start. Never raw ids, raw timestamps or pixels.
  • Through a public surface only. A test reaches the product through HTTP, MCP, the CLI or the UI, never by importing implementation: it imports @executor-js/lab, its sibling .verifies.ts, expect, effect and src/contracts/ modules (lint test-policy/through-surface). The only exception is an invariant over a pure rule, written as a property, listed with its rule and why no surface shows it in policy/src/invariants.ts.
  • Everything names what it verifies. x.test.ts registers its tests with tests(declarations, bodies) from ./x.verifies.ts, which names for each a feature-map behavior or an entrypoint of surface/entrypoints.txt, its invariant, or its check. A journey's declaration names its behaviors in proves. Both are typed: a typo is a compile error, and when what they name goes, bun run tests:check or bun run features:check fails until they go too. Coverage is generated into policy/coverage.md by bun run tests and surface/journeys.md by bun run features.
  • Everything ships a break. A break is a patch under which the test or journey fails where it says: test/breaks/<test id>.patch with { "fails": "assertion" | "snapshot", "why" }, proved by bun run tests:break <test id>; journeys/breaks/<journey id>.patch with { "fails": "<checkpoint or transcript>", "why" }, proved by bun run journeys:breaks <journey id>. tests:check and features:check fail when a break is missing or no longer applies.
  • Same commit, same result. A property checks the same generated inputs on every run of a commit: its seed comes from its test id, not from the run. Cases it once failed on are recorded and replayed first, and a known product defect lives in the test's known-defect list with its smallest case, printed in policy/coverage.md, until it is fixed. New inputs are tried outside the gate with bun run explore.
  • Admission before gating. A new or changed test file or journey gates only after it passes every run of admission across the conditions in ci/src/contracts/admission.ts (bun run test:admission <files> for tests; the gate admits journeys). To run one of the gate's journey units yourself before pushing: bun run remote --size xlarge -- bun run ci gate admission --kind journeys --file <journey file> --members <journey,…> --cell <0-5> --runs <n> --sized-to-this-machine --out /tmp/admission. It sizes the unit to the machine it is on and says so in its first line, records nothing, and is refused inside the gate's own jobs; it shows whether the unit passes in that condition, not how long the gate takes. --out has to be outside any checkout, because a journey run refuses to write evidence inside one. On a smaller machine fewer runs fit at once (a Cloud journey runs one at a time in 31 GB) and the unit stops at its deadline, so pass --deadline-seconds <n> when you need every one of --runs.
  • Never bend a test or journey to pass. A product defect, or a disagreement between the map and the product, is blocked with its seam in the files journeys/src/journeys/blocked.ts lists and reported, never waited out or recorded as right.

Heavy commands go to boat.dev

  • On a host that other agents share, run every suite, browser run or build that takes more than a minute or a few cores with bun run remote -- <command>: bun run check, bun run test, bun run journeys:build/journeys, bun run test:hosted, bun run typecheck, image builds. Quick single-file runs may stay local, under nice -n 10; on a machine that allows no network namespace they run with a network (see No network).
  • It sends exactly HEAD (a git archive, rebuilt there as the same commit) to a fresh machine, runs the command with no network but loopback and its own containers, streams its output and exits with its status. --patch also sends uncommitted changes; --back <path> copies a path in the checkout back; --out <dir> copies $REMOTE_OUT back (evidence that must live outside a work tree); --shards N splits over N machines ({shard}/{shards} in the command), --size xlarge for 16 cores. Any run with a Cloud journey in it needs --size xlarge: the journeys' memory check plans Cloud at about 11 GB, what it holds by the end of a whole suite, however short the run, so the default 16 GB machine is refused at any worker count; Local and self-host files fit there. A whole suite on one Cloud instance can hold about 220 Cloud journeys (116 today): under the local runtime each new organization leaves about 23 MB in Cloud's app-data worker, which dies at its memory limit after about 260 to 280 of them, and the gate reports a worker that dies as the product failing.
  • Machines delete themselves at the end and stop on their own 10 minutes after the runner dies (--max-minutes, default 120, is the hard limit). bun run remote status lists them. A run's runner keeps its machine up; once the runner dies the machine stops by itself within 10 minutes, and only then is it anyone's to sweep: bun run remote gc deletes this repository's stopped machines and never one that is up, whatever state the provider reports (a machine whose job runs over a connection reads idle), and prints what it deleted and what it left. Stop a run of yours by its process; to delete a machine you started that is still up, bun run remote delete <machine id>, which refuses a machine started from another checkout (each name carries its checkout, xn-run-<checkout>-<time>-<suffix>). bun run remote base rebuilds the prepared base after a change to Node, bun, Playwright, Rust or the Dockerfiles' images.
  • Nothing secret is sent: a secret-like name (.env*, *.pem, *.key, id_*, token files), any .local/ or .reference/, or anything outside the commit and patch refuses the run. Never work around a refusal by renaming or archiving a file; a committed non-secret file is pinned by blob hash in scripts/remote.ts.
  • --allow-network gives the command the network. It is for diagnosis only, and a result from it is not a no-network verdict (the suite runners still enter their own namespace there; LAB_ALLOW_NETWORK=1 keeps the network, outside CI only).

Public v2 export mirror

  • Public UsefulSoftwareCo/executor branch v2 is overwritten from executor-next main on export. Never merge, push to, or open PRs directly against v2.
  • To land an external contributor's v2 PR so GitHub marks it merged: port it into a draft executor-next PR with a commit body line Public-PR: UsefulSoftwareCo/executor#<number> <full head sha>. Keep the SHA current if the contributor pushes updates.

PRs, releases & workflow

  • CI, release and preview tools: bun run ci --help lists every one (the gate, proof, Cloud deploys, releases, products, previews, the scoreboard); bun run ci <command> --help gives its flags.
  • Setup: in a fresh checkout run bun install before anything else.
  • Workspace: keep ~/agent-workspace/executor-next clean on main. Do all work in a rift workspace on a named branch; before starting, run bun run workspace:check --task in the rift. It fetches origin and changes nothing; it checks only its own checkout: clean, inside a rift, on a named branch other than main, and not behind origin/main.
  • Before pushing: run bun run format and bun run check.
  • After pushing: wait with bun run ci verdict --sha $(git rev-parse HEAD) --pr <N>, never by sleeping, polling or watching the run. It blocks up to 9 minutes and exits with the verdict: 0 pass, done; 1 fail: reproduce each printed cause with its command, fix, push; 2 fails only on pending admission: do not change code for it; 3 inconclusive: proof code changed, tell the owner; 4 no readable verdict, 5 not started: nothing says your code is at fault, remove the printed cause or tell the owner; 6 superseded: wait for the head it prints; 7 gave up: run the printed resume command; 8 could not ask GitHub: read the printed error. A change to any journey, lab/ or ci/ is proof code and is always inconclusive. How an owner reads the proof page: proving a change.
  • Before handing over: bun run ci proof show --pr <N> reads the proof; on exit 2 name each behavior it prints as unproven in the pull request, with what proves it instead.
  • Evidence after a re-run: an earlier attempt's artifacts are not evidence you can rely on: GitHub removes some of them each time every job of a run is re-run (about 50, lowest ids first; re-running only the failed jobs removes none). An attempt's evidence is its stored proof, linked from that attempt's proof status (https://proof.executor.engineering/b/<id>/); bun run ci verdict finds it.
  • Stacks: land stacks only via gh stack merge <top PR> --yes --squash after checking all layers are in one stack on main. Never bypass the main ruleset (--admin, API bypass). Never run CI checks on macOS runners.
  • Release notes: for changes users of Cloud, the CLI, desktop, or self-host would notice, add Release-note: Feature|Improvement|Fix: <plain sentence> in a commit message body (PR titles are never published; see RELEASING.md). A note goes to every product its change reaches; node scripts/releases/release-notes.ts --check <base> prints who and the note's hash, where <base> is the branch the pull request merges into (origin/main, or the branch below it in a stack): it reads the commits in <base>..HEAD, and an entry with that hash in scripts/releases/note-audiences.ts changes it.
  • apps versions: a change to what the apps package ships needs a higher version in packages/apps/package.json, bun install, and bun run apps:record, committed together; a recorded version's content never changes (apps publishing).
  • Generated / patched files: never edit node_modules directly (use bun patch <pkg>). Never read/edit packages/apps/protocols/*.json directly (run bun run apps:protocols / --write; see apps publishing).
  • Cloud Worker size: bun run check builds the Cloud Workers as a deploy does and fails when one is over its budget in apps/hosted/cloud/src/infrastructure/worker-build.ts, or grew past the size recorded for it in apps/hosted/cloud/worker-sizes.json by more than growthLimit (apps/hosted/cloud/scripts/worker-sizes.ts). To allow growth, record it with its reason in the same change: bun run hosted:cloud:worker-sizes --record <worker> "<why it is worth the cold-start time>". Never raise budgets to fit a change.
  • Documentation: every bun run script, bun run ci tool, repository path and link that AGENTS.md, the top-level documents, notes/, .agents/ and the READMEs of journeys/, lab/, policy/, ci/, surface/ and scripts/ name must exist (scripts/check-docs.ts). Write numbers that change (counts of journeys, behaviors) only as a pointer to the generated file that holds them.
  • Test failures: never re-run a failed test or job to get a pass. Replay its printed seed and matrix cell locally; a failure that does not reproduce is still a defect in the test or the product. A gate run with no verdict because machines could not be prepared (a step before their own command failed, and nothing that ran failed) has no failed test: running those machines again, with a new push or "re-run failed jobs", is not a re-run of a failed test.

Enforcement map

Every enforcer below runs in bun run check (steps in ci/src/contracts/checks.ts) or in the gate, unless the row says otherwise.

Rule Enforcer
Format, lint, executor/* Oxlint rules format and lint steps (.oxlintrc.jsonc, scripts/oxlint-plugin.ts)
Types & Effect diagnostics typecheck step (bun run typecheck, tsc-rs)
No retries, re-runs, skips or focused tests and journeys vitest.config.ts and vitest.journeys.config.ts (retry: 0, allowOnly: false), scripts/test.ts and scripts/journeys.ts refuse retry and focus flags, lab reporter fails skipped/todo/retried runs, executor/no-test-timeout-or-retry and executor/no-skipped-or-focused-tests
No waiting on wall-clock time executor/no-test-waiting, test-code timer tripwire (lab/src/implementation/tripwires.ts), hang-only timeouts in the vitest configs; journeys read pages only once settled (web.checkpoint)
One clock, owned by the test controlled clock (lab), executor/no-test-wall-clock, test-code Date tripwire; product Date and randomUUID tripwires report call sites
No network scripts/no-network.ts (loopback-only namespace and a watcher for name lookups and connections, network.json; refuses a run with a network under CI), scripts/no-network/netns.sh, lab/src/contracts/offline.ts, lab egress guard (fetch, sockets, DNS, Effect HttpClient) checked after every test, the journey browser's request filter
No shared state a host or instance per test and journey (fresh data dir, own port), shuffled order with printed seed, pool: forks, handle-leak check after every test, executor/journey-through-harness; the harness refuses Cloud executor login from a second journey file
Assert on structure normalising snapshot serializer (lab/src/vitest/setup.ts), normalised journey trees and transcripts (journeys/src/implementation/harness.ts), executor/no-pixel-assertions
Admission before a test or journey gates the gate's admission units (bun run ci gate admission, running scripts/test-admission.ts and ci/scripts/journey-admission.ts)
Nothing secret, .local/ or .reference/ sent to boat.dev; same commit there scripts/remote.ts, on every bun run remote and in bun run check (remote upload rules: the same stageTree over the tracked tree, so a pull request cannot make every later commit unsendable; upload rules checked on the commit, the patch and the transfer; tree and commit hashes checked on the machine)
Dependency patches & exact versions dependency-patches and exact-versions steps
bun.lock matches every package.json lockfile step (scripts/check-lockfile.ts)
Tests only through a surface; invariants listed lint test-policy/through-surface (scripts/oxlint-test-policy.ts), policy/src/invariants.ts
Every test names what it verifies and ships a break lint test-policy/declares-what-it-verifies, typed .verifies.ts, test-policy step (bun run tests:check); bun run tests:break proves one
Every journey names its behaviors, agrees with the map and ships a break; blocks name a seam typed proves, feature-map step (bun run features:check); bun run journeys:breaks proves one
Every served entrypoint is claimed or listed as unclaimed surface-snapshots step (bun run surface:check)
Host protocols, telemetry, API errors host-protocols, app-telemetry and api-errors steps
A published apps version never changes content apps-version step (scripts/releases/apps-recorded.ts, packages/apps/released.json); on main, the publish compares with npm
Better Auth refuses redirects and keeps its security patches auth-security step (bun run auth:security)
Cloud Worker upload sizes, growth and the sites' links cloud-build step: bun run hosted:cloud:worker-sizes, then bun run site:links and bun run docs:audit on the site it built
GitHub Actions workflow syntax workflows step (scripts/check-workflows.ts: GitHub's workflow schema, needs and local uses)
Documentation names only what exists doc-references step (scripts/check-docs.ts)