@erclx/canon 5.36.0 → 5.37.0

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.
Files changed (127) hide show
  1. package/claude/.claude-plugin/plugin.json +1 -1
  2. package/claude/skills/api-design/SKILL.md +6 -0
  3. package/claude/skills/backlog-triage/SKILL.md +7 -7
  4. package/claude/skills/build-in-slices/SKILL.md +6 -0
  5. package/claude/skills/build-in-slices/references/adopted.md +3 -0
  6. package/claude/skills/canon-cli/SKILL.md +3 -0
  7. package/claude/skills/canon-feedback/SKILL.md +5 -0
  8. package/claude/skills/canon-feedback-triage/SKILL.md +3 -0
  9. package/claude/skills/canvas-board/SKILL.md +3 -0
  10. package/claude/skills/canvas-board/references/canvas.md +12 -0
  11. package/claude/skills/ci-workflow/SKILL.md +5 -0
  12. package/claude/skills/code-craft/SKILL.md +6 -0
  13. package/claude/skills/context-fold/references/context.md +48 -34
  14. package/claude/skills/create-rule/SKILL.md +11 -9
  15. package/claude/skills/create-rule/references/rule.md +6 -0
  16. package/claude/skills/create-skill/SKILL.md +11 -2
  17. package/claude/skills/create-skill/references/skill-disclosure.md +26 -0
  18. package/claude/skills/create-skill/references/skill-paths.md +3 -0
  19. package/claude/skills/create-skill/references/skill-reference.md +12 -0
  20. package/claude/skills/create-skill/references/skill.md +25 -24
  21. package/claude/skills/deprecation-migration/SKILL.md +6 -0
  22. package/claude/skills/deprecation-migration/references/adopted.md +3 -0
  23. package/claude/skills/design-taste/SKILL.md +6 -0
  24. package/claude/skills/design-taste/references/craft.md +3 -0
  25. package/claude/skills/design-taste/references/preflight.md +16 -0
  26. package/claude/skills/docs-sync/references/docs.md +6 -0
  27. package/claude/skills/docs-sync/references/readme.md +15 -0
  28. package/claude/skills/draft-and-pick/SKILL.md +12 -0
  29. package/claude/skills/draft-doc/references/context.md +1 -1
  30. package/claude/skills/draft-doc/references/readme.md +3 -0
  31. package/claude/skills/draft-figure/references/mermaid.md +6 -0
  32. package/claude/skills/draft-slides/SKILL.md +3 -0
  33. package/claude/skills/git-branch/references/branch.md +16 -11
  34. package/claude/skills/git-commit/references/commit.md +19 -11
  35. package/claude/skills/git-commit/references/versioning.md +9 -0
  36. package/claude/skills/git-issue/references/issue.md +12 -9
  37. package/claude/skills/git-pr/SKILL.md +5 -0
  38. package/claude/skills/git-pr/references/pr.md +24 -6
  39. package/claude/skills/git-ship/SKILL.md +3 -0
  40. package/claude/skills/git-split/SKILL.md +6 -0
  41. package/claude/skills/git-stage/SKILL.md +3 -0
  42. package/claude/skills/git-worktree/SKILL.md +6 -6
  43. package/claude/skills/markdown-craft/references/markdown.md +24 -6
  44. package/claude/skills/plan-feature/SKILL.md +9 -0
  45. package/claude/skills/plan-feature/references/plan.md +20 -8
  46. package/claude/skills/plan-groundwork/SKILL.md +6 -0
  47. package/claude/skills/plan-groundwork/references/groundwork.md +10 -7
  48. package/claude/skills/plan-intake/references/intake.md +6 -6
  49. package/claude/skills/read-frames/SKILL.md +3 -0
  50. package/claude/skills/review-craft/SKILL.md +3 -0
  51. package/claude/skills/review-ui/SKILL.md +6 -3
  52. package/claude/skills/role-orchestrator/SKILL.md +3 -0
  53. package/claude/skills/role-orchestrator/references/orchestrator-dispatch.md +7 -4
  54. package/claude/skills/role-orchestrator/references/orchestrator-refill.md +3 -0
  55. package/claude/skills/role-planner/SKILL.md +3 -0
  56. package/claude/skills/role-worker/SKILL.md +12 -0
  57. package/claude/skills/search-craft/SKILL.md +3 -0
  58. package/claude/skills/systematic-debugging/SKILL.md +6 -0
  59. package/claude/skills/target-check/references/domains.md +5 -0
  60. package/claude/skills/target-setup/SKILL.md +5 -0
  61. package/claude/skills/task-board/references/tasks.md +9 -6
  62. package/claude/skills/task-complete/references/archive.md +3 -0
  63. package/claude/skills/teach-workspace/SKILL.md +3 -0
  64. package/claude/skills/teach-workspace/references/glossary.md +3 -0
  65. package/claude/skills/teach-workspace/references/lesson-build.md +3 -0
  66. package/claude/skills/teach-workspace/references/lesson-craft.md +3 -0
  67. package/claude/skills/teach-workspace/references/teach.md +8 -8
  68. package/claude/skills/test-craft/SKILL.md +5 -0
  69. package/claude/skills/video-craft/SKILL.md +6 -0
  70. package/claude/skills/write-human/SKILL.md +9 -0
  71. package/docs/agents/capture.md +2 -0
  72. package/docs/agents/commands.md +54 -54
  73. package/docs/agents/context-audit-checks.md +6 -0
  74. package/docs/agents/context-audit.md +8 -8
  75. package/docs/agents/context-classify.md +2 -0
  76. package/docs/agents/drift-surfaces.md +5 -5
  77. package/docs/agents/gate.md +6 -7
  78. package/docs/agents/index.md +1 -1
  79. package/docs/agents/install-and-sync.md +2 -2
  80. package/docs/agents/markdown-audit-weight.md +11 -3
  81. package/docs/agents/markdown-audit.md +2 -2
  82. package/docs/agents/pr-frames.md +17 -3
  83. package/docs/agents/sessions-transfer.md +8 -6
  84. package/docs/agents/skills-audit.md +9 -1
  85. package/docs/target/scenarios.md +1 -1
  86. package/docs/target/standards-moved.md +20 -18
  87. package/docs/workflow/ai-workflow.md +3 -0
  88. package/docs/workflow/visual-design-workflow.md +5 -0
  89. package/package.json +2 -2
  90. package/src/cli/help.ts +1 -1
  91. package/src/commands/context.ts +29 -4
  92. package/src/commands/gate.ts +1 -8
  93. package/src/commands/markdown.ts +52 -0
  94. package/src/commands/pr.ts +17 -10
  95. package/src/context/audit.ts +83 -0
  96. package/src/context/classify/prompts.ts +6 -1
  97. package/src/context/gate.ts +6 -3
  98. package/src/gate/measures.ts +186 -1
  99. package/src/gate/sequencer.ts +0 -4
  100. package/src/gate/stages.ts +32 -27
  101. package/src/git/files.ts +30 -0
  102. package/src/gov/adapter.ts +2 -2
  103. package/src/gov/install.ts +2 -2
  104. package/src/gov/list.ts +1 -1
  105. package/src/gov/payload.ts +1 -1
  106. package/src/gov/stacks.ts +1 -1
  107. package/src/markdown/gate.ts +10 -0
  108. package/src/markdown/growth.ts +43 -0
  109. package/src/markdown/stacks.ts +74 -0
  110. package/src/markdown/structure.ts +72 -4
  111. package/src/migrate/rule-layout.ts +12 -12
  112. package/src/pr/frames.ts +66 -1
  113. package/src/sync/check.ts +23 -23
  114. package/tooling/astro/configs/tsconfig.json +1 -1
  115. package/tooling/astro/reference.md +2 -2
  116. package/tooling/base/configs/scripts/verify.json +1 -1
  117. package/tooling/base/configs/scripts/verify.ts +2 -8
  118. package/tooling/base/reference.md +10 -10
  119. package/tooling/base/seeds/canon/context/ci.md +4 -4
  120. package/tooling/base/seeds/canon/context/development.md +9 -9
  121. package/tooling/claude/seeds/.claude/hooks/scratch-guard.sh +8 -0
  122. package/tooling/vite-react/configs/tsconfig.json +1 -1
  123. package/tooling/vite-react/configs/vitest.config.ts +1 -1
  124. package/tooling/vite-react/reference.md +2 -2
  125. package/tooling/web/configs/src/test/setup.ts +1 -1
  126. package/tooling/web/manifest.toml +3 -3
  127. package/tooling/web/reference.md +1 -1
