8000 INSTALL.md never tells you to clone the repo (#22) by simon-inkie · Pull Request #49 · simon-inkie/inkie-deck · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .specs/22-install-clone-step/SPEC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# #22: INSTALL.md never tells you to clone the repo

- Issue: #22
- Branch: 22-install-clone-step
- Started: 2026-10-07

## TL;DR

INSTALL.md says you need a git clone but no step makes one. This adds an
explicit `git clone` step at the end of section 1, a note that a private repo
needs `gh auth login`, a narrow leak-gate exemption so the real clone URL can
be written, and an explicit, declared skip of the clone block in the install
rig.

## Scope

In scope:
- Clone block and private-repo note in INSTALL.md.
- Leak-gate exemption for the canonical repo URL only, plus self-test cases.
- Install rig: declare the clone block as deliberately skipped, with a reason.

Out of scope:
- Anything else in INSTALL.md or the rig (see Follow-ups).

## Acceptance

- INSTALL.md has an explicit clone step with the real URL.
- `pnpm check:leaks` and `pn 8000 pm check:leaks -- --self-test` pass.
- The rig extracts and runs the clone block, or deliberately skips it with a
comment saying why. This change skips it (see Decisions log).

## Test plan

- `node scripts/leak-gate.mjs --self-test`: new cases prove the URL is exempt,
and the name rule still fires on the bare name, on a different URL and on a
longer owner or repo path that merely starts with the URL.
- `pnpm check:leaks`, `pnpm check:dashes` and the other CI checks.
- `node rig/self-test.mjs`: new case proves a skipped block is accounted for
and a stale skip is reported. The container rig needs Docker and is not run
here.

## Decisions log

- Clone block placed at the end of section 1, not a new heading: the rig keys
runs to heading slugs, so a new section would renumber ids for no gain.
- Exemption is a per-rule `contentExemptPattern` that blanks the exact URL
(optionally `.git`, followed by a non-name character) before the rule
runs, so any other occurrence of the name on the same line still fires. It
applies to content scope only, and only to the first-name rule. The URL is
assembled from fragments in the gate source, as the gate's other samples are.
- The rig skips the clone block rather than running it: the rig copies the
working tree into a container that has no network credentials, and the repo
is private, so a real clone cannot succeed there. Skips are declared in
`rig/install-plan.mjs` with a reason, and count as claimed in the coverage
accounting, so a stale skip (block gone from the document) fails the rig.
- The `gh auth login` note is marked for deletion once the repo is public, as
the issue asks. gh is not added to the prerequisites install line: the note
only applies to private access, and adding a package there changes tested
blocks for a temporary need.

## Check results

- Pass: `check:leaks` and `--self-test`, `check:boundaries`, `check:licence`,
`check:lib-version`, `check:dashes`, `typecheck`, `node rig/self-test.mjs`.
- Already failing on main, unchanged by this work: `pnpm test` has 4 failures
(`create-agent` CANNOT VERIFY case, `inbox` and `inbox-push` shell suites,
the pane-gate cases). This machine lacks `xxd` and has no `LANG` set, both
of which INSTALL.md section 1 names as causes. Confirmed identical on a
clean checkout of main.
- Already failing: `check:leaks:messages` reports 6 findings in three older
commits on main, none from this branch.
- Not run: the Docker install rig (no Docker here).

## Follow-ups

- Tidy: `pnpm check:leaks -- --self-test` fails because pnpm forwards the
literal `--`; the self-test works as `pnpm check:leaks --self-test`.
- Remove the private-repo `gh auth login` paragraph from INSTALL.md once the
repository is public.
- Reword the `check:leaks:messages` findings in the older commits, or decide
they are accepted.
16 changes: 16 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ your shell profile rather than in one terminal, since the agents inherit the
environment of whatever launched them. A desktop machine almost certainly
already has this and can skip it.

Last, get the code. This is the step that makes the clone the prerequisites
above ask for:

```sh
git clone https://github.com/simon-inkie/inkie-deck.git && cd inkie-deck
```

While the repository is private, that clone needs you signed in to GitHub.
Install the GitHub CLI (`gh`) and run `gh auth login` inside the same Linux
environment you are installing in, which on Windows means inside WSL, not in
PowerShell. Delete this paragraph once the repository is public.

This block is the one exception to "executed from this document": the rig
copies the tree into its container instead of cloning it, so it is declared
as skipped in `rig/install-plan.mjs`, with the reason.

## 2. Install the dependencies

Everything from here runs from the root of your clone.
Expand Down
17 changes: 17 additions & 0 deletions rig/install-plan.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@ export const RUNS = {
],
};

