Skip to content
Myr

Keep a local check's ChecksFailed from pointing at evidence

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

- The CLI's local check raises ChecksFailed with a `local:<lane>` ref, a log kept nowhere; the new reason told its reader to fetch it with `evidence`. A local lane now reads "the <lane> checks failed on this commit; run <next> to see the failure". - ChecksFailed gains `localRef(lane)` and `isLocal(logRef)` beside `withheld`, so the local check and the renderer share one prefix. No field, tag, `retryable` or `next` changes. - The answer's reason names `next`'s command itself, and says the answerer and the project's deciders read the log with `evidence`, as `evidenceOf` lets in. - Test: render.test.ts pins the local lane's lines and that they name no `evidence`; the answer case pins the interpolated command.

authored by oscabriel · committed by oscabriel · parent d1bcd43 · Browse files · 5 files+53 added−10 removed
This commit

State

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

Diff stats

5 files+53 added−10 removed

  • tests:+24 added−5 removed
  • other:+29 added−5 removed

5 files+53 added−10 removed

modified:apps/cli/src/local/check.ts+7 added-1 removed
789 unmodified lines
790791 const failed = run.lanes.flatMap(({ command, lane, result }) =>792 result === "passed"793 ? []794 : [new ChecksFailed({ lane, logRef: `local:${lane}`, next: command })]794 : [795 new ChecksFailed({796 lane,797 logRef: ChecksFailed.localRef(lane),798 next: command,799 }),800 ]801 );802803 for (const evidence of run.evidence) {804 if (evidence.signature !== undefined) {
65 unmodified lines
modified:apps/cli/test/local/check.test.ts+1 added-1 removed
475 unmodified lines
476 ok: false,477 refusals: [478 new ChecksFailed({479 lane: "bad",480 logRef: "local:bad",480 logRef: ChecksFailed.localRef("bad"),481 next: "false",482 }),483 ],484 v: 1,
379 unmodified lines
modified:packages/protocol/src/refusal.ts+11 added
207 unmodified lines
208}) {}209210// Checks211212const LOCAL = "local:";213214/** A check failed; `next` is the command that reproduces it. */215export class ChecksFailed extends Schema.TaggedError<ChecksFailed>()(216 "ChecksFailed",217 {
6 unmodified lines
224 * The `logRef` of a lane whose log held a stored write-only value: the log225 * was never kept, and nothing names the item.226 */227 static readonly withheld = "withheld";228229 /**230 * The `logRef` of a lane the CLI's local check ran on the caller's machine:231 * its log was kept nowhere, so `evidence` has nothing to read.232 */233 static readonly localRef = (lane: string) => `${LOCAL}${lane}`;234235 /** Whether `logRef` names a lane the local check ran. */236 static readonly isLocal = (logRef: string) => logRef.startsWith(LOCAL);237}238239/** A held-back check failed; only its area and suite are disclosed. */240export class HeldBackFailed extends Schema.TaggedError<HeldBackFailed>()(
305 unmodified lines
modified:packages/protocol/src/render.ts+11 added-4 removed
54 unmodified lines
55 AskFull: ({ ask }) => `someone else holds the claim on ${ask}`,56 AttemptsExhausted: ({ area, resetsAt }) =>57 `no attempts left on ${area} until ${DateTime.formatIso(resetsAt)}`,58 CapReached: capReason,59 ChecksFailed: ({ lane, logRef }) =>60 logRef === ChecksFailed.withheld61 ? `the ${lane} checks failed; their log was withheld`62 : `the ${lane} checks failed on the answer; run next in a clone of the fork to see the failure; the log is kept as ${logRef}, for the answer's claimant and the project's deciders to read with ${Brand.cli} evidence`,59 ChecksFailed: ({ lane, logRef, next }) => {60 if (logRef === ChecksFailed.withheld) {61 return `the ${lane} checks failed; their log was withheld`;62 }6364 // `evidence` lets in the answerer and the project's deciders alone; the65 // local check keeps no log for it to read.66 return ChecksFailed.isLocal(logRef)67 ? `the ${lane} checks failed on this commit; run ${next} to see the failure`68 : `the ${lane} checks failed on the answer; run ${next} in a clone of the fork to see the failure; the log is kept as ${logRef}, which the answerer and the project's deciders read with ${Brand.cli} evidence`;69 },70 ClaimLapsed: ({ ask }) => `your claim on ${ask} lapsed`,71 DecisionClosed: ({ decision }) =>72 `${decision} was already decided, or expired to its default`,73 Denounced: () =>
132 unmodified lines
modified:packages/protocol/test/render.test.ts+23 added-4 removed
399 unmodified lines
400 ]);401 });402403 // The lane's command reproduces the failure in a clone of the fork; the log404 // is read through `evidence`, which lets in the answer's claimant and the405 // project's deciders alone.406 it("says the checks failed on the answer, how to see it, and where the log is kept", () => {404 // is read through `evidence`, which lets in the answerer and the project's405 // deciders alone.406 it("says the checks failed on the answer, the command that shows it, and where the log is kept", () => {407 const logRef = "datekit/push-2222222/unit#1";408409 expect(410 explain([new ChecksFailed({ lane: "unit", logRef, next: "bun test" })])411 ).toStrictEqual([412 `ChecksFailed: the unit checks failed on the answer; run next in a clone of the fork to see the failure; the log is kept as ${logRef}, for the answer's claimant and the project's deciders to read with ${Brand.cli} evidence`,412 `ChecksFailed: the unit checks failed on the answer; run bun test in a clone of the fork to see the failure; the log is kept as ${logRef}, which the answerer and the project's deciders read with ${Brand.cli} evidence`,413 " next: bun test",414 " retryable: no",415 ]);416 });417418 // The CLI's local check ran the lane on this machine: no log was kept, so419 // nothing points at `evidence`.420 it("says a lane the local check ran failed here, with no kept log to read", () => {421 const lines = explain([422 new ChecksFailed({423 lane: "unit",424 logRef: ChecksFailed.localRef("unit"),425 next: "bun test",426 }),427 ]);428429 expect(lines).toStrictEqual([430 "ChecksFailed: the unit checks failed on this commit; run bun test to see the failure",431 " next: bun test",432 " retryable: no",433 ]);434 expect(lines.join("\n")).not.toContain("evidence");435 });436437 // `today` across every project raises it too, so it names no project.438 it("tells a caller they are not a decider without naming a project", () => {439 const [line] = explain([new NotDecider({})]);440
65 unmodified lines