Merge cli/exit-codes 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 c742fc9, a7bcfd8 · Browse files · 32 files·+687 added−350 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
32 files+687 added−350 removed
- tests:+424 added−278 removed
- other:+263 added−72 removed
Provenance
- Commit
c19a862- Tree
d8780e3- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
c742fc9- Parent 2
a7bcfd8
32 files changed+687 added−350 removed
modified:apps/cli/src/hook/push-check.ts+2 added-2 removed
57 unmodified lines585960616263626364656667115 unmodified linesExpand all57 unmodified lines
/** * `PushCheck` over a child process: `command` (the CLI, as this process was * started) with `check --shape-only --offline --json --base <base>`, in * `root`. It exits 1 * when it refuses, so the exit code says nothing; the envelope says all. * `root`. A refusal ends it with the refusal's exit code, but the envelope * says all, so only the envelope is read. */export const pushCheckWith = ( command: readonly [string, ...string[]]): Layer.Layer<PushCheck, never, ChildProcessSpawner.ChildProcessSpawner> =>115 unmodified linesExpand allmodified:apps/cli/src/local/check.ts+3 added-6 removed
64 unmodified lines65 import { Command, Flag } from "effect/cli";66 import { ChildProcess, ChildProcessSpawner } from "effect/process";67 68 import { Credentials } from "../credentials.ts";69-import { Output, Reported } from "../output.ts";69+import { endRefused, Output, Reported } from "../output.ts";70 import { repoContext } from "../repo-context.ts";71 import type { RepoContext } from "../repo-context.ts";72 import { commitOf, localFacts, outsideAnyHook, runGit } from "./facts.ts";73 import {50 unmodified lines124 Output.use((output) =>125 Effect.andThen(output.note(text), Effect.fail(new Reported()))126 );127 128-/** Prints `refusals` the way every command does, then ends the command. */128+/** Prints `refusals` the way every command does, then ends the command with their exit code. */129 const refuse = (130 json: boolean,131 refusals: Array.NonEmptyReadonlyArray<Refusal>132 ) =>133 Output.use((output) =>134- Effect.andThen(135- output.refused({ command: COMMAND, json, refusals }),136- Effect.fail(new Reported())137- )134+ endRefused(output, { command: COMMAND, json, refusals })135 );136 137 /**138 * What a stale copy is told: which file, the landing it names, why it can728 unmodified linesmodified:apps/cli/src/local/init.ts+5 added-9 removed
28 unmodified lines29 import { Command, Flag } from "effect/cli";30 import { ChildProcess, ChildProcessSpawner } from "effect/process";31 32 import { gitHelperConfig } from "../credentials.ts";33-import { Output, Reported } from "../output.ts";33+import { endRefused, Output } from "../output.ts";34 import { parseRemote, repoContext } from "../repo-context.ts";35 import { projectFile } from "./project-file.ts";36 37 const COMMAND = "init";215 unmodified lines253 ["git", "add", "--", path],254 ["git", "commit", "--quiet", "--message", SUBJECT, "--", path],255 ]);256 257-/** Prints `refusal` once, as the CLI prints every refusal, and ends as `Reported`. */257+/** Prints `refusal` once, as the CLI prints every refusal, and ends as `Reported` with its exit code. */258 const refuse = (json: boolean) => (refusal: Refusal) =>259- Effect.gen(function* () {260- const output = yield* Output;259+ Output.use((output) =>260+ endRefused(output, { command: COMMAND, json, refusals: [refusal] })261+ );262 262- yield* output.refused({ command: COMMAND, json, refusals: [refusal] });263-264- return yield* new Reported();265- });266-263 /** Asks the platform to make the project; a refusal is printed once. */264 const makeProject = (payload: Payload, json: boolean) =>265 Effect.gen(function* () {266 const client = yield* Client;252 unmodified linesmodified:apps/cli/src/local/why.ts+4 added-4 removed
24 unmodified lines25 } from "effect";26 import { Argument, Command, Flag } from "effect/cli";27 import { ChildProcess, ChildProcessSpawner } from "effect/process";28 29-import { Output, Reported } from "../output.ts";29+import { endRefused, Output } from "../output.ts";30 import type { View } from "../output.ts";31 import { repoContext } from "../repo-context.ts";32 import type { RepoContext } from "../repo-context.ts";33 31 unmodified lines65 const isRefusal = Schema.is(Refusal);66 67 /**68 * Prints a refusal the platform answered with, once, through `Output`, and69- * ends with `Reported` (exit 1). Shared with `env set`.69+ * ends with `Reported` and the refusal's exit code. Shared with `env set`.70 */71 export const reportRefusals =72 (command: string, json: boolean) =>73 <A, E, R>(effect: Effect.Effect<A, E, R>) =>74 effect.pipe(75 Effect.catchIf(isRefusal, (refusal) =>76 Output.use((output) =>77- output.refused({ command, json, refusals: [refusal] })78- ).pipe(Effect.andThen(Effect.fail(new Reported())))77+ endRefused(output, { command, json, refusals: [refusal] })78+ )79 )80 );81 82 /**341 unmodified linesmodified:apps/cli/src/tui/command.ts+4 added-7 removed
10 unmodified lines11 import type { NotDecider, UnknownProject } from "@repo/protocol/refusal";12 import { Context, Effect, Option, Schema } from "effect";13 import { Command, Flag } from "effect/cli";14 15-import { Output, Reported } from "../output.ts";15+import { endRefused, Output } from "../output.ts";16 import { views } from "../render.ts";17 import { payloadFor, runTodayTui, TuiRefused } from "./run.ts";18 19 const COMMAND = "today";1 unmodified line21 const encodeToday = Schema.encodeUnknownEffect(TodayOf.successSchema);22 23 /**24 * The `today` contract's refusals, each printed once where the command's25- * refusals go; the command then ends `Reported`.25+ * refusals go; the command then ends `Reported`, with the refusal's exit code.26 */27 const reported = (json: boolean) => {28 const once = (refusal: NotDecider | UnknownProject) =>29- Effect.andThen(30- Effect.flatMap(Effect.service(Output), (output) =>31- output.refused({ command: COMMAND, json, refusals: [refusal] })29+ Effect.flatMap(Effect.service(Output), (output) =>30+ endRefused(output, { command: COMMAND, json, refusals: [refusal] })32- ),33- Effect.fail(new Reported())31 );32 33 return { NotDecider: once, UnknownProject: once };34 };82 unmodified linesmodified:apps/cli/src/main.ts+35 added-15 removed
3 unmodified lines4 * with theirs.5 */6 import { Brand } from "@repo/brand";7 import { ApprovalNeeded, MissingValue, Reported } from "@repo/protocol/cli";8+import { ExitCode } from "@repo/protocol/exit-code";9 import { Unauthenticated } from "@repo/protocol/principal";10 import { Refusal } from "@repo/protocol/refusal";11 import { Console, Effect, Exit, Layer, Option, Runtime, Schema } from "effect";12 import { CliConfig, CliError, Command, GlobalFlag } from "effect/cli";32 unmodified lines45 Command.withSubcommands(tree)46 );47 48 /** The exit code of a usage error, as for a command line effect/cli can't parse. */48-const USAGE = 2;49+const USAGE = ExitCode.usage;50 51 /**52 * The command was misused and said so in one line on stderr: the program53 * exits 2 and prints nothing more.49 unmodified lines103 ? Option.map(noPlatformOf(failure), ({ message }) => message)104 : Option.none();105 };106 106-/** What to say on stderr about a failure nobody printed yet. */107+/** What to say on stderr about a failure nobody printed yet, and the code the process ends with. */108 const noteFor = (failure: Failure) => {109 if (isUnauthenticated(failure)) {109- return signIn;110+ return { exitCode: ExitCode.noPerm, note: signIn };111 }112 113 if (isTransportFailure(failure)) {113- return `could not reach the platform: ${transportMessage(failure)}`;114+ return {115+ exitCode: ExitCode.unavailable,116+ note: `could not reach the platform: ${transportMessage(failure)}`,117+ };118 }119 116- return String(failure);120+ return { exitCode: ExitCode.failed, note: String(failure) };121 };122 123+/** How a failure printed already ends: as it said, or with its refusal's code. */124+const printed = (failure: Failure): Option.Option<Reported> => {125+ if (isReported(failure)) {126+ return Option.some(failure);127+ }128+129+ return isRefusal(failure)130+ ? Option.some(Reported.of([failure]))131+ : Option.none();132+};133+134 /**135 * Says once what nobody printed yet, and how the process ends: a misuse in121- * one line on stderr (exit 2); not being signed in with what to run next,122- * and a platform out of reach, on stderr (exit 1); a refusal or anything123- * `Reported`, nothing more (exit 1).136+ * one line on stderr (exit 2); not being signed in with what to run next137+ * (77), a platform out of reach (69) and anything else (1), on stderr; a138+ * refusal, or anything `Reported`, nothing more, with its own code.139 */140 const settle = (141 failure: Failure142 ): Effect.Effect<never, Reported | Misused, Output> =>143 Option.match(usageLine(failure), {144 onNone: () =>130- isReported(failure) || isRefusal(failure)131- ? Effect.fail(new Reported())132- : Output.use((output) => output.note(noteFor(failure))).pipe(133- Effect.andThen(Effect.fail(new Reported()))134- ),145+ Option.match(printed(failure), {146+ onNone: () => {147+ const { exitCode, note } = noteFor(failure);148+149+ return Output.use((output) => output.note(note)).pipe(150+ Effect.andThen(Effect.fail(new Reported({ exitCode })))151+ );152+ },153+ onSome: Effect.fail,154+ }),155 onSome: (line) =>156 Output.use((output) => output.note(line)).pipe(157 Effect.andThen(Effect.fail(new Misused()))158 ),16 unmodified lines175 * Runs the command `argv` names. Help asked for, or shown for a group run176 * without a subcommand, is a success. A misuse (a parse error, a missing177 * value, `--yes` left out, any failure whose `Runtime.errorExitCode` is 2)178 * ends as `Misused` (exit 2) after one line on stderr; every other failure159- * ends as `Reported` (exit 1), printed once: a refusal by the command,160- * anything else here. A defect (a stub's "not built") is not caught: the179+ * ends as `Reported`, printed once: a refusal by the command, with its180+ * exit code (`exitCodeFor`), anything else here (`settle`). A defect (a stub's "not built") is not caught: the181 * runtime prints it, loudly. `env set`'s words are screened before182 * effect/cli parses them, so a value typed where a flag goes is never183 * printed back.184 */43 unmodified linesmodified:apps/cli/src/output.ts+1 added-1 removed
13 unmodified lines14 15 import { Policy } from "./policy.ts";16 import type { Mode } from "./policy.ts";17 18-export { Reported } from "@repo/protocol/cli";18+export { endRefused, Reported } from "@repo/protocol/cli";19 20 export type { View } from "@repo/protocol/cli";21 22 export type { Mode } from "./policy.ts";206 unmodified linesmodified:apps/cli/test/local/check.test.ts+8 added-2 removed
33 unmodified lines34 import { asTester, unanswered } from "@repo/protocol/testing";35 import { gitOk } from "@repo/testkit/git";36 import {37 Array,38+ Cause,39 DateTime,40 Effect,41 Exit,42 FileSystem,43 Layer,44 Option,45 Path,46+ Runtime,47 Schema,48 } from "effect";49 import { CliOutput } from "effect/cli";50 import { RpcTest } from "effect/rpc";93 unmodified lines144 out: (yield* TestConsole.logLines).map(String),145 };146 });147 148+/** The code a run's process ends with: 0 for a success. */149+const exitCodeOf = (exit: Exit.Exit<unknown, unknown>) =>150+ Exit.isSuccess(exit) ? 0 : Runtime.getErrorExitCode(Cause.squash(exit.cause));151+152 const decodeJson = Schema.decodeEffect(Schema.fromJsonString(Schema.Json));153 154 /** The one document `--json` printed on stdout. */155 const envelopeOf = (out: readonly string[]) =>238 unmodified lines394 });395 396 describe(`${Brand.cli} check`, () => {397 it.live(392- "prints the refusals the gateway would give the same head, in one envelope, and exits 1",398+ "prints the refusals the gateway would give the same head, in one envelope, and exits 65: the answer must change",399 () =>400 Effect.gen(function* () {401 const repo = yield* aCheckRepo;402 9 unmodified lines412 ]).pipe(Effect.provide(services(unreachable)));413 414 const expected = yield* gateSays(repo, repo.straying);415 410- expect(Exit.isFailure(printed.exit)).toBeTruthy();416+ expect(exitCodeOf(printed.exit)).toBe(65);417 expect(printed.err.join("\n")).toContain(`made up for ${handle}`);418 expect(yield* envelopeOf(printed.out)).toStrictEqual({419 command: "check",420 ok: false,449 unmodified linesmodified:apps/cli/test/local/env-set-live.test.ts+4 added-4 removed
834 unmodified lines835 })836 );837 838 it.effect(839- "refuses bram, no decider, with NotDecider printed once and exit 1",839+ "refuses bram, no decider, with NotDecider printed once and exit 77",840 () =>841 Effect.gen(function* () {842 const { byBram } = yield* Scenario;843 1 unmodified line845 code: byBram.code,846 err: filled(byBram.err),847 out: filled(byBram.out),848 }).toStrictEqual({849- code: 1,849+ code: 77,850 err: explain([new NotDecider({})]),851 out: [],852 });853 })17 unmodified lines871 out: filled(tooShort.out),872 },873 }).toStrictEqual({874 publicItem: {875- code: 1,875+ code: 65,876 err: explain([new NotSensitive({ key: EnvKey.make("APP_ENV") })]),877 out: [],878 },879 tooShort: {880- code: 1,880+ code: 65,881 err: explain([ValueTooShort.of(token, 12)]),882 out: [],883 },884 });54 unmodified linesmodified:apps/cli/test/local/env-set.test.ts+2 added-2 removed
443 unmodified lines444 it.live.each([445 { refusal: new NotSensitive({ key }) },446 { refusal: ValueTooShort.of(key, 12) },447 ])(448- "prints $refusal._tag from the platform once, and exits 1",448+ "prints $refusal._tag from the platform once, and exits 65",449 ({ refusal }: { readonly refusal: NotSensitive | ValueTooShort }) =>450 Effect.gen(function* () {451 const ran = yield* run([key, ...always, "--yes"], {452 answer: Effect.fail(refusal),453 });454 455- expect(ran.code).toBe(1);455+ expect(ran.code).toBe(65);456 expect(ran.out).toBe("");457 expect(ran.err).toBe(explain([refusal]).join("\n"));458 neverShown(ran);459 }).pipe(Effect.provide(NodeServices.layer))54 unmodified linesmodified:apps/cli/test/local/init.test.ts+2 added-2 removed
550 unmodified lines551 { timeout: 30_000 }552 );553 554 it.live(555- "prints ProjectExists once and exits 1, pushing nothing",555+ "prints ProjectExists once and exits 65, pushing nothing",556 () =>557 Effect.gen(function* () {558 const machine = yield* aMachine;559 7 unmodified lines567 "demo",568 "--yes",569 ]);570 571- expect(ran.code).toBe(1);571+ expect(ran.code).toBe(65);572 expect(573 ran.err.filter((line) =>574 line.includes("a project named demo already exists")575 )236 unmodified linesmodified:apps/cli/test/local/why.test.ts+16 added-14 removed
545 unmodified lines546 });547 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))548 );549 550+ it.live(551+ "prints a refusal from the platform once, and exits 66 for a name that names nothing",550- it.live("prints a refusal from the platform once, and exits 1", () =>551- Effect.gen(function* () {552- const { dir } = yield* aRepo;552+ () =>553+ Effect.gen(function* () {554+ const { dir } = yield* aRepo;555 554- const ran = yield* run(555- dir,556- ["src/week.ts:3", "--project", "datekit"],557- platform(() => Effect.fail(new UnknownProject({ project })))558- );556+ const ran = yield* run(557+ dir,558+ ["src/week.ts:3", "--project", "datekit"],559+ platform(() => Effect.fail(new UnknownProject({ project })))560+ );561 560- expect(ran.code).toBe(1);561- expect(ran.out).toBe("");562- expect(ran.err).toBe(563- explain([new UnknownProject({ project })]).join("\n")564- );565- }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))562+ expect(ran.code).toBe(66);563+ expect(ran.out).toBe("");564+ expect(ran.err).toBe(565+ explain([new UnknownProject({ project })]).join("\n")566+ );567+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))568 );569 });modified:apps/cli/test/build.test.ts+2 added-1 removed
363 unmodified lines364 expect({365 exitCode: checked.exitCode,366 stderr: checked.stderr,367 }).toStrictEqual({368+ // UnknownAsk: the ask named is not one the policy has.368- exitCode: 1,369+ exitCode: 66,370 stderr: "",371 });372 373 const envelope = yield* Schema.decodeEffect(188 unmodified linesmodified:apps/cli/test/policy.test.ts+3 added-3 removed
99 unmodified lines100 })101 );102 103 it.effect(104- "prints a refusal as one refused envelope under --json, and exits 1",104+ "prints a refusal as one refused envelope under --json, and exits with its code",105 () =>106 Effect.gen(function* () {107 const run = yield* runProgram(108 ["claim", "fix-week", "--project", "datekit", "--json"],1 unmodified line110 );111 112 expect(run.out).toHaveLength(1);113 expect(run.err).toStrictEqual([]);114- expect(run.code).toBe(1);114+ expect(run.code).toBe(75);115 expect(yield* decodeEnvelope(run.out[0] ?? "")).toStrictEqual({116 command: "claim",117 ok: false,118 refusals: [new AskFull({ ask: fixWeek })],14 unmodified lines133 const [reason = ""] = explain([new AskFull({ ask: fixWeek })]);134 const printed = run.err.join("\n");135 136 expect(run.out).toStrictEqual([]);137- expect(run.code).toBe(1);137+ expect(run.code).toBe(75);138 expect(printed.split(reason)).toHaveLength(2);139 expect(run.err).toStrictEqual([140 `- ${reason}`,141 ` - Next: \`${Brand.cli} asks\``,19 unmodified linesmodified:apps/cli/test/remote.test.ts+21 added-19 removed
116 unmodified lines117 });118 119 const status = yield* runProgram(["status"], { client, handlers });120 121- expect([asks.code, status.code]).toStrictEqual([0, 1]);121+ expect([asks.code, status.code]).toStrictEqual([0, 77]);122 expect(asks.out.join("\n")).toContain("fix-week");123 expect(status.err.join("\n")).toContain(signIn);124 expect(status.out).toStrictEqual([]);125 expect(yield* platform.seen).toStrictEqual([undefined, undefined]);126 }).pipe(Effect.scoped)127 );128 129+ it.live(130+ "turns a 401 into the same words, not a stack trace, and exits 77",129- it.live("turns a 401 into the same words, not a stack trace", () =>130- Effect.gen(function* () {131- const platform = yield* httpPlatform(handlers);131+ () =>132+ Effect.gen(function* () {133+ const platform = yield* httpPlatform(handlers);134 133- const run = yield* runProgram(["status"], {134- client: remote(135- holding(Option.some(profileOn(platform.origin, "a-stale-token")))136- ),137- handlers,138- });135+ const run = yield* runProgram(["status"], {136+ client: remote(137+ holding(Option.some(profileOn(platform.origin, "a-stale-token")))138+ ),139+ handlers,140+ });141 140- expect(run.code).toBe(1);141- expect(run.err).toStrictEqual([142- "Unauthenticated: the platform does not know who you are",143- ` ${signIn}`,144- " retryable: no",145- ]);146- }).pipe(Effect.scoped)142+ expect(run.code).toBe(77);143+ expect(run.err).toStrictEqual([144+ "Unauthenticated: the platform does not know who you are",145+ ` ${signIn}`,146+ " retryable: no",147+ ]);148+ }).pipe(Effect.scoped)149 );150 151 it.live(150- "says in one line what failed when the platform answers with an error",152+ "says in one line what failed when the platform answers with an error, and exits 69",153 () =>154 Effect.gen(function* () {155 const origin = yield* failingPlatform(503);156 1 unmodified line158 client: remote(holding(Option.none()), { [urlVariable]: origin }),159 handlers,160 });161 160- expect(run.code).toBe(1);162+ expect(run.code).toBe(69);163 expect(run.out).toStrictEqual([]);164 expect(run.err).toHaveLength(1);165 expect(run.err[0]).toMatch(/^could not reach the platform: .*\b503\b/u);166 expect(run.err[0]).toContain(`${origin}/rpc`);16 unmodified linesmodified:apps/cli/test/surfaces.test.ts+5 added-4 removed
318 unmodified lines319 const run = yield* runProgram([...decideArgs, "--yes"], {320 handlers: deciding(calls),321 });322 323+ // DecisionClosed: the decision named no longer stands open.323- expect(run.code).toBe(1);324+ expect(run.code).toBe(66);325 expect(yield* Ref.get(calls)).toBe(1);326 })327 );328 });265 unmodified lines594 })595 );596 597 it.effect(597- "prints a refused receipt as a refusal: once on stderr, nothing on stdout, exit 1",598+ "prints a refused receipt as a refusal: once on stderr, nothing on stdout, exit 75 for a moved main",599 () =>600 Effect.gen(function* () {601 const run = yield* runProgram(submitArgs, {602 handlers: receiving(603 receiptAt(Outcome.cases.Refused.make({ refusals: [refusal] }))604 ),605 });606 606- expect(run.code).toBe(1);607+ expect(run.code).toBe(75);608 expect(run.out).toStrictEqual([]);609 expect(run.err).toStrictEqual(explain([refusal]));610 })611 );5 unmodified lines617 receiptAt(Outcome.cases.Refused.make({ refusals: [refusal] }))618 ),619 });620 620- expect(run.code).toBe(1);621+ expect(run.code).toBe(75);622 expect(run.err).toStrictEqual([]);623 expect(run.out).toHaveLength(1);624 expect(yield* decodeEnvelope(run.out[0] ?? "")).toStrictEqual({625 command: "submit",7 unmodified linesmodified:packages/agent-kit/src/full-llms.ts+8 added-6 removed
1 /**2 * `/llms-full.txt`: what an agent needs beyond the index, in one file.3 * `frontLlms`' text, then every refusal of the closed union (every group,4- * from `refusalCatalog`), how git meets the platform, how a landing4+ * from `refusalCatalog`), the CLI's exit codes, how git meets the platform, how a landing5 * happens (ADR 0014), one line per event a watcher hears, and the guides6 * for the moments an answer goes sideways.7 *8 * Pure, and every name comes from `Brand`. The refusals come from the9 unmodified lines18 import { Option } from "effect";19 20 import type { CommandDoc } from "./command-doc.ts";21 import { frontLlms, typed, withCommand } from "./host-doc.ts";22-import { refusalCatalog } from "./refusals.ts";22+import { exitCodeSection, refusalCatalog } from "./refusals.ts";23 import { code, page, table } from "./text.ts";24 25 type Commands = readonly CommandDoc[];26 13 unmodified lines40 "",41 `Every refusal the platform gives, in every group of its closed union. Each has a \`_tag\`, \`retryable\` (whether trying the same thing again can help) and \`next\` (the command to run next), and no message: match on the tag. Git prints them on its \`remote:\` lines, ${code(cli("check"))} and ${code(cli("status"))} print them, an MCP tool returns them as JSON, and the verdict note holds them. The refusals about an answer's files arrive together, so one push hears about all of them.`,42 "",43 ...table(44- ["`_tag`", "Group", "Retryable", "`next`", "What to do"],45- refusalCatalog().map(({ group, next, retryable, tag, todo }) => [44+ ["`_tag`", "Group", "Retryable", "Exit code", "`next`", "What to do"],45+ refusalCatalog().map(({ exitCode, group, next, retryable, tag, todo }) => [46 code(tag),47 group,48 retryable ? "yes" : "no",49+ String(exitCode),50 next,51 todo,52 ])53 ),132 unmodified lines186 ).join("")}`,187 ];188 189 /**189- * `/llms-full.txt`: the index, then the refusals, git, landings, events190- * and guides. The web serves it; the platform's `/` stays the index alone.190+ * `/llms-full.txt`: the index, then the refusals, exit codes, git,191+ * landings, events and guides. The web serves it; the platform's `/` stays the index alone.192 */193 export const fullLlms = (input: {194 readonly commands: Commands;195 readonly projects: readonly ProjectListing[];1 unmodified line197 readonly webUrl: string;198 }) =>199 `${frontLlms(input)}\n${page([200 ...refusals(),201+ ...exitCodeSection(),202 ...gitHere(input.platformUrl),203 ...landing(),204 ...events(),205 ...guides(input.commands, input.platformUrl),1 unmodified linemodified:packages/agent-kit/src/refusals.ts+46 added-9 removed
1 /**2 * The refusals an answer can meet, read from the closed union: each one's3- * tag, whether retrying can help and its `next` come from its schema, and4- * what to do about it from the table below, which the type holds to the5- * union's groups (a refusal added to one fails the typecheck until it has6- * a line here). `refusalCatalog` walks every group the same way, for7- * `/llms-full.txt`, with a second table for the refusals no answer meets.3+ * tag, whether retrying can help and its `next` come from its schema, its4+ * exit code from the CLI's (`exitCodeOfTag`), and what to do about it from5+ * the table below, which the type holds to the union's groups (a refusal6+ * added to one fails the typecheck until it has a line here).7+ * `refusalCatalog` walks every group the same way, for `/llms-full.txt`,8+ * with a second table for the refusals no answer meets.9 */10 import { Brand } from "@repo/brand";11+import { ExitCode, exitCodeOfTag, precedence } from "@repo/protocol/exit-code";12 import { groups } from "@repo/protocol/refusal";13 import { Exit, Predicate, SchemaAST } from "effect";14 15 import { code, table } from "./text.ts";124 unmodified lines140 NotSensitive: {141 todo: "Only an `@sensitive` item holds a write-only value: `next` shows which items are.",142 },143 PostureChange: {142- todo: "Wait for a decider to take the posture change it names (`from`, `to`); `next` lists the decisions waiting.",144+ todo: "A decider declined the posture change it names (`from`, `to`): take out what changes the posture; `next` lists the decisions.",145 },146 ProjectExists: { todo: "Pick another name: that one is taken." },147 ProposalClosed: {148 todo: "Nothing more is drafted for it: the proposal was accepted, declined or expired.",59 unmodified lines208 /** One refusal an answer can meet, as the skills list it. */209 export interface AnswerRefusal {210 readonly tag: string;211 readonly retryable: boolean;212+ /** The code the CLI exits with when it meets this refusal. */213+ readonly exitCode: ExitCode;214 /** Its `next`, in Markdown: the command as a code span, or what it names. */215 readonly next: string;216 readonly todo: string;217 }17 unmodified lines235 const fixed = constructorDefault(member.fields.next.ast);236 const repair = repairTable.get(member.identifier);237 238 return {239+ exitCode: exitCodeOfTag(member.identifier),240 next: nextOf(fixed, repair),241 retryable: SchemaAST.isLiteral(retryable) && retryable.literal === true,242 tag: member.identifier,243 todo: repair?.todo ?? "",20 unmodified lines264 group: group.name,265 }))266 );267 268+/** What each code the CLI exits with tells its caller, in the order a caller reads them. */269+const exitMeanings = {270+ [ExitCode.ok]: "It did what it was asked.",271+ [ExitCode.failed]: "Something else went wrong; stderr says what.",272+ [ExitCode.usage]:273+ "The command was misused; stderr names the flag or value, and nothing was sent.",274+ [ExitCode.dataErr]:275+ "Refused: what you sent has to change (the answer, the ask or the value).",276+ [ExitCode.noInput]:277+ "Refused: what you named does not exist, or no longer stands open; `next` lists what does.",278+ [ExitCode.unavailable]:279+ "No platform answered: it is down, or the URL is wrong.",280+ [ExitCode.tempFail]:281+ "Refused for now: run the refusal's `next`, then try the same thing again.",282+ [ExitCode.noPerm]:283+ "Refused: you may not do this until you sign in, or someone lets you in.",284+} as const satisfies Record<ExitCode, string>;285+286+/** The CLI's exit codes, as `/llms-full.txt` lists them. */287+export const exitCodeSection = () => [288+ "## Exit codes",289+ "",290+ `${code(Brand.cli)} exits with a code from sysexits(3), so a script or an agent can tell what to do next without reading stderr. A refusal's code follows from its \`retryable\`: 75 when trying again can help, else the code for what has to change, as the Refusals table lists it. A command that meets several refusals at once exits with the first of ${precedence.map(String).join(", ")} among them.`,291+ "",292+ ...table(293+ ["Exit code", "Means"],294+ Object.entries(exitMeanings).map(([exit, means]) => [exit, means])295+ ),296+ "",297+];298+299 /** The refusals section every skill carries. */300 export const refusalSection = () => [301 "## Refusals",302 "",267- `Instead of landing an answer, the platform answers with refusals. Git prints them on its \`remote:\` lines, \`${cli("check")}\` and \`${cli("status")}\` print them, and the verdict note holds them as JSON. Each one has a \`_tag\`, \`retryable\` (whether trying the same thing again can help) and \`next\` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them.`,303+ `Instead of landing an answer, the platform answers with refusals. Git prints them on its \`remote:\` lines, \`${cli("check")}\` and \`${cli("status")}\` print them, and the verdict note holds them as JSON. Each one has a \`_tag\`, \`retryable\` (whether trying the same thing again can help) and \`next\` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them. The CLI exits with a refusal's code: 75 when trying again can help, and 65, 66 or 77 when something has to change first.`,304 "",305 ...table(270- ["`_tag`", "Retryable", "`next`", "What to do"],271- answerRefusals.map(({ next, retryable, tag, todo }) => [306+ ["`_tag`", "Retryable", "Exit code", "`next`", "What to do"],307+ answerRefusals.map(({ exitCode, next, retryable, tag, todo }) => [308 code(tag),309 retryable ? "yes" : "no",310+ String(exitCode),311 next,312 todo,313 ])314 ),2 unmodified linesmodified:packages/agent-kit/test/golden/agent-plugins-stdio.txt+25 added-25 removed
46 unmodified lines47 `__CLI__ mcp` serves the platform's contracts as MCP tools over stdio, with your stored token.48 49 ## Refusals50 51-Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them.51+Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them. The CLI exits with a refusal's code: 75 when trying again can help, and 65, 66 or 77 when something has to change first.52 53-| `_tag` | Retryable | `next` | What to do |54-| --- | --- | --- | --- |55-| `NotClaimed` | yes | `__CLI__ claim <ask>` | Claim the ask, then push again. |56-| `ClaimLapsed` | yes | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |57-| `NotVouched` | no | `__CLI__ status` | Ask a member of the project to vouch for you. |58-| `CapReached` | yes | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |59-| `AskFull` | yes | `__CLI__ asks` | Someone else holds the claim: pick another ask. |60-| `NoAsk` | no | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |61-| `RepoBusy` | yes | `git push` | Push again. |62-| `DirectPush` | no | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |63-| `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |64-| `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |65-| `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |66-| `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |67-| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |68-| `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |69-| `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |70-| `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |71-| `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |72-| `ChecksFailed` | no | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |73-| `HeldBackFailed` | no | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |74-| `AttemptsExhausted` | yes | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |75-| `Flake` | yes | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |76-| `VerifierBlocked` | yes | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |53+| `_tag` | Retryable | Exit code | `next` | What to do |54+| --- | --- | --- | --- | --- |55+| `NotClaimed` | yes | 75 | `__CLI__ claim <ask>` | Claim the ask, then push again. |56+| `ClaimLapsed` | yes | 75 | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |57+| `NotVouched` | no | 77 | `__CLI__ status` | Ask a member of the project to vouch for you. |58+| `CapReached` | yes | 75 | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |59+| `AskFull` | yes | 75 | `__CLI__ asks` | Someone else holds the claim: pick another ask. |60+| `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |61+| `RepoBusy` | yes | 75 | `git push` | Push again. |62+| `DirectPush` | no | 77 | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |63+| `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |64+| `Denounced` | no | 77 | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |65+| `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |66+| `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |67+| `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |68+| `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |69+| `ReachedInternals` | no | 65 | `__CLI__ check` | Import the other module only through its public files. |70+| `StaleBase` | yes | 75 | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |71+| `StaleLayer` | yes | 75 | `__CLI__ status` | Nothing: the answer is checked again. |72+| `ChecksFailed` | no | 65 | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |73+| `HeldBackFailed` | no | 65 | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |74+| `AttemptsExhausted` | yes | 75 | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |75+| `Flake` | yes | 75 | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |76+| `VerifierBlocked` | yes | 75 | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |77 78 ## No fence yet79 80 Norms that nothing checks yet. Keep them; the gate does not refuse an answer that breaks one.17 unmodified linesmodified:packages/agent-kit/test/golden/agent-plugins.txt+25 added-25 removed
47 unmodified lines48 The platform serves its contracts as MCP tools at `https://__SLUG__.technology/mcp`; `__CLI__ mcp` serves the same tools over stdio, with your stored token.49 50 ## Refusals51 52-Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them.52+Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them. The CLI exits with a refusal's code: 75 when trying again can help, and 65, 66 or 77 when something has to change first.53 54-| `_tag` | Retryable | `next` | What to do |55-| --- | --- | --- | --- |56-| `NotClaimed` | yes | `__CLI__ claim <ask>` | Claim the ask, then push again. |57-| `ClaimLapsed` | yes | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |58-| `NotVouched` | no | `__CLI__ status` | Ask a member of the project to vouch for you. |59-| `CapReached` | yes | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |60-| `AskFull` | yes | `__CLI__ asks` | Someone else holds the claim: pick another ask. |61-| `NoAsk` | no | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |62-| `RepoBusy` | yes | `git push` | Push again. |63-| `DirectPush` | no | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |64-| `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |65-| `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |66-| `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |67-| `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |68-| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |69-| `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |70-| `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |71-| `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |72-| `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |73-| `ChecksFailed` | no | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |74-| `HeldBackFailed` | no | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |75-| `AttemptsExhausted` | yes | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |76-| `Flake` | yes | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |77-| `VerifierBlocked` | yes | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |54+| `_tag` | Retryable | Exit code | `next` | What to do |55+| --- | --- | --- | --- | --- |56+| `NotClaimed` | yes | 75 | `__CLI__ claim <ask>` | Claim the ask, then push again. |57+| `ClaimLapsed` | yes | 75 | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |58+| `NotVouched` | no | 77 | `__CLI__ status` | Ask a member of the project to vouch for you. |59+| `CapReached` | yes | 75 | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |60+| `AskFull` | yes | 75 | `__CLI__ asks` | Someone else holds the claim: pick another ask. |61+| `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |62+| `RepoBusy` | yes | 75 | `git push` | Push again. |63+| `DirectPush` | no | 77 | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |64+| `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |65+| `Denounced` | no | 77 | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |66+| `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |67+| `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |68+| `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |69+| `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |70+| `ReachedInternals` | no | 65 | `__CLI__ check` | Import the other module only through its public files. |71+| `StaleBase` | yes | 75 | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |72+| `StaleLayer` | yes | 75 | `__CLI__ status` | Nothing: the answer is checked again. |73+| `ChecksFailed` | no | 65 | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |74+| `HeldBackFailed` | no | 65 | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |75+| `AttemptsExhausted` | yes | 75 | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |76+| `Flake` | yes | 75 | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |77+| `VerifierBlocked` | yes | 75 | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |78 79 ## No fence yet80 81 Norms that nothing checks yet. Keep them; the gate does not refuse an answer that breaks one.14 unmodified linesmodified:packages/agent-kit/test/golden/claude-plugin-stdio.txt+25 added-25 removed
45 unmodified lines46 `__CLI__ mcp` serves the platform's contracts as MCP tools over stdio, with your stored token.47 48 ## Refusals49 50-Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them.50+Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them. The CLI exits with a refusal's code: 75 when trying again can help, and 65, 66 or 77 when something has to change first.51 52-| `_tag` | Retryable | `next` | What to do |53-| --- | --- | --- | --- |54-| `NotClaimed` | yes | `__CLI__ claim <ask>` | Claim the ask, then push again. |55-| `ClaimLapsed` | yes | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |56-| `NotVouched` | no | `__CLI__ status` | Ask a member of the project to vouch for you. |57-| `CapReached` | yes | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |58-| `AskFull` | yes | `__CLI__ asks` | Someone else holds the claim: pick another ask. |59-| `NoAsk` | no | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |60-| `RepoBusy` | yes | `git push` | Push again. |61-| `DirectPush` | no | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |62-| `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |63-| `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |64-| `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |65-| `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |66-| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |67-| `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |68-| `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |69-| `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |70-| `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |71-| `ChecksFailed` | no | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |72-| `HeldBackFailed` | no | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |73-| `AttemptsExhausted` | yes | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |74-| `Flake` | yes | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |75-| `VerifierBlocked` | yes | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |52+| `_tag` | Retryable | Exit code | `next` | What to do |53+| --- | --- | --- | --- | --- |54+| `NotClaimed` | yes | 75 | `__CLI__ claim <ask>` | Claim the ask, then push again. |55+| `ClaimLapsed` | yes | 75 | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |56+| `NotVouched` | no | 77 | `__CLI__ status` | Ask a member of the project to vouch for you. |57+| `CapReached` | yes | 75 | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |58+| `AskFull` | yes | 75 | `__CLI__ asks` | Someone else holds the claim: pick another ask. |59+| `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |60+| `RepoBusy` | yes | 75 | `git push` | Push again. |61+| `DirectPush` | no | 77 | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |62+| `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |63+| `Denounced` | no | 77 | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |64+| `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |65+| `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |66+| `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |67+| `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |68+| `ReachedInternals` | no | 65 | `__CLI__ check` | Import the other module only through its public files. |69+| `StaleBase` | yes | 75 | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |70+| `StaleLayer` | yes | 75 | `__CLI__ status` | Nothing: the answer is checked again. |71+| `ChecksFailed` | no | 65 | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |72+| `HeldBackFailed` | no | 65 | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |73+| `AttemptsExhausted` | yes | 75 | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |74+| `Flake` | yes | 75 | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |75+| `VerifierBlocked` | yes | 75 | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |76 77 ## No fence yet78 79 Norms that nothing checks yet. Keep them; the gate does not refuse an answer that breaks one.52 unmodified linesmodified:packages/agent-kit/test/golden/claude-plugin.txt+25 added-25 removed
46 unmodified lines47 The platform serves its contracts as MCP tools at `https://__SLUG__.technology/mcp`; `__CLI__ mcp` serves the same tools over stdio, with your stored token.48 49 ## Refusals50 51-Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them.51+Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them. The CLI exits with a refusal's code: 75 when trying again can help, and 65, 66 or 77 when something has to change first.52 53-| `_tag` | Retryable | `next` | What to do |54-| --- | --- | --- | --- |55-| `NotClaimed` | yes | `__CLI__ claim <ask>` | Claim the ask, then push again. |56-| `ClaimLapsed` | yes | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |57-| `NotVouched` | no | `__CLI__ status` | Ask a member of the project to vouch for you. |58-| `CapReached` | yes | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |59-| `AskFull` | yes | `__CLI__ asks` | Someone else holds the claim: pick another ask. |60-| `NoAsk` | no | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |61-| `RepoBusy` | yes | `git push` | Push again. |62-| `DirectPush` | no | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |63-| `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |64-| `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |65-| `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |66-| `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |67-| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |68-| `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |69-| `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |70-| `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |71-| `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |72-| `ChecksFailed` | no | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |73-| `HeldBackFailed` | no | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |74-| `AttemptsExhausted` | yes | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |75-| `Flake` | yes | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |76-| `VerifierBlocked` | yes | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |53+| `_tag` | Retryable | Exit code | `next` | What to do |54+| --- | --- | --- | --- | --- |55+| `NotClaimed` | yes | 75 | `__CLI__ claim <ask>` | Claim the ask, then push again. |56+| `ClaimLapsed` | yes | 75 | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |57+| `NotVouched` | no | 77 | `__CLI__ status` | Ask a member of the project to vouch for you. |58+| `CapReached` | yes | 75 | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |59+| `AskFull` | yes | 75 | `__CLI__ asks` | Someone else holds the claim: pick another ask. |60+| `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |61+| `RepoBusy` | yes | 75 | `git push` | Push again. |62+| `DirectPush` | no | 77 | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |63+| `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |64+| `Denounced` | no | 77 | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |65+| `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |66+| `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |67+| `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |68+| `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |69+| `ReachedInternals` | no | 65 | `__CLI__ check` | Import the other module only through its public files. |70+| `StaleBase` | yes | 75 | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |71+| `StaleLayer` | yes | 75 | `__CLI__ status` | Nothing: the answer is checked again. |72+| `ChecksFailed` | no | 65 | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |73+| `HeldBackFailed` | no | 65 | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |74+| `AttemptsExhausted` | yes | 75 | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |75+| `Flake` | yes | 75 | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |76+| `VerifierBlocked` | yes | 75 | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |77 78 ## No fence yet79 80 Norms that nothing checks yet. Keep them; the gate does not refuse an answer that breaks one.50 unmodified linesmodified:packages/agent-kit/test/golden/full-llms.txt+62 added-47 removed
50 unmodified lines51 ## Refusals52 53 Every refusal the platform gives, in every group of its closed union. Each has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next), and no message: match on the tag. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, an MCP tool returns them as JSON, and the verdict note holds them. The refusals about an answer's files arrive together, so one push hears about all of them.54 55-| `_tag` | Group | Retryable | `next` | What to do |56-| --- | --- | --- | --- | --- |57-| `NotClaimed` | Push and claim | yes | `__CLI__ claim <ask>` | Claim the ask, then push again. |58-| `ClaimLapsed` | Push and claim | yes | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |59-| `NotVouched` | Push and claim | no | `__CLI__ status` | Ask a member of the project to vouch for you. |60-| `CapReached` | Push and claim | yes | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |61-| `AskFull` | Push and claim | yes | `__CLI__ asks` | Someone else holds the claim: pick another ask. |62-| `NoAsk` | Push and claim | no | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |63-| `RepoBusy` | Push and claim | yes | `git push` | Push again. |64-| `DirectPush` | Push and claim | no | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |65-| `AskBlocked` | Push and claim | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |66-| `Denounced` | Push and claim | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |67-| `OutOfScope` | Shape | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |68-| `TouchedJudge` | Shape | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |69-| `Weakened` | Shape | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |70-| `PrivatePathInPublicTree` | Shape | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |71-| `ReachedInternals` | Shape | no | `__CLI__ check` | Import the other module only through its public files. |72-| `StaleBase` | Merge | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |73-| `StaleLayer` | Merge | yes | `__CLI__ status` | Nothing: the answer is checked again. |74-| `ChecksFailed` | Checks | no | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |75-| `HeldBackFailed` | Checks | no | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |76-| `AttemptsExhausted` | Checks | yes | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |77-| `Flake` | Never counted against the answerer | yes | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |78-| `VerifierBlocked` | Never counted against the answerer | yes | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |79-| `NotRedFirst` | At ask open | no | `__CLI__ check` | Make the ask's check fail on main by an assertion, the same way twice, then open the ask again. |80-| `WeakCheck` | At ask open | no | `__CLI__ check` | Strengthen the check: as it stands, the trivial answer `weakness` names would pass it. |81-| `IncompleteBrief` | At ask open | no | `__CLI__ check` | Fill in the fields `missing` names: the ask's kind requires them. |82-| `LayerContentInPublicTree` | Maintainers only | no | `__CLI__ check` | Take the paths it names out: their files stay private and never enter a public tree. |83-| `SecretInOutput` | Maintainers only | no | `__CLI__ check` | Take the write-only value of `item` out of the output or the tree (`where`), then check again. |84-| `UnstatedRequirement` | Maintainers only | no | `__CLI__ check` | State in public what the area's held-back check holds, or take the check out of the suite. |85-| `PostureChange` | Decision | no | `__CLI__ today` | Wait for a decider to take the posture change it names (`from`, `to`); `next` lists the decisions waiting. |86-| `NotDecider` | Decision | no | `__CLI__ status` | Only one of the project's deciders may do this: ask one of them. |87-| `DecisionClosed` | Decision | no | `__CLI__ today` | Nothing to decide: it was taken already, or expired to its default. |88-| `ProposalClosed` | Decision | no | `__CLI__ today` | Nothing more is drafted for it: the proposal was accepted, declined or expired. |89-| `DraftInProgress` | Decision | yes | `__CLI__ proposal <proposal>` | Wait: the platform is drafting this proposal's ask already, and `next` shows when it settles. |90-| `UnknownProject` | Lookup | no | `__CLI__ asks` | Check the project's name: every project is listed in the index. |91-| `UnknownAsk` | Lookup | no | `__CLI__ asks` | Check the ask's name: `next` lists the project's open asks. |92-| `UnknownCommit` | Lookup | no | `git fetch` | Fetch the project, then name a commit it holds. |93-| `UnknownDecision` | Lookup | no | `__CLI__ today` | Check the decision's id: `next` lists the decisions waiting on you. |94-| `UnknownPath` | Lookup | no | `git ls-tree` | Name a path the commit holds: `next` lists its files. |95-| `UnknownRevision` | Lookup | no | `git ls-remote` | Name `main`, a commit the project holds or one of its tags: `next` lists its refs. |96-| `UnknownProposal` | Lookup | no | `__CLI__ today` | Check the proposal's id: `next` lists the proposals waiting on you. |97-| `ProjectExists` | Setup | no | `__CLI__ asks` | Pick another name: that one is taken. |98-| `ImportFailed` | Setup | yes | `__CLI__ init` | Read `reason`, then import again. |99-| `UnknownEnvItem` | Env | no | `__CLI__ env shape` | Name a key the project's env shape has: `next` lists them. |100-| `NotSensitive` | Env | no | `__CLI__ env shape` | Only an `@sensitive` item holds a write-only value: `next` shows which items are. |101-| `ValueTooShort` | Env | no | `__CLI__ env set <key>`, with `--acknowledge-short` when the value is above the floor | Give a longer value, or acknowledge a short one where the floor allows it. |55+| `_tag` | Group | Retryable | Exit code | `next` | What to do |56+| --- | --- | --- | --- | --- | --- |57+| `NotClaimed` | Push and claim | yes | 75 | `__CLI__ claim <ask>` | Claim the ask, then push again. |58+| `ClaimLapsed` | Push and claim | yes | 75 | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |59+| `NotVouched` | Push and claim | no | 77 | `__CLI__ status` | Ask a member of the project to vouch for you. |60+| `CapReached` | Push and claim | yes | 75 | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |61+| `AskFull` | Push and claim | yes | 75 | `__CLI__ asks` | Someone else holds the claim: pick another ask. |62+| `NoAsk` | Push and claim | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |63+| `RepoBusy` | Push and claim | yes | 75 | `git push` | Push again. |64+| `DirectPush` | Push and claim | no | 77 | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |65+| `AskBlocked` | Push and claim | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |66+| `Denounced` | Push and claim | no | 77 | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |67+| `OutOfScope` | Shape | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |68+| `TouchedJudge` | Shape | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |69+| `Weakened` | Shape | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |70+| `PrivatePathInPublicTree` | Shape | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |71+| `ReachedInternals` | Shape | no | 65 | `__CLI__ check` | Import the other module only through its public files. |72+| `StaleBase` | Merge | yes | 75 | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |73+| `StaleLayer` | Merge | yes | 75 | `__CLI__ status` | Nothing: the answer is checked again. |74+| `ChecksFailed` | Checks | no | 65 | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |75+| `HeldBackFailed` | Checks | no | 65 | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |76+| `AttemptsExhausted` | Checks | yes | 75 | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |77+| `Flake` | Never counted against the answerer | yes | 75 | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |78+| `VerifierBlocked` | Never counted against the answerer | yes | 75 | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |79+| `NotRedFirst` | At ask open | no | 65 | `__CLI__ check` | Make the ask's check fail on main by an assertion, the same way twice, then open the ask again. |80+| `WeakCheck` | At ask open | no | 65 | `__CLI__ check` | Strengthen the check: as it stands, the trivial answer `weakness` names would pass it. |81+| `IncompleteBrief` | At ask open | no | 65 | `__CLI__ check` | Fill in the fields `missing` names: the ask's kind requires them. |82+| `LayerContentInPublicTree` | Maintainers only | no | 65 | `__CLI__ check` | Take the paths it names out: their files stay private and never enter a public tree. |83+| `SecretInOutput` | Maintainers only | no | 65 | `__CLI__ check` | Take the write-only value of `item` out of the output or the tree (`where`), then check again. |84+| `UnstatedRequirement` | Maintainers only | no | 65 | `__CLI__ check` | State in public what the area's held-back check holds, or take the check out of the suite. |85+| `PostureChange` | Decision | no | 65 | `__CLI__ today` | A decider declined the posture change it names (`from`, `to`): take out what changes the posture; `next` lists the decisions. |86+| `NotDecider` | Decision | no | 77 | `__CLI__ status` | Only one of the project's deciders may do this: ask one of them. |87+| `DecisionClosed` | Decision | no | 66 | `__CLI__ today` | Nothing to decide: it was taken already, or expired to its default. |88+| `ProposalClosed` | Decision | no | 66 | `__CLI__ today` | Nothing more is drafted for it: the proposal was accepted, declined or expired. |89+| `DraftInProgress` | Decision | yes | 75 | `__CLI__ proposal <proposal>` | Wait: the platform is drafting this proposal's ask already, and `next` shows when it settles. |90+| `UnknownProject` | Lookup | no | 66 | `__CLI__ asks` | Check the project's name: every project is listed in the index. |91+| `UnknownAsk` | Lookup | no | 66 | `__CLI__ asks` | Check the ask's name: `next` lists the project's open asks. |92+| `UnknownCommit` | Lookup | no | 66 | `git fetch` | Fetch the project, then name a commit it holds. |93+| `UnknownDecision` | Lookup | no | 66 | `__CLI__ today` | Check the decision's id: `next` lists the decisions waiting on you. |94+| `UnknownPath` | Lookup | no | 66 | `git ls-tree` | Name a path the commit holds: `next` lists its files. |95+| `UnknownRevision` | Lookup | no | 66 | `git ls-remote` | Name `main`, a commit the project holds or one of its tags: `next` lists its refs. |96+| `UnknownProposal` | Lookup | no | 66 | `__CLI__ today` | Check the proposal's id: `next` lists the proposals waiting on you. |97+| `ProjectExists` | Setup | no | 65 | `__CLI__ asks` | Pick another name: that one is taken. |98+| `ImportFailed` | Setup | yes | 75 | `__CLI__ init` | Read `reason`, then import again. |99+| `UnknownEnvItem` | Env | no | 66 | `__CLI__ env shape` | Name a key the project's env shape has: `next` lists them. |100+| `NotSensitive` | Env | no | 65 | `__CLI__ env shape` | Only an `@sensitive` item holds a write-only value: `next` shows which items are. |101+| `ValueTooShort` | Env | no | 65 | `__CLI__ env set <key>`, with `--acknowledge-short` when the value is above the floor | Give a longer value, or acknowledge a short one where the floor allows it. |102 103+## Exit codes104+105+`__SLUG__` exits with a code from sysexits(3), so a script or an agent can tell what to do next without reading stderr. A refusal's code follows from its `retryable`: 75 when trying again can help, else the code for what has to change, as the Refusals table lists it. A command that meets several refusals at once exits with the first of 77, 66, 65, 75 among them.106+107+| Exit code | Means |108+| --- | --- |109+| 0 | It did what it was asked. |110+| 1 | Something else went wrong; stderr says what. |111+| 2 | The command was misused; stderr names the flag or value, and nothing was sent. |112+| 65 | Refused: what you sent has to change (the answer, the ask or the value). |113+| 66 | Refused: what you named does not exist, or no longer stands open; `next` lists what does. |114+| 69 | No platform answered: it is down, or the URL is wrong. |115+| 75 | Refused for now: run the refusal's `next`, then try the same thing again. |116+| 77 | Refused: you may not do this until you sign in, or someone lets you in. |117+118 ## Git here119 120 Git reaches each repo at `https://platform-test.example.workers.dev/<repo>.git` over smart HTTP and signs in with Basic auth. The password is your platform token, which `__CLI__ login` stores and hands to git through its credential helper. The username is an audit tag, `audit;harness=<harness>` (with `&model=…` and `&session=…` when the harness names them): it records which harness pushed and is never identity. The token alone says who you are.121 69 unmodified linesmodified:packages/agent-kit/test/golden/platform-skill.txt+25 added-25 removed
39 unmodified lines40 The platform serves its contracts as MCP tools at `https://__SLUG__.technology/mcp`; `__CLI__ mcp` serves the same tools over stdio, with your stored token.41 42 ## Refusals43 44-Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them.44+Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them. The CLI exits with a refusal's code: 75 when trying again can help, and 65, 66 or 77 when something has to change first.45 46-| `_tag` | Retryable | `next` | What to do |47-| --- | --- | --- | --- |48-| `NotClaimed` | yes | `__CLI__ claim <ask>` | Claim the ask, then push again. |49-| `ClaimLapsed` | yes | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |50-| `NotVouched` | no | `__CLI__ status` | Ask a member of the project to vouch for you. |51-| `CapReached` | yes | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |52-| `AskFull` | yes | `__CLI__ asks` | Someone else holds the claim: pick another ask. |53-| `NoAsk` | no | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |54-| `RepoBusy` | yes | `git push` | Push again. |55-| `DirectPush` | no | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |56-| `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |57-| `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |58-| `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |59-| `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |60-| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |61-| `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |62-| `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |63-| `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |64-| `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |65-| `ChecksFailed` | no | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |66-| `HeldBackFailed` | no | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |67-| `AttemptsExhausted` | yes | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |68-| `Flake` | yes | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |69-| `VerifierBlocked` | yes | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |46+| `_tag` | Retryable | Exit code | `next` | What to do |47+| --- | --- | --- | --- | --- |48+| `NotClaimed` | yes | 75 | `__CLI__ claim <ask>` | Claim the ask, then push again. |49+| `ClaimLapsed` | yes | 75 | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |50+| `NotVouched` | no | 77 | `__CLI__ status` | Ask a member of the project to vouch for you. |51+| `CapReached` | yes | 75 | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |52+| `AskFull` | yes | 75 | `__CLI__ asks` | Someone else holds the claim: pick another ask. |53+| `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |54+| `RepoBusy` | yes | 75 | `git push` | Push again. |55+| `DirectPush` | no | 77 | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |56+| `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |57+| `Denounced` | no | 77 | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |58+| `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |59+| `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |60+| `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |61+| `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |62+| `ReachedInternals` | no | 65 | `__CLI__ check` | Import the other module only through its public files. |63+| `StaleBase` | yes | 75 | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |64+| `StaleLayer` | yes | 75 | `__CLI__ status` | Nothing: the answer is checked again. |65+| `ChecksFailed` | no | 65 | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |66+| `HeldBackFailed` | no | 65 | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |67+| `AttemptsExhausted` | yes | 75 | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |68+| `Flake` | yes | 75 | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |69+| `VerifierBlocked` | yes | 75 | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |70 71 ## No fence yet72 73 Norms that nothing checks yet. Keep them; the gate does not refuse an answer that breaks one.3 unmodified linesmodified:packages/agent-kit/test/golden/project-skill.txt+50 added-50 removed
73 unmodified lines74 - The brief states: want and check.75 76 ## Refusals77 78-Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them.78+Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them. The CLI exits with a refusal's code: 75 when trying again can help, and 65, 66 or 77 when something has to change first.79 80-| `_tag` | Retryable | `next` | What to do |81-| --- | --- | --- | --- |82-| `NotClaimed` | yes | `__CLI__ claim <ask>` | Claim the ask, then push again. |83-| `ClaimLapsed` | yes | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |84-| `NotVouched` | no | `__CLI__ status` | Ask a member of the project to vouch for you. |85-| `CapReached` | yes | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |86-| `AskFull` | yes | `__CLI__ asks` | Someone else holds the claim: pick another ask. |87-| `NoAsk` | no | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |88-| `RepoBusy` | yes | `git push` | Push again. |89-| `DirectPush` | no | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |90-| `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |91-| `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |92-| `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |93-| `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |94-| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |95-| `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |96-| `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |97-| `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |98-| `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |99-| `ChecksFailed` | no | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |100-| `HeldBackFailed` | no | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |101-| `AttemptsExhausted` | yes | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |102-| `Flake` | yes | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |103-| `VerifierBlocked` | yes | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |80+| `_tag` | Retryable | Exit code | `next` | What to do |81+| --- | --- | --- | --- | --- |82+| `NotClaimed` | yes | 75 | `__CLI__ claim <ask>` | Claim the ask, then push again. |83+| `ClaimLapsed` | yes | 75 | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |84+| `NotVouched` | no | 77 | `__CLI__ status` | Ask a member of the project to vouch for you. |85+| `CapReached` | yes | 75 | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |86+| `AskFull` | yes | 75 | `__CLI__ asks` | Someone else holds the claim: pick another ask. |87+| `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |88+| `RepoBusy` | yes | 75 | `git push` | Push again. |89+| `DirectPush` | no | 77 | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |90+| `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |91+| `Denounced` | no | 77 | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |92+| `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |93+| `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |94+| `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |95+| `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |96+| `ReachedInternals` | no | 65 | `__CLI__ check` | Import the other module only through its public files. |97+| `StaleBase` | yes | 75 | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |98+| `StaleLayer` | yes | 75 | `__CLI__ status` | Nothing: the answer is checked again. |99+| `ChecksFailed` | no | 65 | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |100+| `HeldBackFailed` | no | 65 | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |101+| `AttemptsExhausted` | yes | 75 | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |102+| `Flake` | yes | 75 | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |103+| `VerifierBlocked` | yes | 75 | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |104 105 ## No fence yet106 107 Norms that nothing checks yet. Keep them; the gate does not refuse an answer that breaks one.77 unmodified lines185 - The brief states: want and check.186 187 ## Refusals188 189-Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them.189+Instead of landing an answer, the platform answers with refusals. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, and the verdict note holds them as JSON. Each one has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next). The refusals about an answer's files arrive together, so one push hears about all of them. The CLI exits with a refusal's code: 75 when trying again can help, and 65, 66 or 77 when something has to change first.190 191-| `_tag` | Retryable | `next` | What to do |192-| --- | --- | --- | --- |193-| `NotClaimed` | yes | `__CLI__ claim <ask>` | Claim the ask, then push again. |194-| `ClaimLapsed` | yes | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |195-| `NotVouched` | no | `__CLI__ status` | Ask a member of the project to vouch for you. |196-| `CapReached` | yes | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |197-| `AskFull` | yes | `__CLI__ asks` | Someone else holds the claim: pick another ask. |198-| `NoAsk` | no | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |199-| `RepoBusy` | yes | `git push` | Push again. |200-| `DirectPush` | no | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |201-| `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |202-| `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |203-| `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |204-| `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |205-| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |206-| `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |207-| `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |208-| `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |209-| `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |210-| `ChecksFailed` | no | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |211-| `HeldBackFailed` | no | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |212-| `AttemptsExhausted` | yes | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |213-| `Flake` | yes | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |214-| `VerifierBlocked` | yes | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |191+| `_tag` | Retryable | Exit code | `next` | What to do |192+| --- | --- | --- | --- | --- |193+| `NotClaimed` | yes | 75 | `__CLI__ claim <ask>` | Claim the ask, then push again. |194+| `ClaimLapsed` | yes | 75 | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |195+| `NotVouched` | no | 77 | `__CLI__ status` | Ask a member of the project to vouch for you. |196+| `CapReached` | yes | 75 | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |197+| `AskFull` | yes | 75 | `__CLI__ asks` | Someone else holds the claim: pick another ask. |198+| `NoAsk` | no | 66 | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |199+| `RepoBusy` | yes | 75 | `git push` | Push again. |200+| `DirectPush` | no | 77 | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |201+| `AskBlocked` | yes | 75 | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |202+| `Denounced` | no | 77 | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |203+| `OutOfScope` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |204+| `TouchedJudge` | no | 65 | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |205+| `Weakened` | no | 65 | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |206+| `PrivatePathInPublicTree` | no | 65 | `__CLI__ check` | Take the held-back paths it names out of your answer. |207+| `ReachedInternals` | no | 65 | `__CLI__ check` | Import the other module only through its public files. |208+| `StaleBase` | yes | 75 | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |209+| `StaleLayer` | yes | 75 | `__CLI__ status` | Nothing: the answer is checked again. |210+| `ChecksFailed` | no | 65 | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |211+| `HeldBackFailed` | no | 65 | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |212+| `AttemptsExhausted` | yes | 75 | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |213+| `Flake` | yes | 75 | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |214+| `VerifierBlocked` | yes | 75 | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |215 216 ## No fence yet217 218 Norms that nothing checks yet. Keep them; the gate does not refuse an answer that breaks one.3 unmodified linesmodified:packages/agent-kit/test/full-llms.test.ts+15 added-2 removed
8 unmodified lines9 import { describe, expect, it } from "@effect/vitest";10 import { Brand } from "@repo/brand";11 import type { ProjectEvent } from "@repo/protocol/domain/event";12 import type { ProjectListing } from "@repo/protocol/domain/front-page";13+import { ExitCode } from "@repo/protocol/exit-code";14 import { ProjectName } from "@repo/protocol/ids";15 import { groups } from "@repo/protocol/refusal";16 import { Effect } from "effect";17 140 unmodified lines158 159 expect(refusals).toContainEqual(160 expect.stringMatching(161 new RegExp(161- `^\\| \`UnknownAsk\` \\| Lookup \\| no \\| \`${Brand.cli} asks\` \\| .+ \\|$`,162+ `^\\| \`UnknownAsk\` \\| Lookup \\| no \\| 66 \\| \`${Brand.cli} asks\` \\| .+ \\|$`,163 "u"164 )165 )166 );167 expect(refusals).toContainEqual(168 expect.stringMatching(169 new RegExp(169- `^\\| \`DraftInProgress\` \\| Decision \\| yes \\| \`${Brand.cli} proposal <proposal>\` \\| .+ \\|$`,170+ `^\\| \`DraftInProgress\` \\| Decision \\| yes \\| 75 \\| \`${Brand.cli} proposal <proposal>\` \\| .+ \\|$`,171 "u"172 )173 )174 );175 });176 177+ it("lists every code the CLI exits with, once", () => {178+ const listed = section("Exit codes").flatMap((line) => {179+ const exit = /^\| (?<code>\d+) \|/u.exec(line)?.groups?.code;180+181+ return exit === undefined ? [] : [Number(exit)];182+ });183+184+ expect(listed.toSorted((a, b) => a - b)).toStrictEqual(185+ Object.values(ExitCode).toSorted((a, b) => a - b)186+ );187+ });188+189 it("has a line for every event a watcher hears", () => {190 const events = section("Events");191 192 expect(54 unmodified linesmodified:packages/protocol/src/cli.ts+32 added-12 removed
44 unmodified lines45 NeedsApproval,46 ReadOnly,47 Surfaces,48 } from "./annotations.ts";49+import { ExitCode, exitCodeFor } from "./exit-code.ts";50 import type { Unauthenticated } from "./principal.ts";51 import { Refusal } from "./refusal.ts";52 53 /** How a call can fail before its handler runs: in transit, or unauthenticated. */111 unmodified lines165 }166 }167 168 /**168- * Everything a command printed has been printed: the program exits 1 and169- * prints nothing more, and the runtime reports nothing of its own.169+ * Everything a command printed has been printed: the program exits with170+ * `exitCode` (1 unless refusals set it) and prints nothing more, and the171+ * runtime reports nothing of its own.172 */171-export class Reported extends Schema.TaggedError<Reported>()("Reported", {}) {172- override readonly [Runtime.errorExitCode] = 1;173+export class Reported extends Schema.TaggedError<Reported>()("Reported", {174+ exitCode: Schema.optionalKey(Schema.Int),175+}) {176+ override readonly [Runtime.errorExitCode] = this.exitCode ?? ExitCode.failed;177 override readonly [Runtime.errorReported] = false;178+179+ /** Refusals printed: the program exits with the code they share (`exitCodeFor`). */180+ static readonly of = (refusals: Array.NonEmptyReadonlyArray<Refusal>) =>181+ new Reported({ exitCode: exitCodeFor(refusals) });182 }183 184+/**185+ * Hands `refusals` to `output` once, then ends the command as `Reported`186+ * with their exit code: how every command meets a refusal.187+ */188+export const endRefused = (189+ output: Pick<CommandOutput, "refused">,190+ input: Parameters<CommandOutput["refused"]>[0]191+): Effect.Effect<never, Reported> =>192+ Effect.andThen(193+ output.refused(input),194+ Effect.fail(Reported.of(input.refusals))195+ );196+197 interface FieldSpec {198 readonly description: string | undefined;199 readonly kind:200 | "string"287 unmodified lines488 * `--json`; one that needs approval takes `--yes` and runs only with it;489 * one that changes something takes `--dry-run`, which prints the encoded490 * payload and calls nothing. A refusal, or the refusals a success carries491 * (`refusalsIn`), go to `output.refused` once, and the command fails with471- * `Reported`.492+ * `Reported` and their exit code (`endRefused`).493 */494 export const toCommand = <495 R extends CommandRpc,496 ClientR,126 unmodified lines623 (() => Effect.die(`The client has no method for ${rpc._tag}`));624 625 const success = yield* call(decoded).pipe(626 Effect.catchIf(isRefusal, (refusal) =>606- Effect.andThen(607- output.refused({ command, json, refusals: [refusal] }),608- Effect.fail(new Reported())609- )627+ endRefused(output, { command, json, refusals: [refusal] })628 )629 );630 631 const carried = options.refusalsIn?.(success) ?? [];632 633 if (Array.isReadonlyArrayNonEmpty(carried)) {616- yield* output.refused({ command, json, refusals: carried });617-618- return yield* new Reported();634+ return yield* endRefused(output, {635+ command,636+ json,637+ refusals: carried,638+ });639 }640 641 const data = yield* Effect.orDie(encodeSuccess(success));642 63 unmodified linesadded:packages/protocol/src/exit-code.ts+120 added
1+/**2+ * How the CLI's process ends, from sysexits(3), so a script or an agent can3+ * tell what to do next from the exit code alone. A refusal's code follows4+ * from its fixed `retryable`: a retryable one is `tempFail`, since running5+ * its `next` and trying again can pass; a final one says what has to6+ * change, which `final` fixes per tag: what was sent, what was named, or7+ * who is asking.8+ *9+ * The CLI's projection of the union, kept apart from `cli.ts` so the10+ * reference docs read it without effect/cli. A tag's code is public: change11+ * one only as a tag is renamed, with notice.12+ */13+import type { Array } from "effect";14+15+import type { Refusal } from "./refusal.ts";16+17+export const ExitCode = {18+ /** `EX_DATAERR`: what was sent was refused; change it, then try again. */19+ dataErr: 65,20+ /** Anything else that went wrong, said once on stderr. */21+ failed: 1,22+ /** `EX_NOINPUT`: what was named does not exist, or no longer stands open. */23+ noInput: 66,24+ /** `EX_NOPERM`: the caller may not do this: not signed in, or not let in. */25+ noPerm: 77,26+ /** It did what it was asked. */27+ ok: 0,28+ /** `EX_TEMPFAIL`: run the refusal's `next`, and the same thing can pass. */29+ tempFail: 75,30+ /** `EX_UNAVAILABLE`: no platform answered. */31+ unavailable: 69,32+ /** The command was misused (a parse error, a missing value, `--yes` left out). */33+ usage: 2,34+} as const;35+36+export type ExitCode = (typeof ExitCode)[keyof typeof ExitCode];37+38+type FinalTag = Extract<Refusal, { readonly retryable: false }>["_tag"];39+40+type FinalCode =41+ | typeof ExitCode.dataErr42+ | typeof ExitCode.noInput43+ | typeof ExitCode.noPerm;44+45+// Each final refusal's code. A new final tag fails the typecheck until it46+// has one here; a retryable tag can't be given any but `tempFail`.47+const final = {48+ ChecksFailed: ExitCode.dataErr,49+ DecisionClosed: ExitCode.noInput,50+ Denounced: ExitCode.noPerm,51+ DirectPush: ExitCode.noPerm,52+ HeldBackFailed: ExitCode.dataErr,53+ IncompleteBrief: ExitCode.dataErr,54+ LayerContentInPublicTree: ExitCode.dataErr,55+ NoAsk: ExitCode.noInput,56+ NotDecider: ExitCode.noPerm,57+ NotRedFirst: ExitCode.dataErr,58+ NotSensitive: ExitCode.dataErr,59+ NotVouched: ExitCode.noPerm,60+ OutOfScope: ExitCode.dataErr,61+ // A declined decision, as a declined waiver is `Weakened`: the answer changes.62+ PostureChange: ExitCode.dataErr,63+ PrivatePathInPublicTree: ExitCode.dataErr,64+ ProjectExists: ExitCode.dataErr,65+ ProposalClosed: ExitCode.noInput,66+ ReachedInternals: ExitCode.dataErr,67+ SecretInOutput: ExitCode.dataErr,68+ TouchedJudge: ExitCode.dataErr,69+ UnknownAsk: ExitCode.noInput,70+ UnknownCommit: ExitCode.noInput,71+ UnknownDecision: ExitCode.noInput,72+ UnknownEnvItem: ExitCode.noInput,73+ UnknownPath: ExitCode.noInput,74+ UnknownProject: ExitCode.noInput,75+ UnknownProposal: ExitCode.noInput,76+ UnknownRevision: ExitCode.noInput,77+ UnstatedRequirement: ExitCode.dataErr,78+ ValueTooShort: ExitCode.dataErr,79+ WeakCheck: ExitCode.dataErr,80+ Weakened: ExitCode.dataErr,81+} as const satisfies Record<FinalTag, FinalCode>;82+83+/** The code one refusal ends the CLI with. */84+export const exitCodeOf = (refusal: Refusal): ExitCode =>85+ refusal.retryable ? ExitCode.tempFail : final[refusal._tag];86+87+const finalCodes: ReadonlyMap<string, FinalCode> = new Map(88+ Object.entries(final)89+);90+91+/**92+ * The code a refusal with `tag`, one of the union's, ends the CLI with: for93+ * the reference docs, which read the union's schemas rather than refusals.94+ */95+export const exitCodeOfTag = (tag: string): ExitCode =>96+ finalCodes.get(tag) ?? ExitCode.tempFail;97+98+/**99+ * The order a caller deals with refusals met together: who is asking, then100+ * what was named, then what was sent; a retry helps only once none is left.101+ */102+export const precedence: readonly ExitCode[] = [103+ ExitCode.noPerm,104+ ExitCode.noInput,105+ ExitCode.dataErr,106+ ExitCode.tempFail,107+];108+109+/**110+ * The code refusals met together end the CLI with: the first of111+ * `precedence` any of them has, so `tempFail` only when every one is112+ * retryable.113+ */114+export const exitCodeFor = (115+ refusals: Array.NonEmptyReadonlyArray<Refusal>116+): ExitCode => {117+ const codes = new Set(refusals.map(exitCodeOf));118+119+ return precedence.find((code) => codes.has(code)) ?? exitCodeOf(refusals[0]);120+};modified:packages/protocol/test/cli.test.ts+7 added-3 removed
231 unmodified lines232 toCommand(SubmitAnswer, Effect.service(Client), { output }),233 [...answer, "--json"]234 );235 236- expect(result).toStrictEqual(Result.fail(new Reported()));236+ expect(result).toStrictEqual(Result.fail(Reported.of([refusal])));237 expect(printed).toStrictEqual([238 {239 input: { command: "submit", json: true, refusals: [refusal] },240 kind: "refused",33 unmodified lines274 }),275 answer276 );277 278- expect(result).toStrictEqual(Result.fail(new Reported()));278+ expect(result).toStrictEqual(Result.fail(Reported.of([refusal])));279 expect(printed).toStrictEqual([280 {281 input: { command: "submit", json: false, refusals: [refusal] },282 kind: "refused",41 unmodified lines324 (output) => toCommand(Claim, Effect.service(Client), { output }),325 ["fix-week", "--project", project]326 );327 328- expect(result).toStrictEqual(Result.fail(new Reported()));328+ expect(result).toStrictEqual(329+ Result.fail(330+ Reported.of([new AskFull({ ask: AskId.make("fix-week") })])331+ )332+ );333 expect(yield* Ref.get(claimed)).toStrictEqual([334 { ask: AskId.make("fix-week"), project },335 ]);336 })300 unmodified linesadded:packages/protocol/test/exit-code.test.ts+102 added
1+import { describe, expect, it } from "@effect/vitest";2+3+import {4+ ExitCode,5+ exitCodeFor,6+ exitCodeOf,7+ exitCodeOfTag,8+} from "../src/exit-code.ts";9+import {10+ AskFull,11+ NotVouched,12+ OutOfScope,13+ StaleBase,14+ UnknownAsk,15+} from "../src/refusal.ts";16+import type { Refusal } from "../src/refusal.ts";17+import { ask, base, examples, main, path } from "./examples.ts";18+19+// Each tag's code, as scripts and agents branch on it: a public contract,20+// pinned here so a change to one is a change to this table.21+const pinned = {22+ AskBlocked: 75,23+ AskFull: 75,24+ AttemptsExhausted: 75,25+ CapReached: 75,26+ ChecksFailed: 65,27+ ClaimLapsed: 75,28+ DecisionClosed: 66,29+ Denounced: 77,30+ DirectPush: 77,31+ DraftInProgress: 75,32+ Flake: 75,33+ HeldBackFailed: 65,34+ ImportFailed: 75,35+ IncompleteBrief: 65,36+ LayerContentInPublicTree: 65,37+ NoAsk: 66,38+ NotClaimed: 75,39+ NotDecider: 77,40+ NotRedFirst: 65,41+ NotSensitive: 65,42+ NotVouched: 77,43+ OutOfScope: 65,44+ PostureChange: 65,45+ PrivatePathInPublicTree: 65,46+ ProjectExists: 65,47+ ProposalClosed: 66,48+ ReachedInternals: 65,49+ RepoBusy: 75,50+ SecretInOutput: 65,51+ StaleBase: 75,52+ StaleLayer: 75,53+ TouchedJudge: 65,54+ UnknownAsk: 66,55+ UnknownCommit: 66,56+ UnknownDecision: 66,57+ UnknownEnvItem: 66,58+ UnknownPath: 66,59+ UnknownProject: 66,60+ UnknownProposal: 66,61+ UnknownRevision: 66,62+ UnstatedRequirement: 65,63+ ValueTooShort: 65,64+ VerifierBlocked: 75,65+ WeakCheck: 65,66+ Weakened: 65,67+} as const satisfies Record<Refusal["_tag"], number>;68+69+describe("a refusal's exit code", () => {70+ it.each(examples)("$_tag ends the CLI with its pinned code", (refusal) => {71+ expect(exitCodeOf(refusal)).toBe(pinned[refusal._tag]);72+ });73+74+ it.each(examples)("$_tag has the same code by its tag alone", (refusal) => {75+ expect(exitCodeOfTag(refusal._tag)).toBe(exitCodeOf(refusal));76+ });77+78+ it.each(examples)("$_tag is 75 exactly when it is retryable", (refusal) => {79+ expect(exitCodeOf(refusal) === ExitCode.tempFail).toBe(refusal.retryable);80+ });81+});82+83+describe("refusals met together", () => {84+ const stale = new StaleBase({ base, conflicts: [path], main });85+ const outOfScope = new OutOfScope({ paths: [path] });86+87+ it("end with 75 only when every one is retryable", () => {88+ expect([89+ exitCodeFor([stale, new AskFull({ ask })]),90+ exitCodeFor([stale, outOfScope]),91+ ]).toStrictEqual([ExitCode.tempFail, ExitCode.dataErr]);92+ });93+94+ it("end with who is asking first, then what was named, then what was sent", () => {95+ const unknown = new UnknownAsk({ ask });96+97+ expect([98+ exitCodeFor([outOfScope, unknown, new NotVouched({})]),99+ exitCodeFor([outOfScope, unknown]),100+ ]).toStrictEqual([ExitCode.noPerm, ExitCode.noInput]);101+ });102+});modified:AGENTS.md+1 added-1 removed
12 unmodified lines13 | # | Principle | Held by |14 | --- | --- | --- |15 | 1 | **Encode lessons in structure; prose is the last rung.** When a mistake repeats, make it unrepresentable, then a lint or a test. | No fence |16 | 2 | **Parse at the boundary, trust inside.** Decode every external input (HTTP, git, DO RPC, WebSocket, rule facts, env) with Effect Schema; inside, use branded types (`AskId`, `LandedSha`, `PatchId`). Decode the Worker `env` once, in one Layer. | The Effect diagnostics at error in `tsconfig.base.json`; `anti-slop/no-unknown-parameters`, `anti-slop/no-widen-then-assert` and `anti-slop/require-safety-comment-for-type-assertion`; `apps/platform/test/platform.test.ts` (a bad env fails at start, decoded once in `apps/platform/src/platform.ts`); `apps/platform/test/bindings.test.ts` (the decoded bindings, vars and secrets equal each wrangler.jsonc block's, the `AI` binding, `DRAFT_LIMIT`, `DRAFT_MODEL`, `PUBLIC_WEB_URL` and the code store's `CODE_CACHE` among them, and each port's factory takes its binding as the generated Env types it, without a cast); `packages/project/test/code-history.test.ts` (a kept code-history value is decoded with Schema when read, and one that no longer decodes is computed again); `packages/project/test/code.test.ts` (a kept commit that no longer decodes is computed again); `apps/web/test/dev-fixtures.test.ts` (the dev world's fixture record is decoded through the protocol's schemas when the world is built, so every case reads only a record that decodes) |17-| 3 | **Refusals are a closed `Schema.TaggedError` union and a public contract.** Handle them with `Match.exhaustive` or `catchTags`. Each carries a `retryable` and a `next` command fixed per tag, an optional `at`, and no `message` field. A `_tag` is renamed only with an alias. `protocol/render` is the one renderer for git `remote:`, CLI and MCP text. Stage-1 refusals accumulate. | `packages/protocol/test/refusal.test.ts` and `packages/protocol/test/render.test.ts` (every tag, the code reads' and drafting's `UnknownPath`, `UnknownRevision`, `UnknownProposal`, `ProposalClosed` and `DraftInProgress` included; a limit's refusal names its kind and its wait, and a ref outside `refs/heads/` reads as one the platform writes); `packages/agent-kit/test/full-llms.test.ts` (every tag in the union has a row in `/llms-full.txt`); `packages/protocol/test/mcp.test.ts` (a refusal from tools/call keeps its tag); `anti-slop-effect/prefer-effect-match` and `anti-slop-effect/no-manual-tag-comparison`; `packages/gate/test/shape.test.ts` (one push hears every stage-1 refusal at once); `apps/platform/test/mcp.test.ts` (each refusing MCP contract comes back as its exact refusal, `draftAsk`, `showProposal` and a code read's `UnknownPath` included); `apps/platform/test/workflows/draft.test.ts` (past the draft limit, `CapReached`); `apps/cli/test/policy.test.ts`; `apps/cli/test/local/check.test.ts` (the local check gives the gateway's stage-1 refusals for the same commit) |17+| 3 | **Refusals are a closed `Schema.TaggedError` union and a public contract.** Handle them with `Match.exhaustive` or `catchTags`. Each carries a `retryable` and a `next` command fixed per tag, an optional `at`, and no `message` field. A `_tag` is renamed only with an alias. `protocol/render` is the one renderer for git `remote:`, CLI and MCP text. Stage-1 refusals accumulate. | `packages/protocol/test/refusal.test.ts` and `packages/protocol/test/render.test.ts` (every tag, the code reads' and drafting's `UnknownPath`, `UnknownRevision`, `UnknownProposal`, `ProposalClosed` and `DraftInProgress` included; a limit's refusal names its kind and its wait, and a ref outside `refs/heads/` reads as one the platform writes); `packages/agent-kit/test/full-llms.test.ts` (every tag in the union has a row in `/llms-full.txt`); `packages/protocol/test/mcp.test.ts` (a refusal from tools/call keeps its tag); `anti-slop-effect/prefer-effect-match` and `anti-slop-effect/no-manual-tag-comparison`; `packages/gate/test/shape.test.ts` (one push hears every stage-1 refusal at once); `apps/platform/test/mcp.test.ts` (each refusing MCP contract comes back as its exact refusal, `draftAsk`, `showProposal` and a code read's `UnknownPath` included); `apps/platform/test/workflows/draft.test.ts` (past the draft limit, `CapReached`); `apps/cli/test/policy.test.ts`; `apps/cli/test/local/check.test.ts` (the local check gives the gateway's stage-1 refusals for the same commit); `packages/protocol/test/exit-code.test.ts` (each tag's CLI exit code is pinned, 75 exactly when it is retryable) |18 | 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); `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/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) |127 unmodified linesmodified:README.md+2 added
175 unmodified lines176 177 - **`myr mcp`** serves the platform's tools over MCP on stdio, in all five protocol versions from 2024-11-05 to 2026-07-28.178 - **Remote MCP** at `<platform>/mcp` speaks the stateless 2026-07-28 protocol, signed in through the platform's OAuth; the web's `/.well-known/mcp.json` points at it.179 - **The credential helper**, `git-credential-myr`, hands git the stored token for the platform's host and never prompts. It passes the harness and model it finds in the environment (`AI_AGENT` first, then Claude Code's, Cursor's or pi's own variables) as audit metadata, which a landing discloses as `Assisted-by`; identity is only ever the person's token.180+- **Exit codes.** `myr` ends with a code from sysexits(3), so a harness can branch without reading stderr: 75 when running the refusal's `next` and trying again can help, 65 when what was sent has to change, 66 when what was named does not exist, 77 when the caller may not, 69 when no platform answered, and 2 for a misuse. `/llms-full.txt` gives each refusal's code.181 - **`myr hook <event> --json`** answers Claude Code's hooks (session start, before a tool runs, before stopping) with the gate's own policy. It fails open: the gateway stays the authority.182 - **The pi package.** Once published, the package carries a `"pi"` key, so `pi install npm:@myr/cli` gives a pi agent the claim's brief, a guard before it edits the judge closure, and a verdict loop that continues at most three times.183 184 ## Numbers48 unmodified lines233 | --- | --- |234 | A push outside its ask's territory is refused in git's own `remote:` lines, and the fork keeps the commit. The fixed answer lands as the platform's commit, authored by the answerer, with `Asked-by` and `Signed-off-by`; a stale answer is `StaleBase`; replaying a request lands nothing twice. | `apps/platform/test/core-loop.test.ts` |235 | Refusals are one closed union of typed values, each with `retryable`, `next` and an optional `at`, and no `message`. MCP returns each one with its tag. | `packages/protocol/test/refusal.test.ts`, `packages/protocol/test/mcp.test.ts`, `apps/platform/test/mcp.test.ts` |236 | One renderer writes every refusal, for git, the CLI, MCP and the web. | `packages/protocol/test/render.test.ts` |237+| The CLI exits with each refusal's own code, 75 exactly when it is retryable, and the built binary does too. | `packages/protocol/test/exit-code.test.ts`, `apps/cli/test/build.test.ts` |238 | One push hears every shape refusal at once, not one per attempt. | `packages/gate/test/shape.test.ts` |239 | An answer cannot edit the files that judge it, and a disabling marker without a reason is refused. | `packages/checks/test/judge.test.ts`, `packages/gate/test/markers.test.ts` |240 | An ask opens only red first: its check fails on `main` twice the same way, by an assertion. | `packages/checks/test/red-first.test.ts` |241 | `myr check` gives the gateway's shape refusals for the same commit before you push. | `apps/cli/test/local/check.test.ts` |154 unmodified lines