@@ -35,9 +35,14 @@ A record generated from a token source carries the values in tables instead, whi
35
35
 
36
36
  ### Skills
37
37
 
38
+ #### Reviewing and measuring
39
+
38
40
  - `canon:ui-checklist` for what a reviewer has to look at after UI changes, and what ships without a test
39
41
  - `canon:ux-audit` for UX gap detection on existing surfaces
40
42
  - `canon:ux-measure` for what a running surface costs to paint, read against published thresholds
43
+
44
+ #### Drafting
45
+
41
46
  - `canon:draft-and-pick` for a call settled by looking, drafting several candidates as frames on the canvas and taking your pick
42
47
  - `canon:canvas-board` for a direction worked out over several turns, drawn as HTML frames you drag, select, and restyle in the browser while the session reads your changes back. Only the pick moves into `canon/DESIGN.md`, since the canvas folder is gitignored
43
48
  - `canon:draft-identity` to draft a project's logo mark and compose it into an icon sequence and a social card, through `draft-and-pick`'s own render-and-pick loop. On an Astro project holding the card route scaffold, the card lands as a route the project keeps and is captured through a running server, so it reads the project's real stylesheet rather than typed copies of every color. Everywhere else it ships as a PNG and the run says so.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@erclx/canon",
3
3
  "type": "module",
