@erclx/canon 4.19.0 → 4.19.1
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/claude/.claude-plugin/plugin.json +1 -1
- package/claude/skills/claude-autoship/SKILL.md +1 -1
- package/claude/skills/git-pr/references/labels.md +1 -1
- package/docs/agents/key-changes.md +3 -1
- package/docs/agents/label-coverage.md +7 -5
- package/docs/agents/test-order.md +7 -5
- package/package.json +1 -1
- package/src/commands/pr.ts +1 -1
- package/src/git-files.ts +15 -11
- package/src/gov/test-order.ts +12 -9
- package/src/labels/audit.ts +6 -2
|
@@ -11,7 +11,7 @@ Chain the post-plan pipeline in a single run. Every step has a stop condition. S
|
|
|
11
11
|
## Guards
|
|
12
12
|
|
|
13
13
|
- All `.canon/plans/` and `.canon/review/` reads resolve at the main worktree root, not the current worktree. Resolve that root the way `claude-worktree` does.
|
|
14
|
-
- Derive `<slug>` per `${CLAUDE_SKILL_DIR}/../../standards/slug.md`. This skill takes the stop rather than the `latest` fallback, since it commits and opens a pull request. If empty, stop: `❌ Detached HEAD. Checkout the feature branch first.` Every later step keys its output on
|
|
14
|
+
- Derive `<slug>` per `${CLAUDE_SKILL_DIR}/../../standards/slug.md`. This skill takes the stop rather than the `latest` fallback, since it commits and opens a pull request. If empty, stop: `❌ Detached HEAD. Checkout the feature branch first.` This slug is provisional. It is superseded once `claude-worktree` runs, whether at Step 0 or before this chain began. Every later step keys its output on the slug that run resolves, being the worktree, the review receipt, the branch, and the memory proposal, regardless of which plan Step 1 reads.
|
|
15
15
|
- Resolve `<plan>` in Step 1, ahead of any other read.
|
|
16
16
|
- If the working tree has uncommitted changes unrelated to the plan, stop: `❌ Uncommitted changes outside the plan. Commit or stash before autoshipping.`
|
|
17
17
|
|
|
@@ -61,7 +61,7 @@ What it leaves unmeasured is a prefix reaching no path, so a row left behind by
|
|
|
61
61
|
|
|
62
62
|
## Matching
|
|
63
63
|
|
|
64
|
-
- Take the changed set from `git diff --name-only <base
|
|
64
|
+
- Take the changed set from `git diff --name-only <base>...HEAD`, resolved against the same base as the diff the body is written from. The three dots hold whether `<base>` arrives already resolved to a merge base or as a bare ref name, where the two-dot form is correct only in the first case and hands the branch somebody else's merged paths in the second
|
|
65
65
|
- A path earns a label when the path starts with one of that label's prefixes
|
|
66
66
|
- Collect the distinct labels across the whole set, ordered as the map declares them, so two runs over one branch produce one string
|
|
67
67
|
- Pass the result as a single comma-separated value. An empty result runs no labelling step.
|
|
@@ -18,12 +18,14 @@ The positional is the pull request to read, defaulting to the one open on this b
|
|
|
18
18
|
| Option | Behavior |
|
|
19
19
|
| --------------- | ------------------------------------------------------------------ |
|
|
20
20
|
| `--body <path>` | Read the body from a file, taking the changed set from git instead |
|
|
21
|
-
| `--base <ref>` |
|
|
21
|
+
| `--base <ref>` | Ref the range runs back to when `--body` supplies the body |
|
|
22
22
|
| `--root <path>` | Repository to read, defaulting to the cwd |
|
|
23
23
|
| `--json` | Add a machine-readable record on stdout, keeping the frame |
|
|
24
24
|
|
|
25
25
|
`--body` decides where both halves come from, so a number passed beside it is never read. The body comes off disk and the changed set from the local range, which is the shape a fixture and a body still being drafted both need.
|
|
26
26
|
|
|
27
|
+
`--base` names the far side of that range and never the commit the comparison runs against directly. The reader resolves the merge base between `HEAD` and the ref, so `--base origin/main` measures what the branch wrote rather than what the trunk gained while the branch was open. Passing the trunk as it stands today is therefore safe on a branch of any age, and a ref sharing no history with `HEAD` refuses as `bad-base`.
|
|
28
|
+
|
|
27
29
|
Without `--body` the body, the file list, and the head commit come back from one `gh pr view` call, because the three have to describe the same commit and reading them apart leaves a window where a push between them compares a body against another head's files.
|
|
28
30
|
|
|
29
31
|
That view caps its file list at 100 rows and says nothing about having done so, which was measured against `#1250`: the pull request carries 101 files and the view reports 100. A pull request at the cap therefore takes a second read through the paginated endpoint, and a failure there refuses with `gh-truncated` rather than comparing against a set known to be short. A set silently one file short is the worst input this takes, since the missing file is exactly what a correct bullet would then be accused of inventing.
|
|
@@ -14,11 +14,13 @@ canon labels audit --base origin/main
|
|
|
14
14
|
canon labels audit src/cli.ts docs/index.md --json
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
| Option | Behavior
|
|
18
|
-
| --------------- |
|
|
19
|
-
| `--base <ref>` |
|
|
20
|
-
| `--root <path>` | Repository to read, defaulting to the current directory
|
|
21
|
-
| `--json` | Add a machine-readable record on stdout, keeping the frame
|
|
17
|
+
| Option | Behavior |
|
|
18
|
+
| --------------- | ---------------------------------------------------------- |
|
|
19
|
+
| `--base <ref>` | Ref the range runs back to, defaulting to the trunk |
|
|
20
|
+
| `--root <path>` | Repository to read, defaulting to the current directory |
|
|
21
|
+
| `--json` | Add a machine-readable record on stdout, keeping the frame |
|
|
22
|
+
|
|
23
|
+
`--base` names the far side of the range rather than the commit the diff runs against. The audit resolves the merge base between `HEAD` and the ref before reading anything, so `--base origin/main` on a branch the trunk has moved past still earns labels for the paths that branch wrote. Reading the ref literally is what once handed a long-open branch the labels for somebody else's merge, and it named those paths as uncovered surfaces on top.
|
|
22
24
|
|
|
23
25
|
Positional paths replace the range entirely. A caller holding a changed set already passes it rather than paying for a second git read, and the record then omits `base` to say the range was never resolved.
|
|
24
26
|
|
|
@@ -13,11 +13,11 @@ canon gov test-order --base origin/main --json
|
|
|
13
13
|
canon gov test-order --root ../my-app
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
| Option | Behavior
|
|
17
|
-
| --------------- |
|
|
18
|
-
| `--base <ref>` |
|
|
19
|
-
| `--root <path>` | Repository to read, defaulting to the current directory
|
|
20
|
-
| `--json` | Add a machine-readable record on stdout, keeping the frame
|
|
16
|
+
| Option | Behavior |
|
|
17
|
+
| --------------- | ---------------------------------------------------------- |
|
|
18
|
+
| `--base <ref>` | Ref the range runs back to, defaulting to the trunk |
|
|
19
|
+
| `--root <path>` | Repository to read, defaulting to the current directory |
|
|
20
|
+
| `--json` | Add a machine-readable record on stdout, keeping the frame |
|
|
21
21
|
|
|
22
22
|
Under `--json` the record holds stdout alone and the frame still renders on stderr, refusals included, which is the split `output-shape.md` fixes for every mode. A consumer reading stdout sees pure data, and an operator reading the terminal sees why a run refused rather than a command that appeared to do nothing.
|
|
23
23
|
|
|
@@ -27,6 +27,8 @@ The default range is the branch against the trunk, resolved as the merge base ag
|
|
|
27
27
|
|
|
28
28
|
Reading all history on every run measures work nobody is reviewing and buries the finding that matters under the ones already merged. `--base` widens or narrows it when a reader wants a different window.
|
|
29
29
|
|
|
30
|
+
A ref passed there is resolved the same way, through its merge base with `HEAD`, so it names the far side of the range and not the commit the range starts from. `--base origin/main` therefore reports the same window whether the trunk has moved since the branch left or not. Naming a commit the branch already carries still measures from that commit, since the merge base of `HEAD` and an ancestor is the ancestor, and a ref sharing no history with `HEAD` refuses as `bad-base`.
|
|
31
|
+
|
|
30
32
|
Only history is read. A file sitting in the working tree and in no commit is invisible here, which is the point: the verification run sees a tree at one moment, and the ordering exists nowhere but history.
|
|
31
33
|
|
|
32
34
|
## How a pair is decided
|
package/package.json
CHANGED
package/src/commands/pr.ts
CHANGED
|
@@ -66,7 +66,7 @@ const REFUSALS: Record<Refusal, string> = {
|
|
|
66
66
|
'git could not list this repository, so no path could be judged whole rather than partial.',
|
|
67
67
|
'no-base': 'No base resolves against the trunk. Fetch origin or pass --base.',
|
|
68
68
|
'bad-base':
|
|
69
|
-
'The ref passed to --base resolves to no commit
|
|
69
|
+
'The ref passed to --base shares no history with HEAD here, either because it resolves to no commit or because it sits on an unrelated root. Pass a ref this branch was taken from.',
|
|
70
70
|
'unreadable-changes':
|
|
71
71
|
'git could not list what this branch changed, so the set is unknown.',
|
|
72
72
|
'no-section': `This body carries no ## ${KEY_CHANGES} section, so it claims nothing to compare.`,
|
package/src/git-files.ts
CHANGED
|
@@ -18,24 +18,28 @@ async function git(
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* The far side of a branch range: the
|
|
22
|
-
* against the first trunk this repository carries.
|
|
21
|
+
* The far side of a branch range: the merge base against the ref a caller
|
|
22
|
+
* named, or against the first trunk this repository carries.
|
|
23
23
|
*
|
|
24
|
-
* A named ref
|
|
25
|
-
*
|
|
24
|
+
* A named ref names the far side rather than the comparison point, so it
|
|
25
|
+
* resolves through the merge base exactly as the trunk below does. Reading it
|
|
26
|
+
* literally is what let a trunk moving under an open branch report every path
|
|
27
|
+
* merged in between as one the branch had written. A caller naming an ancestor
|
|
28
|
+
* still gets that commit back, since the merge base of `HEAD` and an ancestor
|
|
29
|
+
* is the ancestor.
|
|
30
|
+
*
|
|
31
|
+
* A named ref that produces no merge base refuses rather than falling back,
|
|
32
|
+
* since measuring the trunk range instead would answer a question nobody
|
|
33
|
+
* asked. That covers a ref resolving to nothing and a ref sharing no history
|
|
34
|
+
* with `HEAD` alike, which no caller can separate.
|
|
26
35
|
*/
|
|
27
36
|
export async function resolveBaseRef(
|
|
28
37
|
root: string,
|
|
29
38
|
ref?: string,
|
|
30
39
|
): Promise<string | undefined> {
|
|
31
40
|
if (ref !== undefined) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
'--verify',
|
|
35
|
-
'--quiet',
|
|
36
|
-
`${ref}^{commit}`,
|
|
37
|
-
])
|
|
38
|
-
return resolved === undefined || resolved === '' ? undefined : resolved
|
|
41
|
+
const merged = await git(root, ['merge-base', 'HEAD', ref])
|
|
42
|
+
return merged === undefined || merged === '' ? undefined : merged
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
for (const trunk of TRUNK_REFS) {
|
package/src/gov/test-order.ts
CHANGED
|
@@ -335,11 +335,14 @@ export function readTestOrder(
|
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
/**
|
|
338
|
-
* The far side of the range. A ref the caller named
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
338
|
+
* The far side of the range. A ref the caller named resolves through the merge
|
|
339
|
+
* base against `head`, matching the no-ref branch below rather than taking the
|
|
340
|
+
* ref as the comparison point, so a trunk that has moved under the branch does
|
|
341
|
+
* not pull other people's merged commits into the range. A ref producing no
|
|
342
|
+
* merge base has to refuse, since falling back to the trunk there would measure
|
|
343
|
+
* a range nobody asked for. With no ref named, the merge base against the trunk
|
|
344
|
+
* scopes the run to the branch, and a repository carrying no trunk falls back
|
|
345
|
+
* to the root commit rather than refusing.
|
|
343
346
|
*/
|
|
344
347
|
function resolveBase(
|
|
345
348
|
root: string,
|
|
@@ -347,15 +350,15 @@ function resolveBase(
|
|
|
347
350
|
head: string,
|
|
348
351
|
): string | { kind: 'unreadable'; reason: TestOrderRefusal; message: string } {
|
|
349
352
|
if (ref !== undefined) {
|
|
350
|
-
const
|
|
351
|
-
if (
|
|
353
|
+
const merged = git(root, ['merge-base', head, ref])
|
|
354
|
+
if (merged === undefined || merged === '') {
|
|
352
355
|
return {
|
|
353
356
|
kind: 'unreadable',
|
|
354
357
|
reason: 'bad-base',
|
|
355
|
-
message: `Ref ${ref}
|
|
358
|
+
message: `Ref ${ref} shares no history with HEAD in ${root}. Pass a ref this branch was taken from.`,
|
|
356
359
|
}
|
|
357
360
|
}
|
|
358
|
-
return
|
|
361
|
+
return merged
|
|
359
362
|
}
|
|
360
363
|
|
|
361
364
|
for (const trunk of TRUNK_REFS) {
|
package/src/labels/audit.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { type MapRefusal, readLabelMap } from '@/labels/map'
|
|
|
10
10
|
* could not get, which is a broken invocation rather than a project that
|
|
11
11
|
* declared nothing.
|
|
12
12
|
*
|
|
13
|
-
* A named ref
|
|
13
|
+
* A named ref producing no merge base is its own reason. Folding it into
|
|
14
14
|
* `no-base` sends the caller who already passed `--base` a message telling
|
|
15
15
|
* them to pass `--base`.
|
|
16
16
|
*/
|
|
@@ -31,7 +31,11 @@ export type LabelAudit =
|
|
|
31
31
|
| { readonly kind: 'refused'; readonly reason: LabelAuditRefusal }
|
|
32
32
|
|
|
33
33
|
export interface LabelAuditOptions {
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Ref naming the far side of the range, which resolves through its merge
|
|
36
|
+
* base with `HEAD` rather than being compared against literally. Defaults to
|
|
37
|
+
* the trunk.
|
|
38
|
+
*/
|
|
35
39
|
readonly base?: string
|
|
36
40
|
/** A changed set the caller already holds, which skips git entirely. */
|
|
37
41
|
readonly paths?: readonly string[]
|