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`.
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
Provenance
- Commit
4bc29c4- Tree
f07d67d- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent
019f456
3 files changed+74 added−105 removed
modified:examples/datekit/layers/maintainers/.agents/maintainers/finish.md+1 added-1 removed
6 unmodified lines7891011116 unmodified lines3. **No new tokens without the README.** A change to what `format` accepts updates the token table in `README.md` and the one in `format`'s doc comment, in the same order. A letter that is no token keeps throwing a `RangeError`.4. **UTC unless a zone is named.** Code never reads the machine's zone: no `getHours()`, `getDate()` or `toLocaleString()` without `timeZone`. Run the tests under `TZ=Pacific/Kiritimati bun test` before finishing.5. **The smallest diff that reads well.** Keep the ask's territory. Rename only what the change makes wrong. Keep the existing helpers (`pad`, `whole`, `utcMidnight`) rather than adding near copies.6. **Held-back checks stay here.** Never copy a file from `checks/held-back/` into `test/`, and don't paraphrase one in a public test. If a public test needs a check, release it as a credited landing, then write the public test from the release.7. **Credit the answer's author.** A finish commit adds `Finished-by:` and keeps the answer's `Signed-off-by:` as it was.7. **Credit stays with the answer's author.** Commit on top of the answer; never rewrite its commits or write credit trailers by hand. The finish lands with you as `Finished-by:`, beside the answer's own `Signed-off-by:`.modified:packages/config/test/seed-layer.test.ts+26 added-8 removed
200 unmodified lines201 202 return { layer, manifest, plan, policy };203 });204 205+/** The lanes datekit's `project.ts` runs on every answer: the public checks, by name. */206+const 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`)));214+215+ return Object.entries(block.checks);216+});217+218 /** A heading's anchor, as a README link names it: `## Format patterns` is `format-patterns`. */219 const anchorOf = (heading: string) =>220 heading221 .toLowerCase()199 unmodified lines421 60_000422 );423 424 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;430 431 const runs = yield* Effect.forEach(432 layer.knownBad,433 ({ branch, files }) =>6 unmodified lines440 "test",441 `./checks/held-back/${area}`,442 ]);443 430- 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+ );451 452 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 );460 461+ 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 linesmodified:scripts/lib/seed.ts+47 added-96 removed
244 unmodified lines245 /** All a byte stream says, as text. */246 const streamText = <E>(bytes: Stream.Stream<Uint8Array, E>) =>247 bytes.pipe(Stream.decodeText(), Stream.mkString);248 249-/** 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+ */253 const 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 );269 270 const [stdout, stderr, code] = yield* Effect.all(271 [streamText(child.stdout), streamText(child.stderr), child.exitCode],548 unmodified lines820 )821 )822 );823 816- const pushed = (result: StepResult) =>824+ const reported = (result: StepResult) =>825 SeedStep.cases.Layer.make({ result, target: layer.repo });826 827 if (refs.has(MAIN_REF)) {820- return pushed("already");828+ return reported("already");829 }830 831 yield* Effect.forEach(832 layer.knownBad.filter(27 unmodified lines860 ref: MAIN_REF,861 repo: layer.repo,862 });863 856- return pushed("done");864+ return reported("done");865 });866 867 /**868 * Seeds one project: makes it and pushes main's first commit as the173 unmodified lines1042 ? Effect.fail(missing(lacking))1043 : Effect.void;1044 };1045 1038- /** 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+ );1063 1045- 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- );1060-1061- const [stdout, stderr, code] = yield* Effect.all(1062- [1063- streamText(child.stdout),1064- streamText(child.stderr),1065- child.exitCode,1066- ],1067- { concurrency: "unbounded" }1068- );1069-1070- 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- });1078-1064 /** 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));1067 1068 // 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 = fs54 unmodified lines1125 .map((file) => RepoPath.make(file));1126 })1127 );1128 1150- 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 lines1163 )((yield* gitOk(as, dir, ["rev-parse", "HEAD"])).trim());1164 })1165 );1166 1167+ // 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+ });1181 1190- yield* Effect.forEach(1191- files,1192- ({ content, path: file }) =>1193- Effect.gen(function* () {1194- const at = path.join(dir, file);1195-1196- yield* fs.makeDirectory(path.dirname(at), {1197- recursive: true,1198- });1199-1200- yield* fs.writeFile(at, content);1201- }).pipe(1202- Effect.mapError(() => failed(`can't write ${file} to seed`))1203- ),1204- { discard: true }1205- );1206-1207- yield* gitOk(as, dir, ["init", "--quiet", "--initial-branch=main"]);1208- yield* gitOk(as, dir, ["add", "--all"]);1209-1210- yield* gitOk(as, dir, [1211- "commit",1212- "--quiet",1213- "--message",1214- `Start ${project}`,1215- ]);1216-1217- yield* gitOk(as, dir, [1218- "push",1219- "--quiet",1220- remoteOf(project),1221- `HEAD:${MAIN_REF}`,1222- ]);1223-1224- return yield* decoded(1225- CommitSha,1226- "the commit git made"1227- )((yield* gitOk(as, dir, ["rev-parse", "HEAD"])).trim());1228- })1229- );1230-1182 return SeedTarget.of({1183 clientFor: (handle) =>1184 Option.match(tokenOf(handle), {1185 onNone: () => Layer.effect(Client)(Effect.fail(missing([handle]))),214 unmodified lines