Skip to content
Myr

Merge build/516-cli-ask-positional-and-local-ratchets: every CLI command names the ask the same way, and check counts ratchets before the push

Before adoption: this commit came in with the history the project adopted, so no landing records it.

W5 group 3 integration (issue 516 alone in group C, merged with --no-ff from 313513a without a conflict; bun install, gen, fix and verify left no change, and verify is green on this commit). - Kept, as 516's review advised: its edits outside the territory in packages/protocol (`Cli.formerFlags`, the four contracts' positional ask, `toCommand`'s hidden former flag), and the review's moves into one home each: `judgeRatchets` and `countLanes` in `@repo/checks/kinds/ratchet`, `explainedRaises` in `@repo/gate/escapes`, imported by the platform's `lanes.ts`, the Project DO and the CLI's `check`; the web's finish view now prints `finish <ask> --project ...`. - Spec 8.5's two W4 findings are resolved: the positional ask by 8348f03, the local ratchets by 7f1a273 and ec99d7e. - ASSUMPTION (516 #5): `check` judges against the base's count, not the platform's stored baseline, since no contract serves baselines. - No provenance rows left to fold (the `cli.ts` row already names `formerFlags`); no new fence for AGENTS.md's "Held by". - Budgets: platform entry 1,618,018 of 1,665,000; web JavaScript 2,332,735 of 2,500,000; debt at baseline.

authored by oscabriel · committed by oscabriel · parents 313513a, ec99d7e · Browse files · 23 files+1148 added−293 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

23 files+1148 added−293 removed

  • tests:+573 added−116 removed
  • other:+575 added−177 removed

23 files+1148 added−293 removed

modified:apps/cli/src/local/check.ts+75 added-17 removed
2 unmodified lines
3 * gate's own stages 0 and 1 (`@repo/gate`'s `pushStages`) over the facts a4 * push of HEAD to the claim's fork would give the gateway (`localFacts`),5 * under the policy at `main` (`localPolicy`), and prints the same refusals,6 * tag for tag; then it runs the ask's check and the project's lanes on7 * HEAD's tree, in a temp clone, through `CheckRunner` `/local`.7 * HEAD's tree, in a temp clone, through `CheckRunner` `/local`, and counts8 * the project's ratchets on HEAD and on its base (`ratchets.ts`), refusing9 * a raised count with the platform's `Weakened{ratchet}`.10 *11 * Nothing here writes to the repo, its config or its refs, and `--offline`12 * calls no platform: the parse stage then judges a live claim made up for13 * the person checking, and says so on stderr.
60 unmodified lines
74 ConfigBundler,75 ConfigBundlerBun,76 localPolicy,77} from "./local-policy.ts";78import { countRatchets, judgeMoves, RatchetMove } from "./ratchets.ts";79import { staleGenerated } from "./stale.ts";80import type { StaleCopy } from "./stale.ts";8182const COMMAND = "check";
6 unmodified lines
89});9091/**92 * What `check --json` prints on success: the ask, the diff it judged, each93 * lane, each ratchet's count on the base and on HEAD when it counted any,90 * lane, and the generated files that are out of date, when any are.94 * and the generated files that are out of date, when any are.95 */96const Checked = Schema.Struct({97 ask: AskId,98 base: CommitSha,99 head: CommitSha,100 lanes: Schema.Array(LaneResult),101 ratchets: Schema.optionalKey(Schema.NonEmptyArray(RatchetMove)),102 /** The last stage that ran: `shape` with `--shape-only`, else `checks`. */103 stage: Schema.Literals(["shape", "checks"]),104 stale: Schema.optionalKey(Schema.NonEmptyArray(Stale)),105});
402 unmodified lines
508 })509 )510 );511512/** A ratchet's count on the base and on HEAD, as a line says it. */513const moveText = ({ after, before, ratchet, territory }: RatchetMove) =>514 `${ratchet} in ${territory}: ${before} on the base, ${after} here`;515507/** The run as a person reads it: each lane and how it ended. */516/** The run as a person reads it: each lane and how it ended, then each ratchet's count. */517const viewOf = (checked: Checked) => {518 const moves = checked.ratchets ?? [];519520 const lines = [521 `${checked.ask} at ${checked.head.slice(0, 12)}: the gate's shape stage has nothing to say.`,522 ...checked.lanes.map(523 ({ durationMs, lane, result }) =>524 ` ${lane}: ${result} (${durationMs} ms)`525 ),526 ...moves.map((move) => ` ratchet ${moveText(move)}`),527 ];528529 return {530 markdown: [
2 unmodified lines
533 ...checked.lanes.map(534 ({ durationMs, lane, result }) =>535 `- \`${lane}\`: ${result} (${durationMs} ms)`536 ),537 ...moves.map((move) => `- ratchet ${moveText(move)}`),538 ].join("\n"),539 text: lines.join("\n"),540 };541};542543/** The counts as `--json` lists them: absent when there are none. */544const ratchetsField = (moves: readonly RatchetMove[]) =>545 Array.match(moves, {546 onEmpty: () => ({}),547 onNonEmpty: (ratchets) => ({ ratchets }),548 });549550export const check = Command.make(551 COMMAND,552 {553 ask: Flag.String("ask").pipe(
206 unmodified lines
760 `No lane named ${unknown.join(", ")}; this project's lanes are ${all.map(({ lane }) => lane).join(", ")}.`761 );762 }763764 const runner = CheckRunnerLocal.layer({765 checkout: (at) =>766 checkoutOf({767 note: output.note,768 root: context.root,769 setup: Option.fromUndefinedOr(policy.run.setup),770 })(at).pipe(Effect.provide(services)),771 });772744 const run = yield* CheckRunner.use((runner) =>745 runner.run({773 const run = yield* CheckRunner.use((checker) =>774 checker.run({775 at: CheckAt.cases.Commit.make({ commit: facts.head }),776 lanes,777 placeholders: [],778 project,
1 unmodified line
780 repo: fork,781 run: policy.run,782 })783 ).pipe(755 Effect.provide(756 CheckRunnerLocal.layer({757 checkout: (at) =>758 checkoutOf({759 note: output.note,760 root: context.root,761 setup: Option.fromUndefinedOr(policy.run.setup),762 })(at).pipe(Effect.provide(services)),763 })764 ),784 Effect.provide(runner),785 Effect.catchTag("VerifierBlocked", (blocked) =>786 refuse(json, [blocked])787 ),788 Effect.flatMap((ran) => countedAskLane(policy, ask.value, ran))
10 unmodified lines
799 yield* output.note(`${evidence.lane} failed: ${evidence.signature}`);800 }801 }802783 if (Array.isReadonlyArrayNonEmpty(failed)) {784 return yield* refuse(json, failed);803 // The ratchets, counted on the base and on HEAD as the platform's804 // cheap stage counts them, unless `--lane` asked for lanes alone.805 const declared = Array.isReadonlyArrayNonEmpty(policy.ratchets);806 const counting = declared && flags.lane.length === 0;807808 if (declared && !counting) {809 yield* output.note(810 "The ratchets were not counted: --lane runs only the lanes it names."811 );812 }813814 const counts = counting815 ? yield* countRatchets({816 base: facts.base,817 head: facts.head,818 policy,819 project,820 repo: fork,821 }).pipe(Effect.provide(runner))822 : { moves: [], uncounted: [] };823824 for (const { ratchet, why } of counts.uncounted) {825 yield* output.note(826 `Could not count the ratchet ${ratchet} here: ${why}. The platform counts it after the push.`827 );828 }829830 const ratcheted = judgeMoves(facts, ask.value, counts.moves);831832 for (const move of ratcheted.decisions) {833 yield* output.note(834 `The ratchet ${moveText(move)}: a reasoned escape you add there asks a decider to raise it, so the answer will wait on that decision.`835 );836 }837838 const refusals = [...failed, ...ratcheted.refusals];839840 if (Array.isReadonlyArrayNonEmpty(refusals)) {841 return yield* refuse(json, refusals);842 }843844 const checked: Checked = {845 ...judged,846 lanes: run.lanes,847 ...ratchetsField(counts.moves),848 stage: "checks",849 ...staleField(stale),850 };851
12 unmodified lines
added:apps/cli/src/local/ratchets.ts+236 added
1/**2 * `check`'s ratchets: the project's ratchets counted on this machine, on the3 * tree an answer started from and on the answer's own, by the count lanes4 * the platform's cheap stage runs (`countLanes`, from the run block, each5 * handing back its stdout) and read by the platform's own counting code6 * (`measure`); then judged by the Project DO's own `judgeRatchets` (all three7 * in `@repo/checks/kinds/ratchet`), with the base's counts standing in for8 * the baselines, which no contract serves (a landing leaves each baseline at9 * what main then counts). A count over its base's is `Weakened{ratchet}`,10 * unless a reasoned escape the answer adds in that territory asks a decider11 * to raise it (`explainedRaises` in `@repo/gate/escapes`): then the answer12 * will wait on that decision instead.13 *14 * A ratchet this machine cannot count (its command prints nothing the15 * counter reads, or the tree could not be checked out and set up) is named16 * with why, and left to the platform: it never fails `check`.17 */18import { CheckAt, CheckRunner, outputOf } from "@repo/checks/check-runner";19import type { CheckLane, CheckRun } from "@repo/checks/check-runner";20import {21 countLanes,22 judgeRatchets,23 measure,24 sameRatchet,25} from "@repo/checks/kinds/ratchet";26import type {27 RatchetCount,28 RatchetJudgement,29} from "@repo/checks/kinds/ratchet";30import { escapeDecisions, explainedRaises } from "@repo/gate/escapes";31import type { PushFacts } from "@repo/gate/facts";32import type { LaneOutcome } from "@repo/protocol/domain/answer";33import type { Ask } from "@repo/protocol/domain/ask";34import type { Policy } from "@repo/protocol/domain/policy";35import { RatchetName } from "@repo/protocol/ids";36import type { CommitSha, ProjectName, RepoName } from "@repo/protocol/ids";37import { Array, Effect, Option, Result, Schema } from "effect";3839/** One ratchet's count in one territory, on the answer's base and on its head. */40export const RatchetMove = Schema.Struct({41 after: Schema.Int,42 before: Schema.Int,43 ratchet: RatchetName,44 territory: Schema.String,45});4647export type RatchetMove = typeof RatchetMove.Type;4849/** A ratchet no count was read for here, and why. */50export interface Uncounted {51 readonly ratchet: RatchetName;52 readonly why: string;53}5455/** What counting on this machine gave: the counts both trees had, and what it could not count. */56export interface LocalCounts {57 readonly moves: readonly RatchetMove[];58 readonly uncounted: readonly Uncounted[];59}6061/** How a count lane that printed no count ended, in words. */62const endings = {63 blocked: "it never ran here, or ran out of time",64 failed: "it failed",65 flaked: "it flaked",66 loadError: "it did not load",67 passed: "it passed",68} as const satisfies Record<LaneOutcome, string>;6970/**71 * How a count lane that printed no count ended, when that says more: the72 * failure's signature, or else the way it ended (a command this machine73 * lacks never ran).74 */75const endedAs = (ran: CheckRun, lane: Option.Option<CheckLane>) =>76 Option.flatMap(lane, ({ lane: name }) =>77 Option.firstSomeOf([78 Array.findFirst(ran.evidence, (each) => each.lane === name).pipe(79 Option.flatMap(({ signature }) => Option.fromUndefinedOr(signature))80 ),81 Array.findFirst(ran.lanes, (each) => each.lane === name).pipe(82 Option.filter(({ result }) => result !== "passed"),83 Option.map(({ result }) => endings[result])84 ),85 ])86 );8788/** One ratchet's counts per territory on one tree, or why none were read. */89interface Counted {90 readonly ratchet: RatchetName;91 readonly counts: Result.Result<readonly RatchetCount[], Uncounted>;92}9394/** Each ratchet's counts from one run of its count lanes. */95const countsIn = (96 policy: Policy,97 ran: CheckRun98): Effect.Effect<readonly Counted[]> => {99 const lanes = countLanes(policy.ratchets);100101 return Effect.forEach(policy.ratchets, (spec) => {102 const lane = Array.findFirst(103 lanes,104 ({ command }) => command === spec.measure.command105 );106107 const printed = Option.getOrElse(108 Option.flatMap(lane, ({ lane: name }) => outputOf(ran, name)),109 () => ""110 );111112 const why = `\`${spec.measure.command}\` printed no count it can read${Option.match(113 endedAs(ran, lane),114 { onNone: () => "", onSome: (text) => ` (${text})` }115 )}`;116117 return measure(118 spec,119 () => Effect.succeed({ code: 0, stdout: printed }),120 policy.modules121 ).pipe(122 Effect.mapError((): Uncounted => ({ ratchet: spec.name, why })),123 Effect.result,124 Effect.map((counts): Counted => ({ counts, ratchet: spec.name }))125 );126 });127};128129/**130 * The project's ratchets counted at `base` and at `head`, each tree in a131 * checkout of its own set up by the run block, as the platform counts them132 * in a Checker job of their own. A count only one tree has is not judged133 * (the platform's first landing sets that baseline).134 */135export const countRatchets = (input: {136 readonly base: CommitSha;137 readonly head: CommitSha;138 readonly policy: Policy;139 readonly project: ProjectName;140 readonly repo: RepoName;141}): Effect.Effect<LocalCounts, never, CheckRunner> =>142 Effect.gen(function* () {143 const { policy } = input;144 const runner = yield* CheckRunner;145146 const countedAt = (commit: CommitSha) =>147 runner148 .run({149 at: CheckAt.cases.Commit.make({ commit }),150 lanes: countLanes(policy.ratchets),151 placeholders: [],152 project: input.project,153 proxies: [],154 repo: input.repo,155 run: policy.run,156 })157 .pipe(158 Effect.flatMap((ran) => countsIn(policy, ran)),159 Effect.catchTag("VerifierBlocked", () =>160 Effect.succeed(161 policy.ratchets.map(({ name }): Counted => ({162 counts: Result.fail({163 ratchet: name,164 why: `${commit.slice(0, 12)} could not be checked out and set up here`,165 }),166 ratchet: name,167 }))168 )169 )170 );171172 const [before, after] = yield* Effect.all(173 [countedAt(input.base), countedAt(input.head)],174 { concurrency: "unbounded" }175 );176177 const uncounted = Array.dedupeWith(178 [...before, ...after].flatMap(({ counts }) =>179 Result.isFailure(counts) ? [counts.failure] : []180 ),181 (one, other) => one.ratchet === other.ratchet182 );183184 // A ratchet either tree could not count is judged by the platform alone.185 const countsOf = (all: readonly Counted[]) =>186 all.flatMap(({ counts, ratchet }) =>187 uncounted.some((each) => each.ratchet === ratchet)188 ? []189 : Result.getOrElse(counts, (): readonly RatchetCount[] => [])190 );191192 const based = countsOf(before);193194 const moves = countsOf(after).flatMap(195 ({ count, ratchet, territory }): readonly RatchetMove[] =>196 Option.match(197 Array.findFirst(based, sameRatchet({ ratchet, territory })),198 {199 onNone: () => [],200 onSome: (held) => [201 { after: count, before: held.count, ratchet, territory },202 ],203 }204 )205 );206207 return { moves, uncounted };208 });209210/**211 * The answer's counts judged by the Project DO's own `judgeRatchets`, with212 * each count on the base as the baseline and the raises the push's reasoned213 * escapes explain, as the Project DO reads them from the same facts: a count214 * over its base's is refused `Weakened{ratchet}`, unless the answer asks to215 * raise that ratchet in that territory, when it waits on a decider instead216 * (`decisions`).217 */218export const judgeMoves = (219 facts: PushFacts,220 ask: Ask,221 moves: readonly RatchetMove[]222): RatchetJudgement =>223 judgeRatchets({224 ask: ask.id,225 baselines: moves.map(({ before, ratchet, territory }) => ({226 count: before,227 ratchet,228 territory,229 })),230 measured: moves.map(({ after, ratchet, territory }) => ({231 count: after,232 ratchet,233 territory,234 })),235 raises: explainedRaises(facts.policy, ask, escapeDecisions(facts)),236 });
modified:apps/cli/test/local/check.test.ts+231 added
309 unmodified lines
310 }),311 () => Effect.sync(() => vi.unstubAllEnvs())312 );313314/** The ratchet the projects below declare, and the rule it counts. */315const ratchet = "no-explicit-any";316317/**318 * A lint that prints oxlint's JSON: one `no-explicit-any` finding per319 * explicit `any` under `packages/`, so its count follows the tree it runs on.320 */321const countingLint = [322 "grep -rnow any packages | awk -F: '",323 ' BEGIN { printf "{\\"diagnostics\\":[" }',324 ' { printf "%s{\\"code\\":\\"typescript(no-explicit-any)\\",\\"filename\\":\\"%s\\"}", (NR > 1 ? "," : ""), $1 }',325 ' END { print "]}" }',326 "'",327 "exit 1",328 "",329].join("\n");330331/**332 * Main as a project that declares the ratchet, counted by `command`, writes333 * it: the config folder in TypeScript (the fixture's `fix-a`, as a file of334 * its own), the lint, and two explicit `any`s in a. HEAD is left on main.335 */336const declaringRatchet = (repo: CheckRepo, command: string) =>337 Effect.gen(function* () {338 const sdk = `${Brand.cliPackage}/rules`;339340 yield* gitOk(repo.root, "checkout", "--quiet", "main");341 yield* gitOk(repo.root, "rm", "--quiet", policyFile);342343 return yield* commit(344 repo.root,345 {346 [`${Brand.configDir}/asks/${ask}.ask.ts`]: [347 `import { kinds, territory } from "${sdk}";`,348 "",349 "export default kinds.fix.ask({",350 ` path: "${checkFile}",`,351 ' territory: territory.package("a"),',352 ' want: "a is two",',353 "});",354 "",355 ].join("\n"),356 [`${Brand.configDir}/project.ts`]: [357 `import { check, kinds, project } from "${sdk}";`,358 "",359 "export default project({",360 " kinds: [kinds.fix],",361 " ratchets: {",362 ` "${ratchet}": check.ratchet.count("${command}", { rule: "typescript/no-explicit-any" }),`,363 " },",364 ' run: { checks: {}, test: "true {path}" },',365 "});",366 "",367 ].join("\n"),368 "lint.sh": countingLint,369 "packages/a/src/a.ts": "export const a = (x: any, y: any) => 1;\n",370 },371 "Count explicit anys"372 );373 });374375/** An answer on a branch of its own from main that types a third value in a as `any`. */376const raisingInA = (repo: CheckRepo) =>377 Effect.gen(function* () {378 yield* gitOk(repo.root, "checkout", "--quiet", "-b", "raising", "main");379380 return yield* commit(381 repo.root,382 {383 "packages/a/src/a.ts":384 "export const a = (x: any, y: any, z: any) => 2;\n",385 },386 "Make a two, loosely"387 );388 });389390describe(`${Brand.cli} check`, () => {391 it.live(392 "prints the refusals the gateway would give the same head, in one envelope, and exits 1",393 () =>
310 unmodified lines
704 });705 expect(printed.err.join("\n")).toContain(`Checking the ask ${ask}`);706 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))707 );708709 it.live(710 "refuses an answer that raises a ratchet's count from 2 to 3 in the ask's territory, as Weakened, before the push",711 () =>712 Effect.gen(function* () {713 const repo = yield* aCheckRepo;714715 yield* declaringRatchet(repo, "sh lint.sh");716 yield* raisingInA(repo);717718 const printed = yield* run([719 "check",720 "--dir",721 repo.root,722 "--ask",723 ask,724 "--offline",725 "--json",726 ]).pipe(Effect.provide(services(unreachable)));727728 // What the platform said live of the same raise (spec §8.5): the729 // ratchet, the module, and main's count before the answer's after.730 expect(Exit.isFailure(printed.exit)).toBeTruthy();731 expect(yield* decodedOf(printed.out)).toStrictEqual({732 command: "check",733 ok: false,734 refusals: [735 new Weakened({736 weakening: { after: 3, before: 2, ratchet, territory: "a" },737 }),738 ],739 v: 1,740 });741 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))742 );743744 it.live(745 "lets a raise a reasoned escape explains wait on a decider, as the platform does, and says so",746 () =>747 Effect.gen(function* () {748 const repo = yield* aCheckRepo;749750 yield* declaringRatchet(repo, "sh lint.sh");751 yield* gitOk(repo.root, "checkout", "--quiet", "-b", "escaping");752753 yield* commit(754 repo.root,755 {756 "packages/a/src/a.ts": [757 "// @ts-expect-error -- the codec boundary erases types",758 "export const a = (x: any, y: any, z: any) => 2;",759 "",760 ].join("\n"),761 },762 "Make a two, past a codec"763 );764765 const printed = yield* run([766 "check",767 "--dir",768 repo.root,769 "--ask",770 ask,771 "--offline",772 "--json",773 ]).pipe(Effect.provide(services(unreachable)));774775 expect(Exit.isSuccess(printed.exit)).toBeTruthy();776 expect(yield* envelopeOf(printed.out)).toMatchObject({777 data: {778 ratchets: [779 { after: 3, before: 2, ratchet, territory: "a" },780 { after: 0, before: 0, ratchet, territory: "b" },781 ],782 },783 ok: true,784 });785 expect(printed.err.join("\n")).toContain(786 `The ratchet ${ratchet} in a: 2 on the base, 3 here: a reasoned escape you add there asks a decider to raise it`787 );788 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))789 );790791 it.live(792 "passes an answer that keeps every ratchet's count, and reports the counts",793 () =>794 Effect.gen(function* () {795 const repo = yield* aCheckRepo;796 const main = yield* declaringRatchet(repo, "sh lint.sh");797798 yield* gitOk(repo.root, "checkout", "--quiet", "-b", "keeping");799800 const head = yield* commit(801 repo.root,802 {803 "packages/a/src/a.ts": "export const a = (x: any, y: any) => 2;\n",804 },805 "Make a two"806 );807808 const printed = yield* run([809 "check",810 "--dir",811 repo.root,812 "--ask",813 ask,814 "--offline",815 "--json",816 ]).pipe(Effect.provide(services(unreachable)));817818 expect(Exit.isSuccess(printed.exit)).toBeTruthy();819 expect(yield* envelopeOf(printed.out)).toMatchObject({820 data: {821 base: main,822 head,823 ratchets: [824 { after: 2, before: 2, ratchet, territory: "a" },825 { after: 0, before: 0, ratchet, territory: "b" },826 ],827 stage: "checks",828 },829 ok: true,830 });831 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))832 );833834 it.live(835 "says plainly that a ratchet it cannot count here is left to the platform, and does not fail on it",836 () =>837 Effect.gen(function* () {838 const repo = yield* aCheckRepo;839840 yield* declaringRatchet(repo, "not-installed-here --format json");841 yield* raisingInA(repo);842843 const printed = yield* run([844 "check",845 "--dir",846 repo.root,847 "--ask",848 ask,849 "--offline",850 "--json",851 ]).pipe(Effect.provide(services(unreachable)));852853 expect(Exit.isSuccess(printed.exit)).toBeTruthy();854 expect(yield* envelopeOf(printed.out)).toMatchObject({855 data: { stage: "checks" },856 ok: true,857 });858 expect(printed.err.join("\n")).toContain(859 `Could not count the ratchet ${ratchet} here`860 );861 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer))862 );863});
modified:apps/cli/test/surfaces.test.ts+118 added
455 unmodified lines
456 unanswered,457 Contracts.toLayerHandler("submitAnswer", () => Effect.succeed(receipt))458 );459460/** Each command that names an ask, and what else it takes, as a person types it. */461const naming = {462 finish: [463 "--project",464 project,465 "--base",466 base,467 "--head",468 head,469 "--requestId",470 requestId,471 "--yes",472 ],473 release: ["--project", project],474 submit: [475 "--project",476 project,477 "--base",478 base,479 "--head",480 head,481 "--requestId",482 requestId,483 ],484 verdict: ["--project", project],485} as const satisfies Readonly<Record<string, readonly string[]>>;486487/** A platform that records the ask each call names, and answers each call plainly. */488const recordingAsks = (named: Ref.Ref<readonly string[]>) => {489 const record = (given: string) => Ref.update(named, (all) => [...all, given]);490491 const receipt = receiptAt(Outcome.cases.Checking.make({ stage: "merge" }));492493 return Layer.mergeAll(494 unanswered,495 Contracts.toLayerHandler("verdict", (payload) =>496 record(payload.ask).pipe(Effect.as({}))497 ),498 Contracts.toLayerHandler("release", (payload) =>499 record(payload.ask).pipe(Effect.as({ released: true }))500 ),501 Contracts.toLayerHandler("submitAnswer", (payload) =>502 record(payload.ask).pipe(Effect.as(receipt))503 ),504 Contracts.toLayerHandler("finish", (payload) =>505 record(payload.ask).pipe(Effect.as(receipt))506 )507 );508};509510describe("the ask a command is about", () => {511 it.effect(512 "is its first argument on verdict, release, submit and finish, as on claim",513 () =>514 Effect.gen(function* () {515 const named = yield* Ref.make<readonly string[]>([]);516517 const codes = yield* Effect.forEach(518 Object.entries(naming),519 ([command, rest]) =>520 Effect.map(521 runProgram([command, ask, ...rest], {522 handlers: recordingAsks(named),523 }),524 ({ code }) => [command, code] as const525 )526 );527528 expect(codes).toStrictEqual(529 Object.keys(naming).map((command) => [command, 0])530 );531 expect(yield* Ref.get(named)).toStrictEqual([ask, ask, ask, ask]);532 })533 );534535 it.effect(536 "still comes from --ask, which help no longer shows and which prints nothing more",537 () =>538 Effect.gen(function* () {539 const named = yield* Ref.make<readonly string[]>([]);540541 const runs = yield* Effect.forEach(542 Object.entries(naming),543 ([command, rest]) =>544 runProgram([command, "--ask", ask, ...rest], {545 handlers: recordingAsks(named),546 })547 );548549 expect(runs.map(({ code }) => code)).toStrictEqual([0, 0, 0, 0]);550 expect(runs.flatMap(({ err }) => err)).toStrictEqual([]);551 expect(yield* Ref.get(named)).toStrictEqual([ask, ask, ask, ask]);552553 const help = yield* runProgram(["verdict", "--help"], {554 handlers: unanswered,555 });556557 expect(help.out.join("\n")).toContain("<ask>");558 expect(help.out.join("\n")).not.toContain("--ask");559 })560 );561562 it.effect("is a usage error naming <ask> when neither form gives it", () =>563 Effect.gen(function* () {564 const named = yield* Ref.make<readonly string[]>([]);565566 const run = yield* runProgram(["verdict", ...naming.verdict], {567 handlers: recordingAsks(named),568 });569570 expect(run.code).toBe(2);571 expect(run.err).toHaveLength(1);572 expect(run.err[0]).toContain("<ask>");573 expect(yield* Ref.get(named)).toStrictEqual([]);574 })575 );576});577578describe("an answer offered with submit", () => {579 it.effect("prints the same line git's remote: output gives its push", () =>580 Effect.gen(function* () {581 const offered = receiptAt(
50 unmodified lines
modified:apps/platform/src/workflows/answer/lanes.ts+2 added-7 removed
23 unmodified lines
24} from "@repo/checks/check-runner";25import type { CheckRun, LaneEvidence } from "@repo/checks/check-runner";26import { EvidenceStore } from "@repo/checks/evidence-store";27import { lintToZeroCount } from "@repo/checks/kinds/lint-to-zero";28import { measure } from "@repo/checks/kinds/ratchet";28import { countLanes, measure } from "@repo/checks/kinds/ratchet";29import { classifyFailure } from "@repo/gate/classify";30import { MeasuredCount, runBlockOf } from "@repo/project/answer-runs";31import type { AnswerRun } from "@repo/project/answer-runs";32import { LandingState } from "@repo/project/landing";
361 unmodified lines
394 if (!Array.isReadonlyArrayNonEmpty(specs)) {395 return { counts: [], uncounted: Option.none() };396 }397398 const lanes = Array.dedupeWith(399 specs,400 (one, other) => one.measure.command === other.measure.command401 ).map(({ measure: { command }, name }) =>402 CheckLane.make({ command, lane: LaneName.make(name), output: "stdout" })403 );398 const lanes = countLanes(specs);399400 const ran = yield* job(lanes);401402 const printed = (command: string) =>
207 unmodified lines
modified:apps/web/src/features/finish/finish-view.tsx+1 added-1 removed
51 unmodified lines
52 const base = verdict?.base ?? "<base>";5354 return {55 fetch: [`git fetch ${remote} ${head}`, "git switch --detach FETCH_HEAD"],56 finish: `${Brand.cli} finish --project ${decision.project} --ask ${ask} --base ${base} --head $(git rev-parse HEAD) --requestId finish-$(git rev-parse HEAD) --yes`,56 finish: `${Brand.cli} finish ${ask} --project ${decision.project} --base ${base} --head $(git rev-parse HEAD) --requestId finish-$(git rev-parse HEAD) --yes`,57 push: `git push ${remote} HEAD:main`,58 };59};60
158 unmodified lines
modified:apps/web/test/finish.test.tsx+1 added-3 removed
219 unmodified lines
220 const text = textOf(element);221222 expect(text).toContain(`git fetch ${PLATFORM_URL}/`);223 expect(text).toContain(` ${head}`);224 expect(text).toContain(225 `${Brand.cli} finish --project datekit --ask parse-iso`226 );224 expect(text).toContain(`${Brand.cli} finish parse-iso --project datekit`);225 expect(markupOf(element)).not.toContain("<diffs-container");226 expect(markupOf(element)).not.toContain('data-diff="');227 });228
86 unmodified lines
modified:docs/reference/cli.md+8 added-8 removed
253 unmodified lines
254255Finish a passing answer with a decider's own commits on top; they are checked again, and credited with Finished-by when it lands.256257```sh258myr finish --ask <ask> --base <base> --head <head> [--project <project>] --requestId <requestId> [--json] [--yes] [--dry-run]258myr finish <ask> --base <base> --head <head> [--project <project>] --requestId <requestId> [--json] [--yes] [--dry-run]259```260261- Contract: `finish`262- Reads only: no
3 unmodified lines
266- Surfaces: rpc, mcp, cli267268| Argument | Takes | Required |269| --- | --- | --- |270| `--ask` | text | yes |270| `<ask>` | text | yes |271| `--base` | text | yes |272| `--head` | text | yes |273| `--project` | text | no: the project of the repo you stand in |274| `--requestId` | text | yes |
238 unmodified lines
513514Release the caller's claim on an ask, so anyone may claim it again.515516```sh517myr release --ask <ask> [--project <project>] [--json] [--dry-run]517myr release <ask> [--project <project>] [--json] [--dry-run]518```519520- Contract: `release`521- Reads only: no
3 unmodified lines
525- Surfaces: rpc, mcp, cli526527| Argument | Takes | Required |528| --- | --- | --- |529| `--ask` | text | yes |529| `<ask>` | text | yes |530| `--project` | text | no: the project of the repo you stand in |531| `--json` | nothing (a switch) | no |532| `--dry-run` | nothing (a switch) | no |533
37 unmodified lines
571572Offer the commit `head`, built on `base`, as an answer to a claimed ask; the receipt says it is being checked, and it lands if it passes.573574```sh575myr submit --ask <ask> --base <base> --head <head> [--project <project>] --requestId <requestId> [--json] [--dry-run]575myr submit <ask> --base <base> --head <head> [--project <project>] --requestId <requestId> [--json] [--dry-run]576```577578- Contract: `submitAnswer`579- Reads only: no
3 unmodified lines
583- Surfaces: rpc, mcp, cli584585| Argument | Takes | Required |586| --- | --- | --- |587| `--ask` | text | yes |587| `<ask>` | text | yes |588| `--base` | text | yes |589| `--head` | text | yes |590| `--project` | text | no: the project of the repo you stand in |591| `--requestId` | text | yes |
24 unmodified lines
616617Show the verdict on an answer to an ask, for its latest head or the one named; held-back checks show one bit per area.618619```sh620myr verdict --ask <ask> [--head <head>] [--project <project>] [--json]620myr verdict <ask> [--head <head>] [--project <project>] [--json]621```622623- Contract: `verdict`624- Reads only: yes
3 unmodified lines
628- Surfaces: rpc, mcp, cli, web629630| Argument | Takes | Required |631| --- | --- | --- |632| `--ask` | text | yes |632| `<ask>` | text | yes |633| `--head` | text | no |634| `--project` | text | no: the project of the repo you stand in |635| `--json` | nothing (a switch) | no |636
40 unmodified lines
modified:docs/reference/commands.json+12 added-8 removed
558 unmodified lines
559 "contract": "finish",560 "description": "Finish a passing answer with a decider's own commits on top; they are checked again, and credited with Finished-by when it lands.",561 "destructive": false,562 "flags": [563 "--ask",563 "--base",564 "--head",565 "--project",566 "--requestId",
51 unmodified lines
618 "requestId"619 ],620 "type": "object"621 },623 "positional": [],622 "positional": [623 "ask"624 ],625 "readOnly": false,626 "source": "contract",627 "surfaces": [628 "rpc",
456 unmodified lines
1085 "contract": "release",1086 "description": "Release the caller's claim on an ask, so anyone may claim it again.",1087 "destructive": false,1088 "flags": [1088 "--ask",1089 "--project",1090 "--json",1091 "--dry-run"1092 ],
32 unmodified lines
1125 "project"1126 ],1127 "type": "object"1128 },1129 "positional": [],1129 "positional": [1130 "ask"1131 ],1132 "readOnly": false,1133 "source": "contract",1134 "surfaces": [1135 "rpc",
58 unmodified lines
1194 "contract": "submitAnswer",1195 "description": "Offer the commit `head`, built on `base`, as an answer to a claimed ask; the receipt says it is being checked, and it lands if it passes.",1196 "destructive": false,1197 "flags": [1196 "--ask",1198 "--base",1199 "--head",1200 "--project",1201 "--requestId",
50 unmodified lines
1252 "requestId"1253 ],1254 "type": "object"1255 },1255 "positional": [],1256 "positional": [1257 "ask"1258 ],1259 "readOnly": false,1260 "source": "contract",1261 "surfaces": [1262 "rpc",
39 unmodified lines
1302 "contract": "verdict",1303 "description": "Show the verdict on an answer to an ask, for its latest head or the one named; held-back checks show one bit per area.",1304 "destructive": false,1305 "flags": [1303 "--ask",1306 "--head",1307 "--project",1308 "--json"1309 ],
36 unmodified lines
1346 "project"1347 ],1348 "type": "object"1349 },1348 "positional": [],1350 "positional": [1351 "ask"1352 ],1353 "readOnly": true,1354 "source": "contract",1355 "surfaces": [1356 "rpc",
86 unmodified lines
modified:packages/checks/src/kinds/ratchet.ts+107 added-8 removed
1/**2 * The `ratchet` check kind's measure: run a ratchet's declared command once3 * and read its number per territory, exactly as the project's own tool4 * reports it. A lint count splits by path, so it yields one count per5 * territory (per-territory baselines, so the children of a split land on6 * their own; FE §8.4 B3); a metric is one number, so it yields one. The7 * command runs through the runner it is given, never here.2 * The `ratchet` check kind: the lanes that count a project's ratchets, the3 * measure that reads a ratchet's declared command's output as its number4 * per territory, exactly as the project's own tool reports it, and the5 * judgement of an answer's counts against the counts it is held to. A lint6 * count splits by path, so it yields one count per territory (per-territory7 * baselines, so the children of a split land on their own; FE §8.4 B3); a8 * metric is one number, so it yields one. The command runs through the9 * runner it is given, never here. The platform's cheap stage and the Project10 * DO, and `<cli> check` before a push, all count and judge through here.11 */12import { RatchetMeasure } from "@repo/protocol/domain/check";13import type { RatchetSpec } from "@repo/protocol/domain/check";14import { Glob } from "@repo/protocol/domain/common";15import { DecisionSubject } from "@repo/protocol/domain/decision";16import type { Territory } from "@repo/protocol/domain/territory";13import type { RatchetName } from "@repo/protocol/ids";14import { Effect } from "effect";17import { LaneName } from "@repo/protocol/ids";18import type { AskId, RatchetName } from "@repo/protocol/ids";19import { Weakened } from "@repo/protocol/refusal";20import { Array, Effect, Option } from "effect";2122import type { CheckLane } from "../check-runner.ts";23import { countLint, countWithin } from "./lint-count.ts";24import type { CountUnreadable } from "./lint-count.ts";25import { readMetric } from "./metric.ts";26
94 unmodified lines
121 },122 ])123 ),124 });125126/**127 * The lanes that count `ratchets`: one per command, named for the first128 * ratchet that runs it, each handing back what it printed for `measure` to129 * read (a lint's exit code says nothing of its count).130 */131export const countLanes = (132 ratchets: readonly RatchetSpec[]133): readonly CheckLane[] =>134 Array.dedupeWith(135 ratchets,136 (one, other) => one.measure.command === other.measure.command137 ).map(({ measure: { command }, name }) => ({138 command,139 lane: LaneName.make(name),140 output: "stdout",141 }));142143/** A ratchet in a territory: the key a baseline, a count and a raise are kept by. */144export interface RatchetKey {145 readonly ratchet: RatchetName;146 readonly territory: string;147}148149/** Whether two rows name one ratchet in one territory. */150export const sameRatchet =151 (one: RatchetKey) =>152 (other: RatchetKey): boolean =>153 one.ratchet === other.ratchet && one.territory === other.territory;154155/** The decision a raise waits on. */156export type RaiseRatchet = Extract<DecisionSubject, { _tag: "RaiseRatchet" }>;157158/** What judging an answer's counts gives: its refusals, and the raises it waits on. */159export interface RatchetJudgement {160 readonly refusals: readonly Weakened[];161 readonly decisions: readonly RaiseRatchet[];162}163164/**165 * Judges an answer's counts against the counts it is held to (the Project166 * DO's baselines; on a person's machine, the counts on the answer's base). A167 * count at or under its baseline passes; one over it is refused with168 * `Weakened{ratchet}`, unless the answer asks to raise that ratchet in that169 * territory: then it is not refused, and waits on a `RaiseRatchet` decision170 * instead. A ratchet with no baseline yet is not judged (its first landing171 * sets it).172 */173export const judgeRatchets = (input: {174 readonly baselines: readonly RatchetCount[];175 readonly measured: readonly RatchetCount[];176 readonly ask: AskId;177 readonly raises: readonly RatchetKey[];178}): RatchetJudgement => {179 const raised = input.measured.flatMap((measured) =>180 Option.match(Array.findFirst(input.baselines, sameRatchet(measured)), {181 onNone: () => [],182 onSome: (held) =>183 measured.count > held.count184 ? [185 {186 after: measured.count,187 asked: input.raises.some(sameRatchet(measured)),188 before: held.count,189 ratchet: measured.ratchet,190 territory: measured.territory,191 },192 ]193 : [],194 })195 );196197 return {198 decisions: raised199 .filter(({ asked }) => asked)200 .map(({ after, before, ratchet, territory }) =>201 DecisionSubject.cases.RaiseRatchet.make({202 after,203 ask: input.ask,204 before,205 ratchet,206 territory,207 })208 ),209 refusals: raised210 .filter(({ asked }) => !asked)211 .map(212 ({ after, before, ratchet, territory }) =>213 new Weakened({ weakening: { after, before, ratchet, territory } })214 ),215 };216};
modified:packages/checks/test/kinds/ratchet.test.ts+142 added-3 removed
1import { describe, expect, it } from "@effect/vitest";2import { RatchetMeasure, RatchetSpec } from "@repo/protocol/domain/check";3import { Command, Glob, JsonPath } from "@repo/protocol/domain/common";4import { DecisionSubject } from "@repo/protocol/domain/decision";5import type { Territory } from "@repo/protocol/domain/territory";5import { RatchetName } from "@repo/protocol/ids";6import { Effect, Exit, Ref } from "effect";6import { AskId, RatchetName } from "@repo/protocol/ids";7import { Weakened } from "@repo/protocol/refusal";8import { Effect, Exit, Ref, Schema } from "effect";910import { CountUnreadable } from "../../src/kinds/lint-count.ts";9import { measure } from "../../src/kinds/ratchet.ts";11import { countLanes, judgeRatchets, measure } from "../../src/kinds/ratchet.ts";12import type { RatchetCount } from "../../src/kinds/ratchet.ts";13import { recorded } from "./recorded.ts";1415// The recordings `lint-count.test.ts` describes: `any` three times in16// parse.ts and once in date.ts (packages/parser), once in lex.ts
161 unmodified lines
178 expect(exit).toStrictEqual(Exit.fail("no checker"));179 })180 );181});182183describe(countLanes, () => {184 it("runs each command once, in a lane named for the first ratchet that runs it, handing back what it printed", () => {185 const anyInLexer = RatchetSpec.make({186 ...counting,187 name: RatchetName.make("anyInLexer"),188 territory: "@fixture/lexer",189 });190191 expect(countLanes([counting, bundle, anyInLexer])).toStrictEqual([192 { command: lintCommand, lane: "anyCount", output: "stdout" },193 { command: bundleCommand, lane: "bundleKb", output: "stdout" },194 ]);195 });196197 it("runs nothing for a project with no ratchets", () => {198 expect(countLanes([])).toStrictEqual([]);199 });200});201202const ask = AskId.make("parse-dates");203204const parser = "@fixture/parser";205206const counted = (count: number, territory = parser): RatchetCount => ({207 count,208 ratchet: anyCount,209 territory,210});211212const raising = {213 ratchet: anyCount,214 reason: "the parser's one cast, until the date types land",215 territory: parser,216};217218const wire = (refusals: readonly Weakened[]) =>219 refusals.map((refusal) => Schema.encodeSync(Weakened)(refusal));220221describe(judgeRatchets, () => {222 it("refuses an answer that raises a ratchet with Weakened", () => {223 const { decisions, refusals } = judgeRatchets({224 ask,225 baselines: [counted(14)],226 measured: [counted(15)],227 raises: [],228 });229230 expect(decisions).toStrictEqual([]);231 expect(wire(refusals)).toStrictEqual(232 wire([233 new Weakened({234 weakening: {235 after: 15,236 before: 14,237 ratchet: anyCount,238 territory: parser,239 },240 }),241 ])242 );243 });244245 it.each([14, 12, 0])("lets an answer through at %i", (count) => {246 expect(247 judgeRatchets({248 ask,249 baselines: [counted(14)],250 measured: [counted(count)],251 raises: [],252 })253 ).toStrictEqual({ decisions: [], refusals: [] });254 });255256 it("turns an asked-for raise into one RaiseRatchet decision, not a refusal", () => {257 expect(258 judgeRatchets({259 ask,260 baselines: [counted(14)],261 measured: [counted(15)],262 raises: [raising],263 })264 ).toStrictEqual({265 decisions: [266 DecisionSubject.cases.RaiseRatchet.make({267 after: 15,268 ask,269 before: 14,270 ratchet: anyCount,271 territory: parser,272 }),273 ],274 refusals: [],275 });276 });277278 it("refuses a raise asked for in another territory", () => {279 const { decisions, refusals } = judgeRatchets({280 ask,281 baselines: [counted(14)],282 measured: [counted(15)],283 raises: [{ ...raising, territory: "@fixture/lexer" }],284 });285286 expect(decisions).toStrictEqual([]);287 expect(refusals.map(({ weakening }) => weakening)).toStrictEqual([288 { after: 15, before: 14, ratchet: anyCount, territory: parser },289 ]);290 });291292 it("judges nothing a ratchet has no baseline for yet", () => {293 expect(294 judgeRatchets({295 ask,296 baselines: [],297 measured: [counted(15)],298 raises: [],299 })300 ).toStrictEqual({ decisions: [], refusals: [] });301 });302303 it("judges each territory against its own baseline", () => {304 const lexer = "@fixture/lexer";305306 const { refusals } = judgeRatchets({307 ask,308 baselines: [counted(14), counted(2, lexer)],309 measured: [counted(14), counted(3, lexer)],310 raises: [],311 });312313 expect(refusals.map(({ weakening }) => weakening)).toStrictEqual([314 { after: 3, before: 2, ratchet: anyCount, territory: lexer },315 ]);316 });317});
modified:packages/gate/src/escapes.ts+26 added
23 unmodified lines
2425/** A `Waiver` decision's subject. */26export type Waiver = Extract<DecisionSubject, { readonly _tag: "Waiver" }>;2728/** An answer asking a decider to raise one ratchet in one territory, and why. */29export interface RaiseRequest {30 readonly ratchet: RatchetName;31 readonly territory: string;32 readonly reason: string;33}3435/**36 * The escape ratchet of `territory`: `escapes-` and the territory's name in37 * lowercase words joined by `-` (`@datekit/parse` is `escapes-datekit-parse`);38 * a territory with no such words, the root's `.`, is `escapes-root`.
73 unmodified lines
112 })113 );114 },115 });116117/**118 * The raises a push's `waivers` ask a decider for: a reasoned escape in a119 * territory explains a raise of every declared ratchet there, for its120 * reason. The Project DO judges an answer's counts with them, and121 * `<cli> check` does the same before the push.122 */123export const explainedRaises = (124 policy: Policy,125 ask: Ask,126 waivers: readonly Waiver[]127): readonly RaiseRequest[] =>128 waivers.flatMap((waiver) =>129 policy.ratchets.map(({ name: ratchet }) => ({130 ratchet,131 reason: waiver.reason,132 territory: territoryOf(policy, ask, waiver.at.path),133 }))134 );
modified:packages/gate/test/escapes.test.ts+72 added-2 removed
1import { describe, expect, it } from "@effect/vitest";2import { RatchetMeasure, RatchetSpec } from "@repo/protocol/domain/check";3import { Command } from "@repo/protocol/domain/common";4import { DecisionSubject } from "@repo/protocol/domain/decision";5import { RatchetName, RepoPath } from "@repo/protocol/ids";6import { Option } from "effect";78import {9 escapeDecisions,10 escapeRatchet,11 explainedRaises,6import { escapeDecisions, escapeRatchet } from "../src/escapes.ts";7import { addedLines, ask, testFacts } from "./facts.ts";12} from "../src/escapes.ts";13import { addedLines, ask, policy, testFacts } from "./facts.ts";1415const week = "packages/parse/src/week.ts";1617const lex = "packages/parse/src/lex.ts";
111 unmodified lines
129 )130 ).toStrictEqual([]);131 });132});133134describe(explainedRaises, () => {135 const anyCount = RatchetName.make("no-explicit-any");136137 const bundleKb = RatchetName.make("bundle-kb");138139 const declaring = {140 ...policy,141 ratchets: [142 RatchetSpec.make({143 measure: RatchetMeasure.cases.Count.make({144 command: Command.make("oxlint --format json"),145 rule: "typescript/no-explicit-any",146 }),147 name: anyCount,148 }),149 RatchetSpec.make({150 measure: RatchetMeasure.cases.Count.make({151 command: Command.make("oxlint --format json"),152 rule: "import/max-dependencies",153 }),154 name: bundleKb,155 }),156 ],157 };158159 it("asks to raise every declared ratchet in each reasoned escape's territory, for its reason", () => {160 expect(161 explainedRaises(declaring, ask, [162 waiver(week, 4, "oxlint-disable", "the parser's one cast"),163 waiver(pad, 2, "eslint-disable", "generated tables"),164 ])165 ).toStrictEqual([166 {167 ratchet: anyCount,168 reason: "the parser's one cast",169 territory: "@datekit/parse",170 },171 {172 ratchet: bundleKb,173 reason: "the parser's one cast",174 territory: "@datekit/parse",175 },176 {177 ratchet: anyCount,178 reason: "generated tables",179 territory: "@datekit/format",180 },181 {182 ratchet: bundleKb,183 reason: "generated tables",184 territory: "@datekit/format",185 },186 ]);187 });188189 it("asks nothing of a project that declares no ratchets", () => {190 expect(191 explainedRaises(policy, ask, [192 waiver(week, 4, "oxlint-disable", "the parser's one cast"),193 ])194 ).toStrictEqual([]);195 });196});
modified:packages/project/src/project.ts+10 added-15 removed
34 unmodified lines
35import { judgeClosure } from "@repo/checks/judge";36import { checkVersion, commandFor } from "@repo/checks/kinds";37import { lintToZeroCount } from "@repo/checks/kinds/lint-to-zero";38import type { LintToZeroCheck } from "@repo/checks/kinds/lint-to-zero";39import {40 judgeRatchets,41 measure,42 WHOLE_PROJECT,39import { measure, WHOLE_PROJECT } from "@repo/checks/kinds/ratchet";40import type { RatchetCount } from "@repo/checks/kinds/ratchet";43} from "@repo/checks/kinds/ratchet";44import type { RaiseRatchet, RatchetCount } from "@repo/checks/kinds/ratchet";45import { redFirstOfRuns } from "@repo/checks/red-first";46import { weaknessesOf } from "@repo/checks/weak-shapes";47import {48 escapeDecisions,49 escapeRatchet,50 explainedRaises,51 territoryOf,52} from "@repo/gate/escapes";53import type { Waiver } from "@repo/gate/escapes";54import { PushTarget } from "@repo/gate/facts";
207 unmodified lines
262 RatchetRow,263} from "./project-store/rows.ts";264import type { Projection } from "./projection.ts";265import { askToLand, holdsSlot, leave, queueOf, storedQueue } from "./queue.ts";261import { afterLanding, decideRaise, judgeRatchets } from "./ratchets.ts";262import type {263 RaiseRatchet,264 RaiseRequest,265 RatchetBaseline,266} from "./ratchets.ts";266import { afterLanding, decideRaise } from "./ratchets.ts";267import type { RatchetBaseline } from "./ratchets.ts";268269/** Every port one project's service runs on. */270export type ProjectPorts =271 | Alarms
2358 unmodified lines
2630 const territoryIn = (waiver: Waiver) =>2631 territoryOf(policy, asked, waiver.at.path);26322633 // A reasoned escape in a territory explains a raise there.2633 const raises = waivers.flatMap((waiver): readonly RaiseRequest[] =>2634 policy.ratchets.map(({ name: ratchet }) => ({2635 ratchet,2636 reason: waiver.reason,2637 territory: territoryIn(waiver),2638 }))2639 );2634 const raises = explainedRaises(policy, asked, waivers);26352636 const declared = input.report?.ratchets ?? [];26372638 // A tree merged onto a main that has moved on since is not judged:
1717 unmodified lines
modified:packages/project/src/ratchets.ts+14 added-89 removed
1/**2 * Ratchets' baselines, and the rules that move them (GLOSSARY "Ratchet"):3 * a baseline per (ratchet, territory), recorded at landing and lowered by a4 * landing with no one asking; an answer that raises one is refused, unless5 * it asks a decider to raise it; the only way up is a `RaiseRatchet`6 * decision a decider accepts. Pure: the counts come from7 * `@repo/checks/kinds/ratchet`'s `measure`, and the baselines live in the8 * Project DO's `ratchets` rows (no suppressions file in the tree; FE §8.4 B3).4 * landing with no one asking; the only way up is a `RaiseRatchet` decision a5 * decider accepts. Pure: the counts come from `@repo/checks/kinds/ratchet`'s6 * `measure`, an answer's counts are judged against these baselines there7 * (`judgeRatchets`, which `<cli> check` judges with too), and the baselines8 * live in the Project DO's `ratchets` rows (no suppressions file in the9 * tree; FE §8.4 B3).10 */10import type { RatchetCount } from "@repo/checks/kinds/ratchet";11import { DecisionSubject } from "@repo/protocol/domain/decision";11import { sameRatchet } from "@repo/checks/kinds/ratchet";12import type {13 RaiseRatchet,14 RatchetCount,15 RatchetKey,16} from "@repo/checks/kinds/ratchet";17import type { Choice } from "@repo/protocol/domain/decision";13import type { AskId, LandedSha, RatchetName } from "@repo/protocol/ids";14import { Weakened } from "@repo/protocol/refusal";18import type { LandedSha, RatchetName } from "@repo/protocol/ids";19import { Array, Option } from "effect";2021/** A ratchet's baseline in one territory, and the landed SHA that set it. */22export interface RatchetBaseline {
2 unmodified lines
25 readonly count: number;26 readonly setAt: LandedSha;27}2825/** An answer asking a decider to raise one ratchet in one territory, and why. */26export interface RaiseRequest {27 readonly ratchet: RatchetName;28 readonly territory: string;29 readonly reason: string;30}3132/** The decision a raise waits on. */33export type RaiseRatchet = Extract<DecisionSubject, { _tag: "RaiseRatchet" }>;3429/** A baseline a landing lowered, from what to what. */30export interface Lowered {31 readonly ratchet: RatchetName;32 readonly territory: string;33 readonly before: number;34 readonly after: number;35}3643/** What judging an answer's counts gives: its refusals, and the raises it waits on. */44export interface RatchetJudgement {45 readonly refusals: readonly Weakened[];46 readonly decisions: readonly RaiseRatchet[];47}4837/** The baselines after a landing, and the ones it lowered. */38export interface BaselinesAfterLanding {39 readonly baselines: readonly RatchetBaseline[];40 readonly lowered: readonly Lowered[];41}4255interface Keyed {56 readonly ratchet: RatchetName;57 readonly territory: string;58}5960/** Whether two rows name one ratchet in one territory. */61const sameRatchet =62 (one: Keyed) =>63 (other: Keyed): boolean =>64 one.ratchet === other.ratchet && one.territory === other.territory;6566const baselineOf = (baselines: readonly RatchetBaseline[], key: Keyed) =>43const baselineOf = (baselines: readonly RatchetBaseline[], key: RatchetKey) =>44 Array.findFirst(baselines, sameRatchet(key));4546/**70 * Judges an answer's counts against the baselines. A count at or under its71 * baseline passes; one over it is refused with `Weakened{ratchet}`, unless72 * the answer asks to raise that ratchet in that territory: then it is not73 * refused, and waits on a `RaiseRatchet` decision instead. A ratchet with no74 * baseline yet is not judged (its first landing sets it).75 */76export const judgeRatchets = (input: {77 readonly baselines: readonly RatchetBaseline[];78 readonly measured: readonly RatchetCount[];79 readonly ask: AskId;80 readonly raises: readonly RaiseRequest[];81}): RatchetJudgement => {82 const raised = input.measured.flatMap((measured) =>83 Option.match(baselineOf(input.baselines, measured), {84 onNone: () => [],85 onSome: (held) =>86 measured.count > held.count87 ? [88 {89 after: measured.count,90 asked: input.raises.some(sameRatchet(measured)),91 before: held.count,92 ratchet: measured.ratchet,93 territory: measured.territory,94 },95 ]96 : [],97 })98 );99100 return {101 decisions: raised102 .filter(({ asked }) => asked)103 .map(({ after, before, ratchet, territory }) =>104 DecisionSubject.cases.RaiseRatchet.make({105 after,106 ask: input.ask,107 before,108 ratchet,109 territory,110 })111 ),112 refusals: raised113 .filter(({ asked }) => !asked)114 .map(115 ({ after, before, ratchet, territory }) =>116 new Weakened({ weakening: { after, before, ratchet, territory } })117 ),118 };119};120121/**47 * The baselines after a landing measured `measured` at `landed`: each count48 * under its baseline lowers it (and is named in `lowered`), a ratchet with no49 * baseline yet takes its count, and nothing else moves. A landing never50 * raises a baseline: an accepted `RaiseRatchet` already set it.
82 unmodified lines
modified:packages/project/test/ratchets.test.ts+5 added-104 removed
1import { describe, expect, it } from "@effect/vitest";2import type { RatchetCount } from "@repo/checks/kinds/ratchet";2import { judgeRatchets } from "@repo/checks/kinds/ratchet";3import type { RaiseRatchet, RatchetCount } from "@repo/checks/kinds/ratchet";4import type { RaiseRequest } from "@repo/gate/escapes";5import { Choice, DecisionSubject } from "@repo/protocol/domain/decision";6import { AskId, LandedSha, RatchetName } from "@repo/protocol/ids";5import { Weakened } from "@repo/protocol/refusal";7import { Arbitrary, Array, Effect, Option, Result, Schema } from "effect";88import { afterLanding, decideRaise, judgeRatchets } from "../src/ratchets.ts";9import type {10 RaiseRatchet,11 RaiseRequest,12 RatchetBaseline,13} from "../src/ratchets.ts";9import { afterLanding, decideRaise } from "../src/ratchets.ts";10import type { RatchetBaseline } from "../src/ratchets.ts";1112const hex = (n: number) => n.toString(16).padStart(40, "0");1314const shaAt = (step: number) => LandedSha.make(hex(0x1_00_00 + step));
16 unmodified lines
31 ratchet: noExplicitAny,32 territory: parser,33});3438const raising: RaiseRequest = {39 ratchet: noExplicitAny,40 reason: "the parser's one cast, until the date types land",41 territory: parser,42};4344const wire = (refusals: readonly Weakened[]) =>45 refusals.map((refusal) => Schema.encodeSync(Weakened)(refusal));4635const raiseTo = (after: number): RaiseRatchet =>36 DecisionSubject.cases.RaiseRatchet.make({37 after,38 ask,
1 unmodified line
40 ratchet: noExplicitAny,41 territory: parser,42 });4356describe(judgeRatchets, () => {57 it("refuses an answer that raises a ratchet with Weakened", () => {58 const { decisions, refusals } = judgeRatchets({59 ask,60 baselines: [baseline(14)],61 measured: [measuring(15)],62 raises: [],63 });6465 expect(decisions).toStrictEqual([]);66 expect(wire(refusals)).toStrictEqual(67 wire([68 new Weakened({69 weakening: {70 after: 15,71 before: 14,72 ratchet: noExplicitAny,73 territory: parser,74 },75 }),76 ])77 );78 });7980 it.each([14, 12, 0])("lets an answer through at %i", (count) => {81 expect(82 judgeRatchets({83 ask,84 baselines: [baseline(14)],85 measured: [measuring(count)],86 raises: [],87 })88 ).toStrictEqual({ decisions: [], refusals: [] });89 });9091 it("turns an asked-for raise into one RaiseRatchet decision, not a refusal", () => {92 expect(93 judgeRatchets({94 ask,95 baselines: [baseline(14)],96 measured: [measuring(15)],97 raises: [raising],98 })99 ).toStrictEqual({ decisions: [raiseTo(15)], refusals: [] });100 });101102 it("refuses a raise asked for in another territory", () => {103 const { decisions, refusals } = judgeRatchets({104 ask,105 baselines: [baseline(14)],106 measured: [measuring(15)],107 raises: [{ ...raising, territory: "packages/lexer" }],108 });109110 expect(decisions).toStrictEqual([]);111 expect(refusals.map(({ weakening }) => weakening)).toStrictEqual([112 { after: 15, before: 14, ratchet: noExplicitAny, territory: parser },113 ]);114 });115116 it("judges nothing a ratchet has no baseline for yet", () => {117 expect(118 judgeRatchets({119 ask,120 baselines: [],121 measured: [measuring(15)],122 raises: [],123 })124 ).toStrictEqual({ decisions: [], refusals: [] });125 });126127 it("judges each territory against its own baseline", () => {128 const lexer = "packages/lexer";129130 const { refusals } = judgeRatchets({131 ask,132 baselines: [baseline(14), { ...baseline(2), territory: lexer }],133 measured: [measuring(14), { ...measuring(3), territory: lexer }],134 raises: [],135 });136137 expect(refusals.map(({ weakening }) => weakening)).toStrictEqual([138 { after: 3, before: 2, ratchet: noExplicitAny, territory: lexer },139 ]);140 });141});14244describe(afterLanding, () => {45 it("lowers a baseline to a landing's lower count, by itself", () => {46 expect(47 afterLanding([baseline(14)], [measuring(12)], shaAt(1))
398 unmodified lines
modified:packages/protocol/src/annotations.ts+7 added-1 removed
49 unmodified lines
50 "protocol/NeedsApproval",51 { defaultValue: () => false }52);5354/** The CLI command it becomes: its name, and the payload fields taken in order. */54/**55 * The CLI command it becomes: its name, the payload fields taken in order,56 * and those of them that were flags until now (`formerFlags`): each still57 * parses as a flag of its own name, hidden from help, so a script that types58 * it keeps working for a release. Drop a name from `formerFlags` to end that.59 */60export const Cli = Context.Reference<{61 readonly name?: string;62 readonly positional?: readonly string[];63 readonly formerFlags?: readonly string[];64}>("protocol/Cli", { defaultValue: () => ({}) });6566/** Every surface a contract can be served on. */67export const SurfaceName = Schema.Literals(["rpc", "mcp", "cli", "web"]);
8 unmodified lines
modified:packages/protocol/src/cli.ts+62 added-8 removed
1// Ported from joelhooks/rat-stack@fba26d8 `packages/capability/src/to-command.ts`2// (MIT, LICENSES/rat-stack.MIT.txt). Changes are listed in PROVENANCE.md.3import {4 Array,5 Config,6 Context,7 Effect,8 Option,9 Predicate,
286 unmodified lines
296 FieldSpec["kind"],297 (name: string, field: Plain, spec: FieldSpec) => Argument.Argument<unknown>298>;299300/**301 * An argument that was a flag until now, left out: none yet. The parser302 * takes it so, since the flag it was may still give its value, and the303 * handler says if neither did (`MissingValue`). Unlike `Argument.optional`,304 * a fallback leaves help showing the argument as required.305 */306const leftOutForNow = (307 argument: Argument.Argument<unknown>308): Argument.Argument<unknown> =>309 argument.pipe(310 Argument.map(Option.some),311 Argument.withFallbackConfig(Config.succeed(Option.none())),312 Argument.map(Option.getOrUndefined)313 );314315const argumentFor = (316 name: string,317 field: Plain,302 fallback: string | undefined318 fallback: string | undefined,319 wasFlag: boolean320): Argument.Argument<unknown> => {321 const spec = describe(field);322 const base = argumentBuilders[spec.kind](name, field, spec);323 const help = helpOf(spec, fallback);324325 const described =326 help === undefined ? base : base.pipe(Argument.withDescription(help));327311 return spec.optional || fallback !== undefined312 ? described.pipe(Argument.optional, Argument.map(Option.getOrUndefined))313 : described;328 if (spec.optional || fallback !== undefined) {329 return described.pipe(330 Argument.optional,331 Argument.map(Option.getOrUndefined)332 );333 }334335 return wasFlag ? leftOutForNow(described) : described;336};337338/**339 * The flag a positional field was until now (`Cli`'s `formerFlags`): it340 * still parses, checked by the field's schema, but help leaves it out and341 * using it prints nothing more.342 */343const formerFlagFor = (name: string, field: Plain): Flag.Flag<unknown> => {344 const spec = describe(field);345346 return flagBuilders[spec.kind](name, field, spec).pipe(347 Flag.withHidden,348 Flag.optional,349 Flag.map(Option.getOrUndefined)350 );351};352353/**354 * The flags a projected command takes beside its payload's: `--json`355 * always, `--yes` when a person approves it, and `--dry-run` unless it only356 * reads.357 */
79 unmodified lines
437) => {438 const cli = Context.get(rpc.annotations, Cli);439 const command = commandName(rpc);440 const positional = new Set(cli.positional);441442 const wasFlag = new Set(443 cli.formerFlags?.filter((name) => positional.has(name))444 );445446 const approval = Context.get(rpc.annotations, NeedsApproval);447 const readOnly = Context.get(rpc.annotations, ReadOnly);448 const filled = options.defaults?.fields ?? {};449 const fields = fieldsOf(rpc.payloadSchema);
6 unmodified lines
456 string,457 Flag.Flag<unknown> | Argument.Argument<unknown>458 > = {};459460 const former: Record<string, Flag.Flag<unknown>> = {};461462 for (const [name, field] of fields) {463 const fallback = required.includes(name) ? filled[name] : undefined;464465 payload[name] = positional.has(name)422 ? argumentFor(name, field, fallback)466 ? argumentFor(name, field, fallback, wasFlag.has(name))467 : flagFor(name, field, fallback);468469 if (wasFlag.has(name)) {470 former[name] = formerFlagFor(name, field);471 }472 }473474 const decodePayload = Schema.decodeUnknownEffect(rpc.payloadSchema);475 const encodePayload = Schema.encodeUnknownEffect(rpc.payloadSchema);
37 unmodified lines
513 });514515 return Command.make(516 commandPath(rpc).at(-1) ?? rpc._tag,469 { control: controls(approval, readOnly), payload },470 ({ control, payload: given }) =>517 { control: controls(approval, readOnly), former, payload },518 ({ control, former: formerly, payload: given }) =>519 Effect.gen(function* () {520 const json = control.json === true;521 const dryRun = control.dryRun === true;522523 if (approval && control.yes !== true && !dryRun) {524 return yield* new ApprovalNeeded({ command });525 }526527 // An argument left out takes the value its former flag gave.479 const decoded = yield* complete(Object.entries(given));528 const decoded = yield* complete(529 Object.entries(given).map(530 ([name, value]) => [name, value ?? formerly[name]] as const531 )532 );533534 const output = yield* options.output;535536 if (dryRun) {537 const encoded = yield* Effect.orDie(encodePayload(decoded));
103 unmodified lines
modified:packages/protocol/src/contracts.ts+4 added-4 removed
258 unmodified lines
259 .annotate(ReadOnly, true)260 .annotate(Idempotent, true)261 .annotate(Destructive, false)262 .annotate(NeedsApproval, false)263 .annotate(Cli, { name: "verdict" })263 .annotate(Cli, { formerFlags: ["ask"], name: "verdict", positional: ["ask"] })264 .annotate(Surfaces, servedOn.verdict) {}265266export class LandingOf extends Rpc.make("landing", {267 error: Schema.Union([UnknownProject, UnknownCommit]),
298 unmodified lines
566 .annotate(ReadOnly, false)567 .annotate(Idempotent, true)568 .annotate(Destructive, false)569 .annotate(NeedsApproval, false)570 .annotate(Cli, { name: "release" })570 .annotate(Cli, { formerFlags: ["ask"], name: "release", positional: ["ask"] })571 .annotate(Surfaces, servedOn.release) {}572573export class SubmitAnswer extends Rpc.make("submitAnswer", {574 error: Schema.Union([
27 unmodified lines
602 .annotate(ReadOnly, false)603 .annotate(Idempotent, true)604 .annotate(Destructive, false)605 .annotate(NeedsApproval, false)606 .annotate(Cli, { name: "submit" })606 .annotate(Cli, { formerFlags: ["ask"], name: "submit", positional: ["ask"] })607 .annotate(Surfaces, servedOn.submitAnswer) {}608609export class Finish extends Rpc.make("finish", {610 error: Schema.Union([
21 unmodified lines
632 .annotate(ReadOnly, false)633 .annotate(Idempotent, true)634 .annotate(Destructive, false)635 .annotate(NeedsApproval, true)636 .annotate(Cli, { name: "finish" })636 .annotate(Cli, { formerFlags: ["ask"], name: "finish", positional: ["ask"] })637 .annotate(Surfaces, servedOn.finish) {}638639export class Land extends Rpc.make("land", {640 error: Schema.Union([UnknownProject, NotDecider, StaleBase, RepoBusy]),
225 unmodified lines
modified:packages/protocol/test/contracts.test.ts+4 added-4 removed
75 unmodified lines
76 tag: "status",77 },78 {79 audience: "public",80 cli: "verdict",80 cli: "verdict <ask>",81 errors: ["UnknownProject", "UnknownAsk"],82 flags: "RI",83 on: "RMCW",84 tag: "verdict",
119 unmodified lines
204 tag: "claim",205 },206 {207 audience: "signedIn",208 cli: "release",208 cli: "release <ask>",209 errors: ["UnknownProject", "NotClaimed"],210 flags: "I",211 on: "RMC",212 tag: "release",213 },214 {215 audience: "signedIn",216 cli: "submit",216 cli: "submit <ask>",217 errors: [218 "UnknownProject",219 "NotClaimed",220 "ClaimLapsed",
10 unmodified lines
231 tag: "submitAnswer",232 },233 {234 audience: "decider",235 cli: "finish",235 cli: "finish <ask>",236 errors: [237 "UnknownProject",238 "NotDecider",239 "StaleBase",
282 unmodified lines
modified:plugins/myr/skills/myr/SKILL.md+5 added-5 removed
1 unmodified line
2name: myr3description: "Contribute to projects on Myr with the `myr` CLI: find an ask, claim it, check your answer locally, push it to your fork, and read the verdict. Use when a repo's remote is on Myr, or when a push was refused with a refusal such as OutOfScope or StaleBase."4metadata:5 managed-by: "myr"6 content-hash: "sha256:bd1f1c815649d83b48ca8dac25f0b3e9b98e54e3a5dd8edc3171261a75e065ca"6 content-hash: "sha256:5a87960d45b403f8c2b24f8975cdd1c86dd0f490f97d368875ffd7d7f073a6b3"7---8# Myr910Myr is a git platform where a change lands only by passing a typed gate. A project states each change it wants as an ask; you answer one with a commit pushed to your claim's fork, and the platform checks it and lands it, or answers with refusals that say what to do next.
29 unmodified lines
40| `myr decide` | `--choice` `--decision` `--note` `--project` `--json` `--yes` `--dry-run` | Take one decision from Today: accept, decline, adopt or revert. Runs only with `--yes`. |41| `myr env set <key>` | `--project` `--acknowledge-short` `--yes` `--dry-run` `--json` | Set a sensitive env item's value from stdin; nobody can read it back. Runs only with `--yes`. |42| `myr env shape` | `--project` `--json` | Show a project's env shape: the public schema of its environment variables, and who set each write-only value; never a value. Only reads. |43| `myr evidence <ref>` | `--project` `--json` | Show the log a failing lane left, by the logRef its verdict names, to the answer's own claimant and the project's deciders only; the last 256 KiB. Only reads. |44| `myr finish` | `--ask` `--base` `--head` `--project` `--requestId` `--json` `--yes` `--dry-run` | Finish a passing answer with a decider's own commits on top; they are checked again, and credited with Finished-by when it lands. Runs only with `--yes`. |44| `myr finish <ask>` | `--base` `--head` `--project` `--requestId` `--json` `--yes` `--dry-run` | Finish a passing answer with a decider's own commits on top; they are checked again, and credited with Finished-by when it lands. Runs only with `--yes`. |45| `myr fork` | `--project` `--json` `--dry-run` | Make the caller's working fork of a project, or return it if it exists. |46| `myr front` | `--kind` `--reserved` `--json` | List the open asks across every project, each saying whether the caller may take it; optionally of one kind, or held for newcomers or people. Only reads. |47| `myr hook <event>` | `--json` | Answer a harness hook (session-start, pre-tool-use, stop) with the gate's policy. Only reads. |48| `myr init` | `--project` `--import` `--branch` `--yes` `--dry-run` `--push` `--no-push` `--json` | Make this repo, or a public HTTPS repo, a project: find its checks, write its config and push. Runs only with `--yes`. |
4 unmodified lines
53| `myr logout` | `--profile` `--json` | Forget a platform's stored token. |54| `myr mcp` | | Serve the platform's tools over MCP on stdio. |55| `myr projects` | `--json` | List every project on the platform, with its posture and how many asks it has open. Only reads. |56| `myr propose` | `--files` `--project` `--sealed` `--territory` `--want` `--json` `--dry-run` | Propose an ask, optionally with a sealed answer; the proposal expires unless a decider accepts it. |57| `myr release` | `--ask` `--project` `--json` `--dry-run` | Release the caller's claim on an ask, so anyone may claim it again. |57| `myr release <ask>` | `--project` `--json` `--dry-run` | Release the caller's claim on an ask, so anyone may claim it again. |58| `myr schema <command>` | `--json` | Print the JSON Schema of a command's payload. Only reads. |59| `myr status` | `--project` `--json` | Show who the caller is, and their claims and answers, in one project or in every one. Only reads. |60| `myr submit` | `--ask` `--base` `--head` `--project` `--requestId` `--json` `--dry-run` | Offer the commit `head`, built on `base`, as an answer to a claimed ask; the receipt says it is being checked, and it lands if it passes. |60| `myr submit <ask>` | `--base` `--head` `--project` `--requestId` `--json` `--dry-run` | Offer the commit `head`, built on `base`, as an answer to a claimed ask; the receipt says it is being checked, and it lands if it passes. |61| `myr today` | `--project` `--json` | Show the caller's Today: the decisions to take, held to their budget, each with its evidence and a safe default. Only reads. |62| `myr verdict` | `--ask` `--head` `--project` `--json` | Show the verdict on an answer to an ask, for its latest head or the one named; held-back checks show one bit per area. Only reads. |62| `myr verdict <ask>` | `--head` `--project` `--json` | Show the verdict on an answer to an ask, for its latest head or the one named; held-back checks show one bit per area. Only reads. |63| `myr vouch` | `--handle` `--note` `--project` `--verdict` `--json` `--yes` `--dry-run` | Vouch for a person, or denounce them, by landing a line in the project's vouch file. Runs only with `--yes`. |64| `myr why <location>` | `--project` `--json` | Explain a line: the ask, the answer and the people that landed it. Only reads. |6566## MCP
38 unmodified lines
modified:skills/myr/SKILL.md+5 added-5 removed
1 unmodified line
2name: myr3description: "Contribute to projects on Myr with the `myr` CLI: find an ask, claim it, check your answer locally, push it to your fork, and read the verdict. Use when a repo's remote is on Myr, or when a push was refused with a refusal such as OutOfScope or StaleBase."4metadata:5 managed-by: "myr"6 content-hash: "sha256:bd1f1c815649d83b48ca8dac25f0b3e9b98e54e3a5dd8edc3171261a75e065ca"6 content-hash: "sha256:5a87960d45b403f8c2b24f8975cdd1c86dd0f490f97d368875ffd7d7f073a6b3"7---8# Myr910Myr is a git platform where a change lands only by passing a typed gate. A project states each change it wants as an ask; you answer one with a commit pushed to your claim's fork, and the platform checks it and lands it, or answers with refusals that say what to do next.
29 unmodified lines
40| `myr decide` | `--choice` `--decision` `--note` `--project` `--json` `--yes` `--dry-run` | Take one decision from Today: accept, decline, adopt or revert. Runs only with `--yes`. |41| `myr env set <key>` | `--project` `--acknowledge-short` `--yes` `--dry-run` `--json` | Set a sensitive env item's value from stdin; nobody can read it back. Runs only with `--yes`. |42| `myr env shape` | `--project` `--json` | Show a project's env shape: the public schema of its environment variables, and who set each write-only value; never a value. Only reads. |43| `myr evidence <ref>` | `--project` `--json` | Show the log a failing lane left, by the logRef its verdict names, to the answer's own claimant and the project's deciders only; the last 256 KiB. Only reads. |44| `myr finish` | `--ask` `--base` `--head` `--project` `--requestId` `--json` `--yes` `--dry-run` | Finish a passing answer with a decider's own commits on top; they are checked again, and credited with Finished-by when it lands. Runs only with `--yes`. |44| `myr finish <ask>` | `--base` `--head` `--project` `--requestId` `--json` `--yes` `--dry-run` | Finish a passing answer with a decider's own commits on top; they are checked again, and credited with Finished-by when it lands. Runs only with `--yes`. |45| `myr fork` | `--project` `--json` `--dry-run` | Make the caller's working fork of a project, or return it if it exists. |46| `myr front` | `--kind` `--reserved` `--json` | List the open asks across every project, each saying whether the caller may take it; optionally of one kind, or held for newcomers or people. Only reads. |47| `myr hook <event>` | `--json` | Answer a harness hook (session-start, pre-tool-use, stop) with the gate's policy. Only reads. |48| `myr init` | `--project` `--import` `--branch` `--yes` `--dry-run` `--push` `--no-push` `--json` | Make this repo, or a public HTTPS repo, a project: find its checks, write its config and push. Runs only with `--yes`. |
4 unmodified lines
53| `myr logout` | `--profile` `--json` | Forget a platform's stored token. |54| `myr mcp` | | Serve the platform's tools over MCP on stdio. |55| `myr projects` | `--json` | List every project on the platform, with its posture and how many asks it has open. Only reads. |56| `myr propose` | `--files` `--project` `--sealed` `--territory` `--want` `--json` `--dry-run` | Propose an ask, optionally with a sealed answer; the proposal expires unless a decider accepts it. |57| `myr release` | `--ask` `--project` `--json` `--dry-run` | Release the caller's claim on an ask, so anyone may claim it again. |57| `myr release <ask>` | `--project` `--json` `--dry-run` | Release the caller's claim on an ask, so anyone may claim it again. |58| `myr schema <command>` | `--json` | Print the JSON Schema of a command's payload. Only reads. |59| `myr status` | `--project` `--json` | Show who the caller is, and their claims and answers, in one project or in every one. Only reads. |60| `myr submit` | `--ask` `--base` `--head` `--project` `--requestId` `--json` `--dry-run` | Offer the commit `head`, built on `base`, as an answer to a claimed ask; the receipt says it is being checked, and it lands if it passes. |60| `myr submit <ask>` | `--base` `--head` `--project` `--requestId` `--json` `--dry-run` | Offer the commit `head`, built on `base`, as an answer to a claimed ask; the receipt says it is being checked, and it lands if it passes. |61| `myr today` | `--project` `--json` | Show the caller's Today: the decisions to take, held to their budget, each with its evidence and a safe default. Only reads. |62| `myr verdict` | `--ask` `--head` `--project` `--json` | Show the verdict on an answer to an ask, for its latest head or the one named; held-back checks show one bit per area. Only reads. |62| `myr verdict <ask>` | `--head` `--project` `--json` | Show the verdict on an answer to an ask, for its latest head or the one named; held-back checks show one bit per area. Only reads. |63| `myr vouch` | `--handle` `--note` `--project` `--verdict` `--json` `--yes` `--dry-run` | Vouch for a person, or denounce them, by landing a line in the project's vouch file. Runs only with `--yes`. |64| `myr why <location>` | `--project` `--json` | Explain a line: the ask, the answer and the people that landed it. Only reads. |6566## MCP
38 unmodified lines
modified:PROVENANCE.md+1 added-1 removed
5 unmodified lines
67| Our file | Origin | Licence | Our changes |8| --- | --- | --- | --- |9| `tools/oxlint/anti-slop/` | [dmmulroy/anti-slop](https://github.com/dmmulroy/anti-slop) at `c44ef22` | MIT, `LICENSES/anti-slop.MIT.txt` | None; vendored by its own install script. See `UPSTREAM.md` there. |10| `packages/protocol/src/cli.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `packages/capability/src/to-command.ts` l.14–247 at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Projects an `Rpc` whose payload is a struct (or an empty record), not a capability, and calls it through an `RpcClient`, named and given positionals by the `Cli` annotation; `toCommands` projects a whole group by its `Surfaces` annotation. `--json` is always offered; `--yes` is restored from our own `NeedsApproval` (without it the command fails with `ApprovalNeeded` before any call); `--dry-run` is offered unless `ReadOnly` (it prints the encoded payload and calls nothing). The command prints through a `CommandOutput` port, never the console: a refusal (or the refusals a success carries, such as a refused receipt) goes to it once and the command fails with `Reported`. Defaults may fill required fields left out (the repo's project). String flags check their value with the field's schema, so the parser refuses a malformed value by its flag. The description comes from the `Description` annotation. Dropped: the reserved-field guards and the `as never` casts. |10| `packages/protocol/src/cli.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `packages/capability/src/to-command.ts` l.14–247 at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Projects an `Rpc` whose payload is a struct (or an empty record), not a capability, and calls it through an `RpcClient`, named and given positionals by the `Cli` annotation (a positional it lists in `formerFlags` still parses as its former flag, hidden from help, while help shows the argument as required); `toCommands` projects a whole group by its `Surfaces` annotation. `--json` is always offered; `--yes` is restored from our own `NeedsApproval` (without it the command fails with `ApprovalNeeded` before any call); `--dry-run` is offered unless `ReadOnly` (it prints the encoded payload and calls nothing). The command prints through a `CommandOutput` port, never the console: a refusal (or the refusals a success carries, such as a refused receipt) goes to it once and the command fails with `Reported`. Defaults may fill required fields left out (the repo's project). String flags check their value with the field's schema, so the parser refuses a malformed value by its flag. The description comes from the `Description` annotation. Dropped: the reserved-field guards and the `as never` casts. |11| `packages/protocol/src/mcp.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `packages/capability/src/to-toolkit.ts` l.18–146 at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Projects an `RpcGroup`'s Rpcs, not capabilities: the payload, success and error schemas become the tool's. Handlers call each Rpc through an `RpcClient`, passing the payload alone. The description comes from the `Description` annotation. Hint annotations restored from our own `ReadOnly`, `Idempotent` and `Destructive` annotations, with `OpenWorld` false; a `NeedsApproval` contract's description gains "Asks a person first." Added `listTools`, the tools as `tools/list` shows them, and `toJsonSchema`, which derives a schema the way `McpServer` does (top-level `$ref` inlined, definitions under `$defs`). Dropped: the empty-input dynamic tool, upstream's approval flow and the file-wide diagnostics escape. |12| `tools/oxlint/fence/rules/debt-ledger.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `scripts/oxlint-plugin-debt-ledger.ts` at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Five kinds, one per `debt.baseline.json` key: the TypeScript kind is split by directive into `@ts-expect-error`, `@ts-ignore` and `@ts-nocheck`. A named export, registered in the `fence` plugin rather than its own, and run only through `oxlint.debt.config.ts`. `eslint-disable` directives count as `oxlint-disable`, since oxlint honours them. A directive counts only where a comment's line starts, as oxlint, eslint and tsc read it, except `@effect-diagnostics`, which the Effect language service reads anywhere. Every report sits at the file's first offset, where no disable comment can hide it, and carries its line (and column) in the message. An empty reason (`-- ` with nothing after) leaves the directive text without the ` --`. The JSON message `{directive, kind, reason?}` and the reason after ` -- ` are upstream's. |13| `tools/oxlint/fence/rules/no-module-level-mutable-state.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `scripts/oxlint-plugin-patterns.ts` l.28–43 and l.621–677 at `fba26d8` | MIT, `LICENSES/rat-stack.MIT.txt` | Only this rule is ported from that file. A named export in the `fence` plugin. `workspacePath` reads the path string alone: it strips oxlint's `cwd`, then finds the whole `(apps\|packages)/<name>/src/` shape anywhere, so a fixture tree counts and folders above the checkout don't; no `node:path` import and no `nodeBuiltinImport` escape. `workspacePath` is exported, for `no-effect-sleep-in-project`. The `.svelte` exclusion is dropped, and `declare let`/`declare var` is skipped. The scope check, `isModuleScopedVar`, the `moduleState` message and the description are upstream's. See `tools/oxlint/fence/UPSTREAM.md`. |14| `examples/burrow/tools/oxlint/burrow/rules/no-module-level-mutable-state.ts` | [joelhooks/rat-stack](https://github.com/joelhooks/rat-stack) `scripts/oxlint-plugin-patterns.ts` l.28–43 and l.621–677 at `fba26d8`, copied from `tools/oxlint/fence/rules/no-module-level-mutable-state.ts` | MIT, `examples/burrow/tools/oxlint/burrow/LICENSE-rat-stack.txt` (a copy of `LICENSES/rat-stack.MIT.txt`, so the example carries its own notice) | A copy of the fence's port, for the fictional example `burrow`. Its header points at burrow's own licence copy and `UPSTREAM.md`. It is registered in burrow's `burrow` plugin and set to `warn` by burrow's config. Everything else is as in the fence's row. See `examples/burrow/tools/oxlint/burrow/UPSTREAM.md`. |
33 unmodified lines