4
- "version": "5.36.0",
4
+ "version": "5.37.0",
5
5
  "description": "Runs your agent's work and keeps its code good, on one setup for every repo.",
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "test": "bun --bun vitest run",
33
33
  "prepare": "husky",
34
34
  "check": "bun src/cli.ts gate run",
35
- "check:ci": "bun src/cli.ts gate run --all --no-write",
35
+ "check:ci": "bun src/cli.ts gate run --all",
36
36
  "update": "bun update --interactive && bun run check",
37
37
  "clean": "rm -rf node_modules && bun pm cache rm && bun install",
38
38
  "bootstrap": "./scripts/core/bootstrap.sh",
package/src/cli/help.ts CHANGED
@@ -130,7 +130,7 @@ const EXAMPLES = [
130
130
  'canon labels audit --json',
131
131
  'canon census --json',
132
132
  'canon audits run --json',
133
- 'canon gate run --all --no-write',
133
+ 'canon gate run --all',
134
134
  'canon upgrade --json',
135
135
  'canon upstream fetch --since 2.1.256 --json',
136
136
  ]
@@ -11,11 +11,14 @@ import {
11
11
  LENGTH_CHECKPOINT,
12
12
  matchesSiblings,
13
13
  measureFolders,
14
+ extraSections,
14
15
  missingSections,
15
16
  PROVENANCE_FOLDER,
17
+ ALLOWED_SECTIONS_BY_FOLDER,
16
18
  REQUIRED_SECTIONS,
17
19
  REQUIRED_SECTIONS_BY_FOLDER,
18
20
  requiredSections,
21
+ type ExtraSectionFinding,
19
22
  type SectionFinding,
20
23
  } from '@/context/audit'
21
24
  import { auditCitations, type CitationReport } from '@/context/citations'
