slicekit 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/runbook.js ADDED
@@ -0,0 +1,96 @@
1
+ // The runbook judgement (03 REQ-3.7, D-21, D-55), shared by the `runbook` check rule, `build pr` and
2
+ // `slicekit release`: a slice that says `runbook: yes` changes a `##` section of the runbook, or its
3
+ // pull request body's Runbook line begins "no operational change".
4
+ import { execFileSync } from 'node:child_process';
5
+ import path from 'node:path';
6
+ import { GitError, git } from './git.js';
7
+ import { headings, lines } from './markdown.js';
8
+ import { kitPaths } from './paths.js';
9
+ import { getSection } from './prbody.js';
10
+
11
+ export const NO_CHANGE = 'no operational change';
12
+
13
+ // The runbook's POSIX path relative to the root: `runbook.md` when `docsRoot` is `.`.
14
+ export function runbookRel(root, cfg) {
15
+ return path.relative(root, kitPaths(root, cfg).runbook).split(path.sep).join('/');
16
+ }
17
+
18
+ const resolves = (root, ref) => {
19
+ try {
20
+ git(root, ['rev-parse', '--verify', '--quiet', ref]);
21
+ return true;
22
+ } catch (e) {
23
+ if (e instanceof GitError) return false;
24
+ throw e;
25
+ }
26
+ };
27
+
28
+ // The default branch as origin has it, else the local one.
29
+ export function defaultRef(root, cfg) {
30
+ const origin = `refs/remotes/origin/${cfg.defaultBranch}`;
31
+ return resolves(root, origin) ? origin : `refs/heads/${cfg.defaultBranch}`;
32
+ }
33
+
34
+ // The commit `tip` left the default branch at.
35
+ export function mergeBase(root, cfg, tip = 'HEAD') {
36
+ return git(root, ['merge-base', tip, defaultRef(root, cfg)]);
37
+ }
38
+
39
+ // The file at `rev`, byte for byte (git() trims, which would move every line number of a file that
40
+ // begins with a blank line); '' when the commit does not hold it.
41
+ function fileAt(root, rev, rel) {
42
+ try {
43
+ return execFileSync('git', ['show', `${rev}:${rel}`], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 64 * 1024 * 1024 });
44
+ } catch {
45
+ return '';
46
+ }
47
+ }
48
+
49
+ // line number (1-based) -> the text of the `##` heading whose section holds it, or null above the
50
+ // first one. A heading line belongs to its own section; a fenced `## ` line is not a heading.
51
+ function sectionFinder(text) {
52
+ const hs = headings(text).filter((h) => h.level === 2);
53
+ return (n) => {
54
+ let found = null;
55
+ for (const h of hs) {
56
+ if (h.line > n) break;
57
+ found = h.text;
58
+ }
59
+ return found;
60
+ };
61
+ }
62
+
63
+ const HUNK = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
64
+
65
+ // The `##` headings of the runbook whose section holds a line added or removed between `base` and
66
+ // `tip`, sorted and unique. Removed lines are placed with the base's file, added lines with the
67
+ // tip's. A change of trailing whitespace only is no change (D-55).
68
+ export function runbookSections(root, rel, base, tip) {
69
+ const diff = git(root, ['--literal-pathspecs', 'diff', '--no-color', '--no-ext-diff', '--no-renames', '--unified=0', '--ignore-space-at-eol', base, tip, '--', rel]);
70
+ if (diff === '') return [];
71
+ const inBase = sectionFinder(fileAt(root, base, rel));
72
+ const inTip = sectionFinder(fileAt(root, tip, rel));
73
+ const found = new Set();
74
+ const mark = (finder, start, count) => {
75
+ for (let n = start; n < start + count; n++) {
76
+ const s = finder(n);
77
+ if (s !== null) found.add(s);
78
+ }
79
+ };
80
+ for (const line of lines(diff)) {
81
+ const m = HUNK.exec(line);
82
+ if (!m) continue;
83
+ mark(inBase, Number(m[1]), m[2] === undefined ? 1 : Number(m[2]));
84
+ mark(inTip, Number(m[3]), m[4] === undefined ? 1 : Number(m[4]));
85
+ }
86
+ return [...found].sort();
87
+ }
88
+
89
+ // null when the slice passes, else the finding's message. `body` is a pull request body, or null
90
+ // when there is none to read; then only the flag and the changed sections count.
91
+ export function runbookVerdict({ flag, sections, body, rel }) {
92
+ if (!flag) return null;
93
+ if (sections.length > 0) return null;
94
+ if (typeof body === 'string' && (getSection(body, 'Runbook') ?? '').trim().startsWith(NO_CHANGE)) return null;
95
+ return `runbook: the slice says runbook: yes, ${rel} changed no section, and the Runbook line does not begin "${NO_CHANGE}"`;
96
+ }
package/src/workflow.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // The GitHub Actions workflow init writes (REQ-3.11): a gate, a job per declared team command, a job
2
- // per observability step (D-20), the ready label and the post-merge state sync (D-12), which opens a
2
+ // per observability step of config and of observability.md (D-20, D-56), the ready label and the post-merge state sync (D-12), which opens a
3
3
  // [sync] pull request and starts the workflow on its branch with workflow_dispatch (D-78, D-80). The YAML is