/**
* Executable blocks that are deliberately not run, each with the reason.
*
* A skip is declared rather than implied, so the coverage accounting still
* sees the block: it counts as claimed, and a skip naming a block that has left
* the document fails the rig as a stale claim.
*
* The clone step cannot run here. The rig copies the working tree into a
* container that has no network credentials, so `git clone` of the real URL
* would be testing the host's access rather than the document, and while the
* repository is private it cannot succeed at all. Every later block runs from
* the copied tree, which is what the clone would have produced.
*/
export const SKIPPED = {
"1-prerequisites/sh#4": "git clone of the real URL: no credentials in the container, and the rig copies the tree in instead",
};

/**
* Blocks that never return, and the sentence in the document that says so.
*
Expand Down
7 changes: 5 additions & 2 deletions rig/lib/fenced.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ export function slugify(text) {
* derived from the other.
*
* @param {FencedBlock[]} blocks
* @param {{ executableLangs: string[], knownLangs: string[], runs: Record<string, string[]> }} plan
* @param {{ executableLangs: string[], knownLangs: string[], runs: Record<string, string[]>, skipped?: Record<string, unknown> }} plan
*/
export function coverage(blocks, plan) {
const byId = new Map(blocks.map((block) => [block.id, block]));
const executable = blocks.filter((block) => plan.executableLangs.includes(block.lang));
const claimed = new Set(Object.values(plan.runs).flat());
// A declared skip is an accounted-for block, not an unclaimed one: it names
// the block and carries a reason in the plan. It still has to exist in the
// document, so a stale skip is reported through unknownIds like a stale run.
const claimed = new Set([...Object.values(plan.runs).flat(), ...Object.keys(plan.skipped ?? {})]);
return {
total: blocks.length,
executable: executable.map((block) => block.id),
Expand Down
13 changes: 13 additions & 0 deletions rig/self-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,19 @@ export async function selfTest(options = {}) {
runs: { only: ["first-section/sh#1"] },
});
assert("an executable block no run claims is reported", cover.unclaimed.includes("second-section/sh#1"), cover.unclaimed);
const skippedCover = coverage(docBlocks, {
executableLangs: ["sh"],
knownLangs: ["sh", "text"],
runs: { only: ["first-section/sh#1"] },
skipped: { "second-section/sh#1": "declared skip" },
});
assert("a declared skip is accounted for, not reported as unclaimed", skippedCover.unclaimed.length === 0, skippedCover.unclaimed);
assert("a skip on a block that does not exist is reported as stale", coverage(docBlocks, {
executableLangs: ["sh"],
knownLangs: ["sh", "text"],
runs: { only: ["first-section/sh#1", "second-section/sh#1"] },
skipped: { "first-section/sh#9": "stale" },
}).unknownIds.length === 1);
assert("a claim on a block that does not exist is reported separately", coverage(docBlocks, {
executableLangs: ["sh"],
knownLangs: ["sh", "text"],
Expand Down
4 changes: 3 additions & 1 deletion rig/stages/05-install-doc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
REQUIRED_CLAIMS,
REQUIRED_HEADINGS,
RUNS,
SKIPPED,
} from "../install-plan.mjs";

export default {
Expand All @@ -34,7 +35,7 @@ export default {
const docPath = path.join(ctx.repoRoot, INSTALL_DOC);
const markdown = fs.readFileSync(docPath, "utf8");
const blocks = extractFencedBlocks(markdown);
const cover = coverage(blocks, { executableLangs: EXECUTABLE_LANGS, knownLangs: KNOWN_LANGS, runs: RUNS });
const cover = coverage(blocks, { executableLangs: EXECUTABLE_LANGS, knownLangs: KNOWN_LANGS, runs: RUNS, skipped: SKIPPED });

// Handed to the container stages so all three execute the same extraction
// this stage just validated, rather than each parsing the file again.
Expand Down Expand Up @@ -145,6 +146,7 @@ export default {
executableLangs: EXECUTABLE_LANGS,
knownLangs: KNOWN_LANGS,
runs: RUNS,
skipped: SKIPPED,
});

// NEGATIVE CONTROL 3. Strip the sentence that tells a reader `pnpm dev`
Expand Down
44 changes: 41 additions & 3 deletions scripts/leak-gate.mjs
5256
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const REPO_ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
/**
* @param {{ label: string, why: string, pattern: string[], flags?: string, sample: string[], messageExempt?: boolean, messageExemptPattern?: string[] }} spec
*/
function rule({ label, why, pattern, flags = "i", sample, messageExempt = false, messageExemptPattern }) {
function rule({ label, why, pattern, flags = "i", sample, messageExempt = false, messageExemptPattern, contentExemptPattern }) {
return {
label,
why,
Expand All @@ -74,6 +74,11 @@ function rule({ label, why, pattern, flags = "i", sample, messageExempt = false,
// rule, not a specific name) must not go blind to every OTHER match on
// that class just to permit one pre-approved instance.
messageExemptPattern: messageExemptPattern ? new RegExp(messageExemptPattern.join(""), flags) : undefined,
// Content-scope counterpart: this exact shape is blanked out of the text
// BEFORE the rule runs, so only that instance is permitted. Anything else
// the rule's own pattern catches, including the same name elsewhere on the
// same line, still fires. Global so every instance on a line is blanked.
contentExemptRe: contentExemptPattern ? new RegExp(contentExemptPattern.join(""), flags.replace("g", "") + "g") : undefined,
};
}

Expand All @@ -92,6 +97,11 @@ const RULES = [
pattern: ["si", "mon"],
sample: ["si", "mon"],
messageExempt: true,
// The canonical clone URL carries the GitHub owner, which is this name,
// and INSTALL.md has to print it. Exempt that one URL and nothing wider:
// the owner/repo pair is fixed, an optional .git is allowed, and a longer
// repo name (a fork-style suffix) does not match.
contentExemptPattern: ["https://github\\.com/si", "mon-ink", "ie/ink", "ie-deck(?:\\.git)?(?![\\w-])"],
}),
rule({
label: "second-principal-first-name",
Expand Down Expand Up @@ -404,8 +414,9 @@ function scanBuffer(display, buffer) {
const findings = [];
const lines = buffer.toString("utf8").split("\n");
for (const [index, lineText] of lines.entries()) {
for (const { label, why, re } of RULES) {
if (re.test(lineText)) {
for (const { label, why, re, contentExemptRe } of RULES) {
const tested = contentExemptRe ? lineText.replace(contentExemptRe, "") : lineText;
if (re.test(tested)) {
findings.push({ file: display, line: index + 1, label, why });
}
}
Expand Down Expand Up @@ -687,10 +698,37 @@ function selfTest() {
);
process.exit(1);
}
// Prove the content-scope URL exemption is narrow: the canonical clone
// URL passes, and the name still fires on the bare name, on a different
// URL, on a longer repo name, and beside an exempt URL on the same line.
const nameRule = RULES.find((r) => r.label === "principal-first-name");
if (!nameRule?.contentExemptRe) {
console.error("leak-gate self-test: principal-first-name rule or its content exemption missing");
process.exit(1);
}
const owner = ["si", "mon-ink", "ie"].join("");
const bareName = ["si", "mon"].join("");
const exemptCases = [
{ text: `git clone https://github.com/${owner}/inkie-deck.git && cd inkie-deck`, fires: false, why: "the canonical clone URL" },
{ text: `see https://github.com/${owner}/inkie-deck for the source`, fires: false, why: "the canonical URL without .git" },
{ text: `ask ${bareName} about it`, fires: true, why: "the bare name" },
{ text: `https://github.com/${owner}/other-repo.git`, fires: true, why: "a different repo under the same owner" },
{ text: `https://github.com/${owner}/inkie-deck-fork.git`, fires: true, why: "a longer repo name" },
{ text: `http://example.com/${owner}/inkie-deck.git`, fires: true, why: "a different host" },
{ text: `https://github.com/${owner}/inkie-deck.git from ${bareName}`, fires: true, why: "the name beside an exempt URL" },
];
for (const { text, fires, why } of exemptCases) {
const fired = scanBuffer("case", Buffer.from(text)).some((f) => f.label === nameRule.label);
if (fired !== fires) {
console.error(`leak-gate self-test: principal-first-name ${fires ? "should fire on" : "should exempt"} ${why}`);
process.exit(1);
}
}
console.log(
`leak-gate self-test: all ${RULES.length} rules fire correctly (content, filename and binary-sniff paths)`,
);
console.log("leak-gate self-test: message-scope exemption is narrow (approved shape only, not the whole rule)");
console.log("leak-gate self-test: content-scope URL exemption is narrow (canonical clone URL only)");
} finally {
fs.rmSync(dir, { recursive: true, force: true });
}
Expand Down
Loading
0