@@ -640,6 +643,7 @@ async function runAudit(
640
643
  const entries = gateOnly ? [] : await measureFolders(root, folders)
641
644
  const drift = gateOnly ? [] : await auditIndexes(folders)
642
645
  const sections = gateOnly ? [] : missingSections(root, folders, entries)
646
+ const extras = gateOnly ? [] : extraSections(entries)
643
647
  const length = gateOnly ? undefined : lengthFindings(entries)
644
648
  // Absent under `--citations-only` and null when the project carries no
645
649
  // record. A run that never looked and a project with nothing to look at are
@@ -653,7 +657,7 @@ async function runAudit(
653
657
  reportScope(folders, unresolved)
654
658
  reportCitations(citations, cited)
655
659
  reportReferenceForm(entries, folders)
656
- reportSections(sections, folders)
660
+ reportSections(sections, extras, folders)
657
661
  reportLength(length ?? [])
658
662
  reportTables(entries)
659
663
  reportProvenance(entries, folders)
@@ -691,6 +695,7 @@ async function runAudit(
691
695
  // never opened an entry.
692
696
  length,
693
697
  missingSections: sections,
698
+ extraSections: extras,
694
699
  indexDrift: drift,
695
700
  // Null says the run opened the project and found no record, which a
696
701
  // target that never wrote one is entitled to. Absent says the run
@@ -705,6 +710,7 @@ async function runAudit(
705
710
  // caller that read it first, since removing it would break that
706
711
  // caller without an error.
707
712
  requiredSectionsByFolder: REQUIRED_SECTIONS_BY_FOLDER,
713
+ allowedSectionsByFolder: ALLOWED_SECTIONS_BY_FOLDER,
708
714
  },
709
715
  })}\n`,
710
716
  )
@@ -715,6 +721,7 @@ async function runAudit(
715
721
  requirementsOverWords:
716
722
  requirements !== undefined && isOverWordCap(requirements),
717
723
  sections,
724
+ extraSections: extras,
718
725
  drift,
719
726
  widened,
720
727
  })
@@ -905,6 +912,7 @@ function reportReferenceForm(
905
912
  */
906
913
  function reportSections(
907
914
  missing: readonly SectionFinding[],
915
+ extras: readonly ExtraSectionFinding[],
908
916
  folders: readonly AuditedFolder[],
909
917
  ): void {
910
918
  logStep('Sections')
@@ -938,13 +946,30 @@ function reportSections(
938
946
 
939
947
  if (missing.length === 0) {
940
948
  logInfo('Every entry declares each required section.')
949
+ } else {
950
+ logWarn(`${plural(missing.length, 'path')} short a required section`)
951
+ pipeOutput(
952
+ missing
953
+ .map((found) => `${found.rel} missing: ${found.missing.join(', ')}`)
954
+ .join('\n'),
955
+ )
956
+ }
957
+
958
+ logInfo(
959
+ `The set is closed: ${Object.entries(ALLOWED_SECTIONS_BY_FOLDER)
960
+ .map(([name, set]) => `canon/${name}/ allows ${set.join(', ')}`)
961
+ .join('. ')} as H2. Any other topic is an H3 under one of them.`,
962
+ )
963
+
964
+ if (extras.length === 0) {
965
+ logInfo('No entry carries an H2 outside the set.')
941
966
  return
942
967
  }
943
968
 
944
- logWarn(`${plural(missing.length, 'path')} short a required section`)
969
+ logWarn(`${plural(extras.length, 'path')} carrying an H2 outside the set`)
945
970
  pipeOutput(
946
- missing
947
- .map((found) => `${found.rel} missing: ${found.missing.join(', ')}`)
971
+ extras
972
+ .map((found) => `${found.rel} extra: ${found.headings.join(', ')}`)
948
973
  .join('\n'),
949
974
  )
950
975
  }
@@ -27,7 +27,6 @@ import { repairBareFlag } from '@/worktrees/bare-flag'
27
27
 
28
28
  interface RunCommandOptions {
29
29
  readonly all?: boolean
30
- readonly write?: boolean
31
30
  readonly nested?: boolean
32
31
  readonly json?: boolean
33
32
  }
@@ -48,10 +47,6 @@ export function register(program: Command): void {
48
47
  '--all',
49
48
  'Run every stage instead of scoping shell, types, and tests to changed files',
50
49
  )
51
- .option(
52
- '--no-write',
53
- 'Check formatting instead of applying it, which is what a merge gate wants',
54
- )
55
50
  .option(
56
51
  '--nested',
57
52
  'Suppress the outer frame when another script opened one',
@@ -77,7 +72,7 @@ export function register(program: Command): void {
77
72
  '',
78
73
  'Examples:',
79
74
  ' canon gate run',
80
- ' canon gate run --all --no-write',
75
+ ' canon gate run --all',
81
76
  ' canon gate run --json',
82
77
  '',
83
78
  ].join('\n'),
@@ -92,7 +87,6 @@ async function runGate(opts: RunCommandOptions): Promise<number> {
92
87
  const mismatch = checkoutMismatchWarning(process.cwd())
93
88
  const emitJson = opts.json ?? false
94
89
  const nested = opts.nested ?? false
95
- const write = opts.write ?? true
96
90
  const run = commandRunner(root)
97
91
 
98
92
  if (!emitJson && !nested) intro('canon gate run')
@@ -111,7 +105,6 @@ async function runGate(opts: RunCommandOptions): Promise<number> {
111
105
  ci: process.env.CI === 'true',
112
106
  run,
113
107
  cli: cliRunner(root),
114
- write,
115
108
  changed: changed.scoped ? changed.files : undefined,
116
109
  onQueue: (label, holder) => {
117
110
  const text = `${label} is waiting for the suite pid ${holder.pid} runs at ${holder.root}`
@@ -18,6 +18,7 @@ import {
18
18
  bodyLines,
19
19
  scanBans,
20
20
  } from '@/markdown/scan'
21
+ import { bulletStacks, CAP, type StackFinding } from '@/markdown/stacks'
21
22
  import {
22
23
  BASELINE,
23
24
  CHECKPOINTS,
@@ -59,6 +60,7 @@ interface FileReport {
59
60
  readonly links: readonly LinkFinding[]
60
61
  readonly colons: readonly ColonFinding[]
61
62
  readonly headingCase: readonly HeadingCaseFinding[]
63
+ readonly bulletStacks: readonly StackFinding[]
62
64
  readonly structure: StructureReport
63
65
  readonly renderedLines: number
64
66
  /** The stated reason, or null where the document is not exempt. */
@@ -101,6 +103,10 @@ export function register(program: Command): void {
101
103
  'report the same way. A proper noun is the one case the second cannot',
102
104
  'tell from title case, and the first is sometimes right.',
103
105
  '',
106
+ 'Bullet stacks report a run of more than 5 plain bullets under one',
107
+ 'heading and never exit 2. The Bullet stacks gate stage owns that',
108
+ 'verdict, for the reason the length line below states.',
109
+ '',
104
110
  'Length reports a whole document past the ceiling and never exits 2.',
105
111
  'The Document ceiling gate stage owns that verdict, since this audit also',
106
112
  'runs on a record kept out of version control, where a long plan is not',
@@ -178,6 +184,7 @@ async function runAudit(
178
184
  bans: scanBans(lines, bans),
179
185
  colons: advisory ? findColons(lines) : [],
180
186
  headingCase: advisory ? findHeadingCase(source) : [],
187
+ bulletStacks: advisory ? bulletStacks(lines) : [],
181
188
  links: findBrokenLinks(lines, (path) =>
182
189
  existsSync(resolve(dirname(abs), path)),
183
190
  ),
@@ -194,6 +201,7 @@ async function runAudit(
194
201
  reportLinks(reports, root)
195
202
  reportColons(reports)
196
203
  reportHeadingCase(reports)
204
+ reportStacks(reports)
197
205
  reportBullets(reports, checkpoints)
198
206
  reportParagraphs(reports, checkpoints)
199
207
  reportCadence(reports, checkpoints)
@@ -229,6 +237,7 @@ async function runAudit(
229
237
  links: report.links,
230
238
  colons: report.colons,
231
239
  headingCase: report.headingCase,
240
+ bulletStacks: report.bulletStacks,
232
241
  longestRun: report.structure.longestRun,
233
242
  longestRunLine: report.structure.longestRunLine,
234
243
  heavyBullets: report.structure.heavyBullets,
@@ -251,6 +260,7 @@ async function runAudit(
251
260
  structure: reports.map((report) => report.structure),
252
261
  colons: reports.flatMap((report) => report.colons),
253
262
  headingCase: reports.flatMap((report) => report.headingCase),
263
+ bulletStacks: reports.flatMap((report) => report.bulletStacks),
254
264
  })
255
265
 
256
266
  return gating ? EXIT_GATE : 0
@@ -404,6 +414,48 @@ function reportLinks(reports: readonly FileReport[], root: string): void {
404
414
  )
405
415
  }
406
416
 
417
+ function reportStacks(reports: readonly FileReport[]): void {
418
+ logStep('Bullet stacks')
419
+ logInfo(
420
+ `A run of more than ${CAP} top-level bullets, with no paragraph or heading between them.`,
421
+ )
422
+ logInfo(
423
+ 'A run whose every item opens with a bold label or a link is exempt. This never fails a run. The Bullet stacks gate stage owns that verdict.',
424
+ )
425
+
426
+ const carrying = reports
427
+ .filter((report) => report.bulletStacks.length > 0)
428
+ .sort((a, b) => longestStack(b) - longestStack(a))
429
+
430
+ if (carrying.length === 0) {
431
+ logInfo(`No run past ${CAP} bullets.`)
432
+ return
433
+ }
434
+
435
+ const total = carrying.reduce(
436
+ (sum, report) => sum + report.bulletStacks.length,
437
+ 0,
438
+ )
439
+ logWarn(`${plural(total, 'stack')} across ${plural(carrying.length, 'file')}`)
440
+ logInfo(
441
+ 'Fold the run into prose, give each item an H3, or split the list at its seam.',
442
+ )
443
+ pipeOutput(
444
+ carrying
445
+ .map(
446
+ (report) =>
447
+ `${report.rel} ${plural(report.bulletStacks.length, 'stack')}\n${report.bulletStacks
448
+ .map((found) => ` :${found.line} ${found.count} bullets`)
449
+ .join('\n')}`,
450
+ )
451
+ .join('\n'),
452
+ )
453
+ }
454
+
455
+ function longestStack(report: FileReport): number {
456
+ return Math.max(0, ...report.bulletStacks.map((found) => found.count))
457
+ }
458
+
407
459
  function reportColons(reports: readonly FileReport[]): void {
408
460
  logStep('Colons')
409
461
  logInfo(
@@ -44,7 +44,7 @@ import {
44
44
  settleChecklist,
45
45
  } from '@/pr/evidence'
46
46
  import {
47
- dropFrames,
47
+ dropFramesWithLegacy,
48
48
  FRAMES_BRANCH,
49
49
  type FramesApi,
50
50
  type FramesRefusal,
@@ -53,7 +53,8 @@ import {
53
53
  isFrameHead,
54
54
  isFramePass,
55
55
  isFrameTheme,
56
- pruneFrames,
56
+ LEGACY_FRAMES_BRANCH,
57
+ pruneFramesWithLegacy,
57
58
  pushFrame,
58
59
  readFrame,
59
60
  type TreeEntry,
@@ -933,7 +934,7 @@ export function register(program: Command): void {
933
934
  'after',
934
935
  [
935
936
  '',
936
- `Writes only refs/heads/${FRAMES_BRANCH}, through the GitHub git data API,`,
937
+ `An add writes only refs/heads/${FRAMES_BRANCH}, through the GitHub git data API,`,
937
938
  'so nothing is checked out and no other branch is touched. A frame lands',
938
939
  'at pr-<number>/<short-head>/<pass>/box-<n>.png, or box-<n>-<theme>.png',
939
940
  'with --theme, and `link` names that',
@@ -948,6 +949,11 @@ export function register(program: Command): void {
948
949
  'request still open, reopened, closed exactly the given days ago, or one',
949
950
  'whose state could not be read, listing that last kind under `unread`.',
950
951
  '',
952
+ `Both also drain the ${LEGACY_FRAMES_BRANCH} branch a rename left behind,`,
953
+ 'removing only, and carry `legacy: true` when it changed. --prune empties',
954
+ 'it as its pull requests expire, and --drop clears one pull request at',
955
+ 'once. An add never writes it.',
956
+ '',
951
957
  'Read `reason` on the JSON record:',
952
958
  ' ok an add pushed, or a drop or prune finished',
953
959
  ' bad-mode not exactly one of --add, --drop, --prune',
@@ -2876,13 +2882,13 @@ function isTreeEntry(value: unknown): value is TreeEntry {
2876
2882
  * that already exists or no longer does, which is another writer's doing and
2877
2883
  * worth a re-read rather than a failure.
2878
2884
  */
2879
- function ghFramesApi(call: ApiCaller): FramesApi {
2880
- const ref = `git/refs/heads/${FRAMES_BRANCH}`
2885
+ function ghFramesApi(call: ApiCaller, branch: string): FramesApi {
2886
+ const ref = `git/refs/heads/${branch}`
2881
2887
  const refWrite = (result: ApiCall) =>
2882
2888
  result.ok ? 'ok' : result.status === 422 ? 'conflict' : 'failed'
2883
2889
  return {
2884
2890
  async readTip() {
2885
- const head = await call('GET', `git/ref/heads/${FRAMES_BRANCH}`)
2891
+ const head = await call('GET', `git/ref/heads/${branch}`)
2886
2892
  if (!head.ok) {
2887
2893
  return head.status === 404
2888
2894
  ? { kind: 'missing' }
@@ -2937,7 +2943,7 @@ function ghFramesApi(call: ApiCaller): FramesApi {
2937
2943
  async createRef(commit) {
2938
2944
  return refWrite(
2939
2945
  await call('POST', 'git/refs', {
2940
- ref: `refs/heads/${FRAMES_BRANCH}`,
2946
+ ref: `refs/heads/${branch}`,
2941
2947
  sha: commit,
2942
2948
  }),
2943
2949
  )
@@ -3034,7 +3040,8 @@ async function runFrames(
3034
3040
 
3035
3041
  if (Bun.which('gh') === null) return refuseFrames('gh-missing')
3036
3042
  const runner = ghApiRunner(root)
3037
- const api = ghFramesApi(runner.call)
3043
+ const api = ghFramesApi(runner.call, FRAMES_BRANCH)
3044
+ const legacyApi = ghFramesApi(runner.call, LEGACY_FRAMES_BRANCH)
3038
3045
  const refuseWrite = (reason: FramesRefusal) =>
3039
3046
  refuseFrames(
3040
3047
  reason === 'push-failed' && runner.refusedWrites.length > 0
@@ -3059,7 +3066,7 @@ async function runFrames(
3059
3066
 
3060
3067
  if (opts.prune !== undefined) {
3061
3068
  const days = Number(opts.prune)
3062
- const result = await pruneFrames(api, days, new Date())
3069
+ const result = await pruneFramesWithLegacy(api, legacyApi, days, new Date())
3063
3070
  if (result.kind === 'refused') return refuseWrite(result.reason)
3064
3071
  const { kind: _kind, ...rest } = result
3065
3072
  return finish({ days, ...rest }, [
@@ -3072,7 +3079,7 @@ async function runFrames(
3072
3079
 
3073
3080
  const pull = Number(number)
3074
3081
  if (opts.drop === true) {
3075
- const result = await dropFrames(api, [pull])
3082
+ const result = await dropFramesWithLegacy(api, legacyApi, [pull])
3076
3083
  if (result.kind === 'refused') return refuseWrite(result.reason)
3077
3084
  const { kind: _kind, ...rest } = result
3078
3085
  return finish({ number: pull, ...rest }, [
@@ -63,6 +63,22 @@ export const REQUIRED_SECTIONS_BY_FOLDER: Readonly<
63
63
  context: ['Overview', 'Layout'],
64
64
  }
65
65
 
66
+ /**
67
+ * The closed set of H2 sections per audited folder name, which a required
68
+ * section belongs to. An entry carrying another H2 is a finding under
69
+ * `--gate`, since the set is what makes a context entry cheap to find a fact
70
+ * in: a domain's own topic names go one level down as H3 items under
71
+ * `Decisions` and `Gotchas`.
72
+ *
73
+ * Held beside the required lists for the same reason they are held here, and
74
+ * keyed on the folder whose standard states it.
75
+ */
76
+ export const ALLOWED_SECTIONS_BY_FOLDER: Readonly<
77
+ Record<string, readonly string[]>
78
+ > = {
79
+ context: ['Overview', 'Layout', 'Decisions', 'Gotchas'],
80
+ }
81
+
66
82
  /**
67
83
  * The context standard's list, kept as its own export because the audit record
68
84
  * has published it flat under `checkpoints.requiredSections` since before any
@@ -225,6 +241,12 @@ export interface EntryReport {
225
241
  * is `missingSections`, since one entry answers for its siblings.
226
242
  */
227
243
  readonly sections: readonly string[]
244
+ /**
245
+ * H2 headings outside the folder's closed set, in document order, and empty
246
+ * outside a folder whose standard states one. What the folder carries in
247
+ * all is `extraSections`.
248
+ */
249
+ readonly otherSections: readonly string[]
228
250
  /**
229
251
  * Whether the file declares itself a skeleton, which excludes it from the
230
252
  * section check alone. Every other measure still reads it, since a stub is
@@ -281,6 +303,13 @@ export interface LengthFinding {
281
303
  readonly causes: readonly LengthCause[]
282
304
  }
283
305
 
306
+ export interface ExtraSectionFinding {
307
+ /** Repo-relative path of the entry carrying the headings. */
308
+ readonly rel: string
309
+ /** H2 headings outside the closed set, never empty. */
310
+ readonly headings: readonly string[]
311
+ }
312
+
284
313
  export interface SectionFinding {
285
314
  /**
286
315
  * Repo-relative path of whatever owes the sections: the entry itself in the
@@ -442,6 +471,33 @@ function declaredSections(
442
471
  return required.filter((section) => found.has(section))
443
472
  }
444
473
 
474
+ const H2_TEXT = /^##\s+(.+?)\s*$/
475
+
476
+ /**
477
+ * Finds the H2 headings outside the allowed set.
478
+ *
479
+ * H2 only, since the set closes the sections of an entry and says nothing of
480
+ * where its H3 items sit. Fenced blocks are skipped, so a template quoted
481
+ * inside an example declares nothing about the entry quoting it.
482
+ */
483
+ function otherSections(
484
+ lines: readonly BodyLine[],
485
+ allowed: readonly string[],
486
+ ): string[] {
487
+ if (allowed.length === 0) return []
488
+
489
+ const found: string[] = []
490
+
491
+ for (const line of lines) {
492
+ if (line.fenced) continue
493
+
494
+ const match = line.text.match(H2_TEXT)
495
+ if (match && !allowed.includes(match[1])) found.push(match[1])
496
+ }
497
+
498
+ return found
499
+ }
500
+
445
501
  /**
446
502
  * Finds the references naming a sibling entry by bare filename.
447
503
  *
@@ -500,6 +556,7 @@ export function measureEntry(
500
556
  governsContent = true,
501
557
  siblings: readonly string[] = [],
502
558
  required: readonly string[] = governsContent ? REQUIRED_SECTIONS : [],
559
+ allowed: readonly string[] = [],
503
560
  ): EntryReport {
504
561
  const lines = bodyLines(source)
505
562
 
@@ -510,6 +567,7 @@ export function measureEntry(
510
567
  provenance: governsContent ? provenance(lines) : [],
511
568
  bareReferences: bareReferences(lines, siblings),
512
569
  sections: declaredSections(lines, required),
570
+ otherSections: otherSections(lines, allowed),
513
571
  stub: isStubSeed(source),
514
572
  governed: governsContent,
515
573
  }
@@ -589,6 +647,7 @@ export async function measureFolders(
589
647
  governsContent(folder),
590
648
  names.filter((name) => name !== self),
591
649
  requiredSections(folder),
650
+ allowedSections(folder),
592
651
  ),
593
652
  )
594
653
  }
@@ -609,6 +668,13 @@ export function requiredSections(folder: AuditedFolder): readonly string[] {
609
668
  : []
610
669
  }
611
670
 
671
+ /** Names the H2 sections the folder's standard allows, empty where it states no set. */
672
+ export function allowedSections(folder: AuditedFolder): readonly string[] {
673
+ return Object.hasOwn(ALLOWED_SECTIONS_BY_FOLDER, folder.name)
674
+ ? ALLOWED_SECTIONS_BY_FOLDER[folder.name]
675
+ : []
676
+ }
677
+
612
678
  /**
613
679
  * Reports whether a bare sibling name here is a reference by construction.
614
680
  *
@@ -688,3 +754,20 @@ export function missingSections(
688
754
 
689
755
  return findings
690
756
  }
757
+
758
+ /**
759
+ * Names each entry carrying an H2 outside its folder's closed set.
760
+ *
761
+ * Per entry rather than per folder, unlike `missingSections`: a split folder's
762
+ * entries each answer for their own headings, since an extra section is a fact
763
+ * about the file it sits in. A stub seed is dropped for the reason
764
+ * `missingSections` drops one, a skeleton being exempt from the shape rather
765
+ * than from being well formed.
766
+ */
767
+ export function extraSections(
768
+ entries: readonly EntryReport[],
769
+ ): ExtraSectionFinding[] {
770
+ return entries
771
+ .filter((entry) => !entry.stub && entry.otherSections.length > 0)
772
+ .map((entry) => ({ rel: entry.rel, headings: entry.otherSections }))
773
+ }
@@ -2,7 +2,10 @@
2
2
  * System prompts and user-message builders for the model layer, ported
3
3
  * verbatim as data from the groundwork spike at
4
4
  * `.canon/groundwork/93-canonical-doc-drift/scripts/prompts/v3.md` (diff
5
- * mode) and `sweep-v1.md` (sweep mode). Neither prompt text is invented here.
5
+ * mode) and `sweep-v1.md` (sweep mode). The diff prompt is verbatim. The sweep
6
+ * prompt was tuned past `sweep-v1.md` with one decision check, measured
7
+ * against the groundwork's labelled set in
8
+ * `canon/context/context-model/overview.md`.
6
9
  *
7
10
  * Each prompt already states its own rules per canonical doc type inside one
8
11
  * string, which is the shape the spike measured, so there is one prompt per
@@ -45,6 +48,8 @@ Decision checks, in order:
45
48
  1. Judge what the text says, not how long it is. A long section that states current design once is KEEP.
46
49
  2. A trailing "Measured at <sha> on <date>" does not make a paragraph current if another paragraph in the section states an older value on the same subject.
47
50
  3. Short rationale for a current rule ("the form checks length itself because...") is KEEP. A story of the rounds that produced the rule is REWRITE.
51
+ 4. Rationale is KEEP even when it is told in the past tense. A reason naming why an alternative was left out, what an earlier approach got wrong, what a measurement caught, or what a past run cost is the evidence for the current rule, so a sentence such as "the first form timed out" or "two runs took 1281s and 1924s" or "reading figures from real data caught three wrong claims" supports a rule that stands and stays KEEP. Past tense alone is never the test.
52
+ 5. REWRITE needs the section to restate its own subject as a sequence: a superseded figure kept beside its replacement, "now" or "no longer" marking a change, branch or PR narration, or rounds of candidates. A maintenance step or an operator decision stated as a rule is current, not history.
48
53
 
49
54
  Return only JSON: {"verdict": "...", "quotes": ["<up to three short phrases copied from the section that decided it>"], "reason": "<one sentence>"}
50
55
  `
