Skip to content
Myr

Run the seed's git through one helper, read datekit's public lanes from its config, and fix the finish rubric's credit point

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

Review of 608 against its issue and AGENTS.md: - scripts/lib/seed.ts: `gitAs` now runs through `runGit` (its credential settings ahead of the command) and `gitOk` through `okOutput`, so the spawn-and-collect code exists once; `pushInitial` is `pushCommit` to main with the message it always had (git ends a message with one newline either way, so main's first commit is the same commit). The layer step's result helper is named `reported`, since it also reports `already`. - packages/config/test/seed-layer.test.ts: the known-bad case runs every lane datekit's project.ts declares, under `sh -c` as the Checker does, instead of a copy of the unit lane's command that could drift from it. - layers/maintainers/.agents/maintainers/finish.md: point 7 told a maintainer to add `Finished-by:` to a finish commit; the platform writes credit trailers when a finish lands (packages/project landing.ts), so the rubric now says to commit on top and never write credit trailers by hand. - bun run fix, bun run verify green (platform entry 1,598,741 of 1,665,000); `bun scripts/seed.ts --world node` prints `Layer datekit--maintainers: done`.

authored by oscabriel · committed by oscabriel · parent 019f456 · Browse files · 3 files+74 added−105 removed
This commit

State

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

Diff stats

3 files+74 added−105 removed

  • tests:+26 added−8 removed
  • other:+48 added−97 removed

3 files+74 added−105 removed

modified:examples/datekit/layers/maintainers/.agents/maintainers/finish.md+1 added-1 removed
modified:packages/config/test/seed-layer.test.ts+26 added-8 removed
200 unmodified lines
201202 return { layer, manifest, plan, policy };203});204205/** The lanes datekit's `project.ts` runs on every answer: the public checks, by name. */206const publicLanes = Effect.gen(function* () {207 const { run: block } = yield* Schema.decodeUnknownEffect(208 Schema.Struct({209 run: Schema.Struct({210 checks: Schema.Record(Schema.String, Schema.String),211 }),212 })213 )(yield* defaultExportOf(yield* exampleFile(`${config}/project.ts`)));214215 return Object.entries(block.checks);216});217218/** A heading's anchor, as a README link names it: `## Format patterns` is `format-patterns`. */219const anchorOf = (heading: string) =>220 heading221 .toLowerCase()
199 unmodified lines
421 60_000422 );423424 it.live(412 "fail in their area on each known-bad tree, which the public tests pass",425 "fail in their area on each known-bad tree, which every public lane passes",426 () =>427 Effect.gen(function* () {428 const { layer } = yield* datekit;429 const lanes = yield* publicLanes;430431 const runs = yield* Effect.forEach(432 layer.knownBad,433 ({ branch, files }) =>
6 unmodified lines
440 "test",441 `./checks/held-back/${area}`,442 ]);443430 const unit = yield* run(bad, "bun", [431 "test",432 "--path-ignore-patterns=test/asks/**",433 ]);444 // Each lane as the Checker runs it: its command under `sh -c`.445 const failedLanes = yield* Effect.filter(lanes, ([, command]) =>446 Effect.map(447 run(bad, "sh", ["-c", command]),448 ({ code }) => code !== 0449 )450 );451452 return {453 area,454 failedLanes: failedLanes.map(([lane]) => lane),455 heldBackFailed:456 held.code !== 0 && /\(fail\)/u.test(held.output),439 publicPassed: unit.code === 0,457 };458 })459 );460461 expect(lanes.map(([lane]) => lane)).toStrictEqual(["unit"]);462 expect(runs).toStrictEqual([445 { area: "export", heldBackFailed: true, publicPassed: true },446 { area: "parser", heldBackFailed: true, publicPassed: true },463 { area: "export", failedLanes: [], heldBackFailed: true },464 { area: "parser", failedLanes: [], heldBackFailed: true },465 ]);466 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),467 60_000468 );
150 unmodified lines
modified:scripts/lib/seed.ts+47 added-96 removed
244 unmodified lines
245/** All a byte stream says, as text. */246const streamText = <E>(bytes: Stream.Stream<Uint8Array, E>) =>247 bytes.pipe(Stream.decodeText(), Stream.mkString);248249/** git with `args` in `cwd` under `env`: how it ended, and what it printed. */249/**250 * git with `args` in `cwd` under `env`, after the `-c` settings in251 * `settings`: how it ended, and what it printed.252 */253const runGit = (254 spawner: ChildProcessSpawner.ChildProcessSpawner["Service"],255 cwd: string,256 args: readonly string[],254 env: Readonly<Record<string, string>>257 env: Readonly<Record<string, string>>,258 settings: readonly string[] = []259) =>260 Effect.scoped(261 Effect.gen(function* () {262 const child = yield* spawner.spawn(259 ChildProcess.make("git", args, { cwd, env, extendEnv: true })263 ChildProcess.make("git", [...settings, ...args], {264 cwd,265 env,266 extendEnv: true,267 })268 );269270 const [stdout, stderr, code] = yield* Effect.all(271 [streamText(child.stdout), streamText(child.stderr), child.exitCode],
548 unmodified lines
820 )821 )822 );823816 const pushed = (result: StepResult) =>824 const reported = (result: StepResult) =>825 SeedStep.cases.Layer.make({ result, target: layer.repo });826827 if (refs.has(MAIN_REF)) {820 return pushed("already");828 return reported("already");829 }830831 yield* Effect.forEach(832 layer.knownBad.filter(
27 unmodified lines
860 ref: MAIN_REF,861 repo: layer.repo,862 });863856 return pushed("done");864 return reported("done");865 });866867/**868 * Seeds one project: makes it and pushes main's first commit as the
173 unmodified lines
1042 ? Effect.fail(missing(lacking))1043 : Effect.void;1044 };10451038 /** git as `as`, in `cwd`: how it ended, and what it printed. */1046 /**1047 * git as `as`, in `cwd`, with their token for its credential helper1048 * and no other helper: how it ended, and what it printed.1049 */1050 const gitAs = (as: Handle, cwd: string, args: readonly string[]) =>1040 Effect.gen(function* () {1041 const token = yield* Effect.fromOption(tokenOf(as)).pipe(1051 Effect.flatMap(1052 Effect.fromOption(tokenOf(as)).pipe(1053 Effect.mapError(() => missing([as]))1043 );1054 ),1055 (token) =>1056 runGit(spawner, cwd, args, gitEnv(as, token), [1057 "-c",1058 "credential.helper=",1059 "-c",1060 `credential.helper=${helperFor(as)}`,1061 ])1062 );10631045 return yield* Effect.scoped(1046 Effect.gen(function* () {1047 const child = yield* spawner.spawn(1048 ChildProcess.make(1049 "git",1050 [1051 "-c",1052 "credential.helper=",1053 "-c",1054 `credential.helper=${helperFor(as)}`,1055 ...args,1056 ],1057 { cwd, env: gitEnv(as, token), extendEnv: true }1058 )1059 );10601061 const [stdout, stderr, code] = yield* Effect.all(1062 [1063 streamText(child.stdout),1064 streamText(child.stderr),1065 child.exitCode,1066 ],1067 { concurrency: "unbounded" }1068 );10691070 return { code: Number(code), stderr, stdout };1071 })1072 ).pipe(1073 Effect.mapError((error) =>1074 failed(`git ${args[0] ?? ""} didn't run: ${error.message}`)1075 )1076 );1077 });10781064 /** git as `as` that must succeed; its output. */1065 const gitOk = (as: Handle, cwd: string, args: readonly string[]) =>1081 Effect.flatMap(gitAs(as, cwd, args), ({ code, stderr, stdout }) =>1082 code === 01083 ? Effect.succeed(stdout)1084 : Effect.fail(1085 failed(`git ${args.join(" ")} exited ${code}: ${stderr.trim()}`)1086 )1087 );1066 Effect.flatMap(gitAs(as, cwd, args), okOutput(args));10671068 // An empty folder of the seed's own, removed with the scope: git run1069 // there reads no repo's config, as `gitEnv` keeps the machine's out.1070 const scratch = fs
54 unmodified lines
1125 .map((file) => RepoPath.make(file));1126 })1127 );11281150 const pushCommit: SeedTarget["Service"]["pushCommit"] = (input) =>1129 /** A commit of `files` with no parent, made as `as` and pushed to `ref` of `repo`. */1130 const pushCommit = (input: {1131 readonly repo: ProjectName | RepoName;1132 readonly ref: string;1133 readonly files: Array.NonEmptyReadonlyArray<SeedFile>;1134 readonly as: Handle;1135 readonly message: string;1136 }) =>1137 Effect.scoped(1138 Effect.gen(function* () {1139 const dir = yield* scratch;1140 const { as } = input;
22 unmodified lines
1163 )((yield* gitOk(as, dir, ["rev-parse", "HEAD"])).trim());1164 })1165 );11661167 // git ends a message with one newline whether given one or not, so1168 // main's first commit is the one this made before layers had a step.1169 const pushInitial = (1170 project: ProjectName,1171 files: SeedPlan["initFiles"],1172 as: Handle1173 ) =>1186 Effect.scoped(1187 Effect.gen(function* () {1188 const dir = yield* scratch;1174 pushCommit({1175 as,1176 files,1177 message: `Start ${project}`,1178 ref: MAIN_REF,1179 repo: project,1180 });11811190 yield* Effect.forEach(1191 files,1192 ({ content, path: file }) =>1193 Effect.gen(function* () {1194 const at = path.join(dir, file);11951196 yield* fs.makeDirectory(path.dirname(at), {1197 recursive: true,1198 });11991200 yield* fs.writeFile(at, content);1201 }).pipe(1202 Effect.mapError(() => failed(`can't write ${file} to seed`))1203 ),1204 { discard: true }1205 );12061207 yield* gitOk(as, dir, ["init", "--quiet", "--initial-branch=main"]);1208 yield* gitOk(as, dir, ["add", "--all"]);12091210 yield* gitOk(as, dir, [1211 "commit",1212 "--quiet",1213 "--message",1214 `Start ${project}`,1215 ]);12161217 yield* gitOk(as, dir, [1218 "push",1219 "--quiet",1220 remoteOf(project),1221 `HEAD:${MAIN_REF}`,1222 ]);12231224 return yield* decoded(1225 CommitSha,1226 "the commit git made"1227 )((yield* gitOk(as, dir, ["rev-parse", "HEAD"])).trim());1228 })1229 );12301182 return SeedTarget.of({1183 clientFor: (handle) =>1184 Option.match(tokenOf(handle), {1185 onNone: () => Layer.effect(Client)(Effect.fail(missing([handle]))),
214 unmodified lines