4
4
  // generated as text; every free-text value goes through yamlScalar so a quote, colon or hash in a
5
5
  // team's command cannot change the document's structure.
@@ -7,8 +7,10 @@ import { execFileSync } from 'node:child_process';
7
7
  import fs from 'node:fs';
8
8
  import path from 'node:path';
9
9
  import { fileURLToPath } from 'node:url';
10
- import { DEFAULT_RUNS_ON, DEFAULT_TIMEOUT_MINUTES, GITHUB_EXPRESSION, LINE_SEPARATOR, MATRIX_OS, shardErrors, shardRunnerErrors } from './config.js';
10
+ import { ConfigError, DEFAULT_RUNS_ON, DEFAULT_TIMEOUT_MINUTES, GITHUB_EXPRESSION, LINE_SEPARATOR, MATRIX_OS, shardErrors, shardRunnerErrors } from './config.js';
11
11
  import { readText } from './fs.js';
12
+ import { allSteps, docSteps } from './observability.js';
13
+ import { kitPaths } from './paths.js';
12
14
  import { substitute } from './render/entry.js';
13
15
 
14
16
  export const WORKFLOW_TEMPLATE = fileURLToPath(new URL('../templates/workflow/slicekit.yml', import.meta.url));
@@ -277,7 +279,9 @@ function fillFreeText(line, vars) {
277
279
  return m[1] + yamlScalar(substitute(m[2], vars, FREE_TEXT_KEYS));
278
280
  }
279
281
 