@@ -1,4 +1,4 @@
1
- import type { SectionFinding } from '@/context/audit'
1
+ import type { ExtraSectionFinding, SectionFinding } from '@/context/audit'
2
2
  import type { FolderDrift } from '@/context/index-drift'
3
3
 
4
4
  export interface GateInput {
@@ -13,6 +13,8 @@ export interface GateInput {
13
13
  */
14
14
  readonly requirementsOverWords: boolean
15
15
  readonly sections: readonly SectionFinding[]
16
+ /** H2 headings outside a folder's closed set, gating under `--gate` alone. */
17
+ readonly extraSections: readonly ExtraSectionFinding[]
16
18
  readonly drift: readonly FolderDrift[]
17
19
  /**
18
20
  * Whether the caller asked for the widened gate. False leaves a missing
@@ -36,7 +38,7 @@ export function hasDrift(drift: readonly FolderDrift[]): boolean {
36
38
  * does a requirements record past its own word cap: the record states its rule
37
39
  * for itself, which makes it a fact rather than a threshold a reader weighs. The findings `--gate` adds are
38
40
  * the ones answerable from the file itself: a required section it does not
39
- * declare, and an index disagreeing with its folder. Entry length, depth, bullet,
41
+ * declare, an H2 outside the closed set, and an index disagreeing with its folder. Entry length, depth, bullet,
40
42
  * table, provenance, and the record's claim coverage are judgments, so they
41
43
  * stay out under both modes.
42
44
  */
@@ -44,6 +46,7 @@ export function isGating({
44
46
  unresolvedCitations,
45
47
  requirementsOverWords,
46
48
  sections,
49
+ extraSections,
47
50
  drift,
48
51
  widened,
49
52
  }: GateInput): boolean {
@@ -51,5 +54,5 @@ export function isGating({
51
54
  if (requirementsOverWords) return true
52
55
  if (!widened) return false
53
56
 
54
- return sections.length > 0 || hasDrift(drift)
57
+ return sections.length > 0 || extraSections.length > 0 || hasDrift(drift)
55
58
  }