280
- export function renderWorkflow(cfg, pins = loadPins(), { template = fs.readFileSync(WORKFLOW_TEMPLATE, 'utf8'), root = null } = {}) {
282
+ // `steps` are the observability steps to render, one obs-<n> job each in that order: config's own when
283
+ // the caller passes none; workflowState passes config's followed by those of observability.md (D-56).
284
+ export function renderWorkflow(cfg, pins = loadPins(), { template = fs.readFileSync(WORKFLOW_TEMPLATE, 'utf8'), root = null, steps = cfg.ci?.observabilitySteps ?? [] } = {}) {
281
285
  if (/[\r\n]/.test(cfg.cli)) throw new Error('cli: must be one line to render the workflow');
282
286
  const v = checkPins(pins);
283
287
  const matrix = cfg.ci?.matrix === true;
@@ -294,7 +298,6 @@ export function renderWorkflow(cfg, pins = loadPins(), { template = fs.readFileS
294
298
  const shards = given && (matrix ? given : { [runsOn]: Object.values(given)[0] });
295
299
  const commands = COMMAND_ORDER.filter((name) => typeof cfg.commands[name] === 'string' && cfg.commands[name].trim() !== '');
296
300
  const jdk = setupJavaSteps(v, cfg.ci?.java ?? DEFAULT_JAVA, javaBuildTool(root, commands.map((c) => cfg.commands[c])), root);
297
- const steps = cfg.ci?.observabilitySteps ?? [];
298
301
  const texts = [cfg.cli, ...commands.map((c) => cfg.commands[c]), ...steps.map((s) => s.run)];
299
302
  if (texts.some((t) => GITHUB_EXPRESSION.test(t))) throw new Error('workflow: a command contains a GitHub expression; pass values through env:');
300
303
  const blocks = {
@@ -327,12 +330,25 @@ export function renderWorkflow(cfg, pins = loadPins(), { template = fs.readFileS
327
330
  return out.join('\n');
328
331
  }
329
332
 
330
- // The rendered workflow and the repository's copy of it (null when absent), line endings normalised.
333
+ // The observability steps of a repository (D-56): config's, then the rows of the steps table of its
334
+ // observability.md when the file exists. A step the workflow cannot carry, or one named in both
335
+ // places, throws a ConfigError naming the file and line; a row with no command is a warning.
336
+ export function workflowSteps(root, cfg) {
337
+ const file = kitPaths(root, cfg).observability;
338
+ const rel = path.relative(root, file).split(path.sep).join('/');
339
+ const all = allSteps(cfg, fs.existsSync(file) ? docSteps(readText(file), rel) : null);
340
+ if (all.errors.length > 0) throw new ConfigError(all.errors);
341
+ return { steps: all.steps, warnings: all.warnings };
342
+ }
343
+
344
+ // The rendered workflow and the repository's copy of it (null when absent), line endings normalised,
345
+ // with the warnings of the steps read from observability.md.
331
346
  export function workflowState(root, cfg, pins = loadPins()) {
332
- const expected = renderWorkflow(cfg, pins, { root });
347
+ const { steps, warnings } = workflowSteps(root, cfg);
348
+ const expected = renderWorkflow(cfg, pins, { root, steps });
333
349
  const file = path.join(root, WORKFLOW_PATH);
334
350
  const current = fs.existsSync(file) ? readText(file) : null;
335
- return { file, expected, current };
351
+ return { file, expected, current, warnings };
336
352
  }
337
353
 
338
354
  // D-49: a team whose test command never reads SLICEKIT_SHARD runs the whole command in every shard.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ops
3
- description: Reads the runbook and history for a symptom and writes a proposed-actions report; changes nothing.
4
- tools: Read, Grep, Glob, Write, Bash
3
+ description: Reads the runbook and history for a symptom and replies with a proposed-actions report; changes nothing.
4
+ tools: Read, Grep, Glob
5
5
  model: inherit
6
6
  ---
7
- Brief: run `{{cli}} instructions ops` and follow it. You never run a git command that commits, pushes or moves a branch; report and the command commits. End every reply with "Skipped:" and "Not checked:" lines.
7
+ Brief: run `{{cli}} instructions ops` and follow it. The start hook gives you that brief, since you hold no tool that runs a command or writes a file. Your reply is the report; you take no action you propose. End every reply with "Skipped:" and "Not checked:" lines.
@@ -1,11 +1,11 @@
1
1
  # Brief: auditor
2
2
 
3
- You compare what the documents claim with what the code, the tests and the CI history show, or, in gap mode, what the spec claims with what the intake and the decisions support. Every finding carries a citation on both sides: the claim's file and line, and the evidence's file and line, command or CI run. The command that spawned you commits what you write.
3
+ You compare what the documents claim with what the code, the tests and the CI history show, or, in gap mode, what the spec claims with what the intake and the decisions support. Every finding carries a citation on both sides: the claim's file and line, and the evidence's file and line, command or CI run. In gap mode the command commits what you record; an audit report is never committed.
4
4
 
5
5
  ## You write
6
6
 
7
7
  - In an audit, a report at the path the command gives you, with one row per claim: the claim, where it is written, the evidence, where it was found, and its status.
8
- - The status is one of three words. `holds`: the evidence agrees with the claim. `drifted`: the evidence contradicts it; name the commit that broke it, from the history the command gives you. `unverifiable`: you found no evidence either way; say why.
8
+ - The status is one of three words. `holds`: the evidence agrees with the claim. `drifted`: the evidence contradicts it; name the commit that broke it, one of the claim's candidate commits. `unverifiable`: you found no evidence either way; say why.
9
9
  - In gap mode, nothing but the rows you record with `{{cli}} gaps add` (see Gaps below). You write no file of your own.
10
10
 
11
11
  ## You never
@@ -14,6 +14,17 @@ You compare what the documents claim with what the code, the tests and the CI hi
14
14
  - Change the documents you audit. In an audit the gap goes in your report; in gap mode it goes in through `{{cli}} gaps add`.
15
15
  - Run git, except the read-only `git diff`, `git log`, `git show` and `git status`. You never commit or push; the command does that.
16
16
 
17
+ ## Audit
18
+
19
+ In an audit the command gives you the report path and the claims, each with its ID, its `<file>:<line>`, the files it names and its candidate commits: those that touched one of those files after the claim was written. The report holds one table under `## Claims`, one row per claim:
20
+
21
+ ```
22
+ | Claim | Where | Evidence | Found at | Status | Commit |
23
+ |---|---|---|---|---|---|
24
+ ```
25
+
26
+ Claim and Where are as the command printed them. Found at is the evidence's `<file>:<line>` or a command in backticks; an `unverifiable` row may leave it empty. Commit is empty unless the row is `drifted`: a `drifted` row names one of its claim's candidate commits, by seven or more characters of its SHA. When no candidate explains the contradiction, the row is `unverifiable`. The report ends with the same two closing lines as your reply.
27
+
17
28
  ## Gaps
18
29
 
19
30
  When `/slicekit gaps` spawns you, you are in gap mode: the claims are the spec under `<docsRoot>/spec/` and the evidence is the intake snapshots under `<docsRoot>/intake/` and `<docsRoot>/decisions.md`. You look for gaps between them. Each gap is one of five classes:
@@ -1,21 +1,42 @@
1
1
  # Brief: ops
2
2
 
3
- You triage one symptom. You read the runbook, `observability.md`, the history of the files or services the symptom names and the last release record, and you return proposed actions. You change nothing outside your report.
3
+ You triage one symptom. The command gives you the symptom and its context: the files the symptom names, the history of those files (the slices and pull requests that touched them, each with its verdict and release), and the paths of the runbook, `observability.md` and the last release record. You read those three files and return proposed actions. You change nothing: you hold no tool that writes a file or runs a command.
4
4
 
5
5
  ## You write
6
6
 
7
- A proposed-actions report, at the path the command gives you, or as your reply when it names none. It holds:
7
+ No file. Your reply is the report, and the command saves it as you wrote it. It holds these three sections, under these headings:
8
8
 
9
- 1. The likely slices and pull requests, each with the files that tie it to the symptom.
10
- 2. The runbook's first checks for this symptom, quoted with their file and line.
11
- 3. The proposed actions, one per line, each marked by who may take it: `anyone`, `on-call`, or `owner` with the owner's name when the runbook gives one.
9
+ 1. `## Likely slices and pull requests`: one line per slice, with its address, its pull request as `#<n>` and the files that tie it to the symptom. Name only slices and pull requests the history you were given lists.
10
+ 2. `## First checks`: the runbook's first checks for this symptom, each quoted with its `<file>:<line>`. A check from `observability.md` or the release record carries its `<file>:<line>` the same way. When the runbook holds no check for the symptom, say so in one line.
11
+ 3. `## Proposed actions`: one list item per action, each ending with a mark of who may take it: `(anyone)`, `(on-call)`, or `(owner: <name>)` with the owner the runbook names. When you propose no action, the section holds the one line `None.` and nothing else.
12
+
13
+ A reply in this shape passes the check:
14
+
15
+ ```
16
+ ## Likely slices and pull requests
17
+
18
+ - P1/S-01, #1: src/billing/charge.js, src/billing/refund.js
19
+
20
+ ## First checks
21
+
22
+ - docs/runbook.md:14 When billing returns 500, read the charge and refund code first.
23
+
24
+ ## Proposed actions
25
+
26
+ - Read the service's log for the failing request (anyone)
27
+ - Revert pull request #1 on the host (on-call)
28
+ - Ask whether the charge limits changed (owner: Dana)
29
+
30
+ Skipped: the release record
31
+ Not checked: the service's log
32
+ ```
12
33
 
13
34
  ## You never
14
35
 
15
- - Change infrastructure, configuration, data or code.
16
- - Take an action you propose, even one marked `anyone`.
17
- - Run git, except the read-only `git diff`, `git log`, `git show` and `git status`. You never commit, push or revert.
36
+ - Change infrastructure, configuration, data, code or any document.
37
+ - Take an action you propose, even one marked `(anyone)`.
38
+ - Run git or any other command. You never commit, push or revert.
18
39
 
19
40
  ## Your report
20
41
 
21
- Your reply names the report's path, or holds the report. It ends with a `Skipped:` line naming the sources you did not read and then a `Not checked:` line naming what you did not verify. Each of these lines starts at the beginning of its line, with no list marker, bold or backticks. A reply without both lines is refused when you stop.
42
+ Your reply holds the report and nothing before it. It ends with a `Skipped:` line naming the sources you did not read and then a `Not checked:` line naming what you did not verify. Each of these lines starts at the beginning of its line, with no list marker, bold or backticks. The two lines end the Proposed actions section: nothing from the `Skipped:` line on is read as an action, so write every action above it. A reply without both lines is refused when you stop.
@@ -0,0 +1,38 @@
1
+ # /slicekit audit
2
+
3
+ Compare what the spec and the runbook claim with what the code, the tests and the CI history show,
4
+ and list each claim as `holds`, `drifted` or `unverifiable` (REQ-2.14). The area: {{args}}.
5
+
6
+ The area is a spec file's name without `.md`, a REQ prefix such as `REQ-2`, the word `runbook`, or
7
+ a path; `(none)` means every claim. This command changes no tracked file. Its report goes under
8
+ `.slicekit/reports/`, which the project's ignore rules cover, and is never committed. Every step
9
+ that reads the repository's history goes through `{{cli}}`; run no git or gh command yourself.
10
+
11
+ ## Steps
12
+
13
+ 1. Run `{{cli}} graph`, so the files the claims name are read from the latest history.
14
+ 2. Run `{{cli}} audit context {{args}}`; when the area is `(none)`, leave it out and run the command
15
+ with no area. Its first line is the report path. Then, for each claim in the area (each REQ block
16
+ of the spec, each `##` section of the runbook), it prints the claim's ID, its `<file>:<line>` and
17
+ its title, the files the claim names, and one `candidate` line for each commit that touched one of
18
+ those files after the claim's heading was last changed. It prints at most ten `candidate` lines
19
+ for a claim, the newest, then one line that counts the older ones and names the area to run with
20
+ `--all` to print them. On exit 2 the area names no claim: print what it says and ask the human
21
+ for another area.
22
+ 3. Spawn the auditor in audit mode. Its brief is the output of `{{cli}} instructions auditor`. Give
23
+ it the whole output of step 2 and the report path, and tell it this is an audit, not a gap scan:
24
+ the claims are the ones listed, and the evidence is the code, the tests and the CI history. The
25
+ auditor writes the report at that path. Step 2 created that path as an empty file, so tell the
26
+ auditor to read it with the Read tool before the first write, or the Write tool refuses to
27
+ overwrite it.
28
+ 4. Run `{{cli}} audit check <report> {{args}} --every-claim`, with the same area as step 2 or none.
29
+ The check reads the area's claims from the spec and the runbook, as step 2 did. It prints
30
+ `ok <report>`, or one `<report>:<line> <message>` line per problem: a missing `## Claims` table,
31
+ a row for a claim that is not in the area, a claim of the area with no row, a claim with two
32
+ rows, a status that is not one of the three words, a
33
+ `drifted` row whose commit is not one of its claim's candidates. On findings, send them to the
34
+ auditor once and run the check again. When the check still finds a problem, print the findings
35
+ with the report path and go on to step 5.
36
+ 5. Print the report path and the count of rows for each status. Tell the human that the audit
37
+ changed nothing: each `drifted` row becomes a slice or a decision, by their hand, and each
38
+ `unverifiable` row is a claim with no test or check behind it.
@@ -74,6 +74,16 @@ The sections of `<docsRoot>/observability.md`:
74
74
 
75
75
  After each answer step, write the answer into its section of the file, followed by the D-ID in brackets, for example `One Postgres on Fly (D-07).`. Leave the single line "Not yet known" in each section the human cannot answer, and record that question with `--open`. Change nothing else in these two files.
76
76
 
77
+ Write the answer to `CI steps the monitoring setup requires` as a table with the two columns Step and Command, one command per row, and the D-ID on a line of its own below the table:
78
+
79
+ ```
80
+ | Step | Command |
81
+ |---|---|
82
+ | Trace check | `npm run trace-check` |
83
+ ```
84
+
85
+ Each row becomes one job of the generated workflow, named by its Step and running its Command. Write the table in exactly this form: the header cells are `Step` and `Command` in plain text with these capitals, the divider line has two cells, and every line of the table opens with a vertical bar. The table is the only place in the section where a vertical bar may stand: any other line holding one, a second table included, is refused with its file and line. A Command cell is the whole command as one code span, or text with no backtick; put nothing else in the cell, the D-ID included. Text in a code fence, in an indented code block or in an HTML comment is not read. A command is one line and holds no secret and no `${{ … }}` expression; a pipe inside a command is written `\|`, inside a code span too, and a row with a bare pipe is refused. A step that needs a secret does not go in the table: tell the human to add it to `ci.observabilitySteps` in `.slicekit/config.json` with the secret under `env`. When the monitoring setup asks nothing of CI, write `None` and no table. After the table changes, run `{{cli}} workflow --write`.
86
+
77
87
  ## 6. Finish
78
88
 
79
89
  `{{cli}} intake done`
@@ -0,0 +1,38 @@
1
+ # /slicekit ops
2
+
3
+ Triage one symptom: find the slices and pull requests that touched the files it names, the
4
+ runbook's first checks for it, and the actions someone could take, each marked by who may take it
5
+ (REQ-2.13). The symptom: {{args}}.
6
+
7
+ This command takes no action and changes no tracked file. Its report goes under
8
+ `.slicekit/reports/`, which the project's ignore rules cover, and is never committed. Every step
9
+ that reads the repository's history goes through `{{cli}}`; run no git or gh command yourself.
10
+
11
+ When the symptom is `(none)`, ask the human for it and stop until they answer.
12
+
13
+ ## Steps
14
+
15
+ 1. Run `{{cli}} graph`, so the history the next step reads holds the latest merged pull requests.
16
+ 2. Run `{{cli}} ops context "{{args}}"`, with the symptom in one pair of double quotes and any
17
+ double quote, backquote or dollar sign inside it removed. Its first line is the report path.
18
+ The rest names the files the symptom's words match, the history of those files, the runbook,
19
+ `observability.md` and the last release record.
20
+ - On exit 1 the symptom names no file in the graph. Ask the human which file, directory or
21
+ service is meant, then run the command again with `--path <path>` for each one they name.
22
+ - A `too broad:` line names a word that matches more than fifty files and was not expanded. Tell
23
+ the human; when that word is the one they meant, ask for a narrower path and add it with
24
+ `--path`.
25
+ 3. Spawn the ops agent. Its brief is the output of `{{cli}} instructions ops`. Give it the symptom
26
+ and the whole output of step 2, and tell it to read the runbook, `observability.md` and the
27
+ release record that output names. The agent holds no tool that writes a file or runs a command:
28
+ its reply is the report.
29
+ 4. Write the agent's reply, as it is, to the report path from step 2 with the Write tool. Change no
30
+ word of it. Step 2 created that path as an empty file, so read it with the Read tool before the
31
+ first write, or the Write tool refuses to overwrite it.
32
+ 5. Run `{{cli}} ops check <report>`. It prints `ok <report>`, or one `<report>:<line> <message>`
33
+ line per problem: a missing section, a slice or pull request the graph does not hold, a cited
34
+ `<file>:<line>` that does not exist, an action marked by no one. On findings, send them to the
35
+ agent once, write its new reply to the same path and run the check again. When the check still
36
+ finds a problem, print the findings with the report path and go on to step 6.
37
+ 6. Print the report path and the report's `## Proposed actions` section. Tell the human that no
38
+ action was taken: each proposed action is theirs, or the named owner's, to take.
@@ -0,0 +1,51 @@
1
+ # /slicekit release
2
+
3
+ Write the release record of a phase whose slices are all merged, set each slice released, then open
4
+ the release pull request (REQ-2.9). Arguments: {{args}} (the phase).
5
+
6
+ `<docsRoot>` below is the `docsRoot` in `.slicekit/config.json`. Every step that touches the
7
+ repository's history goes through `{{cli}}`; run no git or gh command yourself. The release records
8
+ what merged; it does not deploy (D-12).
9
+
10
+ ## Steps
11
+
12
+ 1. Run `{{cli}} release {{args}} --dry-run`. It writes nothing. When it exits 0 it prints the record
13
+ it would write. When it exits 1 it prints one line per reason: a slice that is not merged, a
14
+ slice with no recorded pull request, a slice that says `runbook: yes` and neither changed a
15
+ section of the runbook nor gave a Runbook line that begins "no operational change", or a record
16
+ that already exists. Print those lines to the human and stop: the release waits for each one.
17
+ 2. Run `{{cli}} branch release <slug>`, the slug being the phase in lower case (`p1` for `P1`). It
18
+ puts the session on `release/<slug>` at the tip of the default branch as origin has it; a
19
+ `release/<slug>` left behind that tip with no commit of its own is moved there, and the command
20
+ says so. When `release/<slug>` holds commits the default branch lacks, it asks the git host for
21
+ an open pull request of that branch and exits 1 with one of three lines:
22
+ 1. `release/<slug> is the branch of open pull request #<n> (<url>); the phase's release is
23
+ already open`: print the line to the human and stop. Take no other slug: merging or closing
24
+ that pull request is the human's.
25
+ 2. A line saying the git host could not be asked: print it to the human and stop. Take no other
26
+ slug.
27
+ 3. A line that names the next slug (`p1-2`): no pull request of that branch is open, so run the
28
+ command again with that slug.
29
+ 3. Run `{{cli}} release {{args}}`. It prints the record's path, `<docsRoot>/releases/{{args}}.md`,
30
+ then one `released <slice>` line per slice, and rewrites `BUILD.md`. When it exits 1, print its
31
+ lines to the human and stop.
32
+ 4. Run `{{cli}} check` and fix each finding it prints until it reports `0 findings`. Never edit the
33
+ record by hand. A finding in the record points at text the record quotes, and is fixed there:
34
+ 1. Run `{{cli}} release {{args}} --undo`. It removes the record, which is not committed yet, and
35
+ puts the state files and `BUILD.md` back as they were, so no change is left in the session.
36
+ 2. A pull request title or body is corrected on the host. The runbook or a decision row is
37
+ corrected on its own pull request, which a human merges; tell the human what to correct, and
38
+ stop until it has merged.
39
+ 3. Start again at step 1, with the same slug in step 2.
40
+ 5. Write the pull request body to a file outside the repository, with these three sections:
41
+
42
+ ```
43
+ **Done when:** every slice of {{args}} released
44
+ **Proof:** <the summary line check printed>
45
+ **Decisions:** <the lines under "## Decisions" in the record, one per line, or "none">
46
+ ```
47
+
48
+ 6. Run `{{cli}} pr open --title "[release] {{args}}" --body-file <file> --commit "docs(release): {{args}}" --paths <docsRoot>/releases/{{args}}.md,.slicekit/state,BUILD.md`.
49
+ 7. Print the pull request line `pr open` printed, and tell the human that merging the pull request
50
+ is the release of {{args}} in this repository, and that it deploys nothing: deployment stays the
51
+ team's (D-12).