@llman-sdd/core 0.7.5 → 0.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llman-sdd/core",
3
- "version": "0.7.5",
3
+ "version": "0.8.1",
4
4
  "description": "Pure domain logic for llman-sdd (config, gherkin specs, validation, templates)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -66,8 +66,8 @@ export function localBranchExists(git: GitLike, name: string): boolean {
66
66
  * (r16 resolution order, not a tie-breaker) — because the user explicitly
67
67
  * configured it; anything else falls through to the chain untouched.
68
68
  */
69
- // Deliberately NOT shared with defaultBranchNameFn() in validation/staleness.ts
70
- // (that probe is local-only with a 'main' fallback — predecessor staleness parity). Do not merge.
69
+ // Local-only default-branch probe (no origin consultation) lives in callers that
70
+ // need it; this resolver honors explicit user config first (r16 order).
71
71
  export function defaultBranch(git: GitLike): string {
72
72
  const preferred = git.runOpt(['config', '--get', 'init.defaultBranch']);
73
73
  if (preferred !== null && preferred !== '' && localBranchExists(git, preferred)) {
package/src/index.ts CHANGED
@@ -60,6 +60,16 @@ export {
60
60
  type MigrateBlock,
61
61
  type MigrateResult,
62
62
  } from './spec/migrateNative.ts';
63
+ export { stripLegacyHeaderLines } from './spec/migrateScope.ts';
64
+ export {
65
+ MIGRATIONS,
66
+ findMigration,
67
+ knownMigrationIds,
68
+ isValidMigrationExpr,
69
+ migrationPrompt,
70
+ migrationOverviewLines,
71
+ type MigrationEntry,
72
+ } from './project/migrations.ts';
63
73
  export {
64
74
  MIGRATE_KINDS,
65
75
  isMigrateKind,
@@ -84,14 +94,9 @@ export type {
84
94
  ValidationLevel,
85
95
  ValidationReport,
86
96
  } from './validation/validate.ts';
87
- export { validateAllSpecs, validateCapability, applyStrict } from './validation/validate.ts';
97
+ export { validateAllSpecs, validateCapability } from './validation/validate.ts';
88
98
  export { buildDuplicatesFor, formatTotals } from './validation/validate.ts';
89
99
  export { splitVerb } from './config/changeId.ts';
90
- export {
91
- evaluateStaleness,
92
- notApplicableStaleness,
93
- type StalenessInfo,
94
- } from './validation/staleness.ts';
95
100
  export {
96
101
  checkChangeDoc,
97
102
  validateChange,
@@ -109,11 +114,9 @@ export {
109
114
  discoverRoots,
110
115
  isValidRoot,
111
116
  resolveInstanceRoot,
112
- scopeCrossings,
113
117
  ROOT_EXCLUDED_DIRS,
114
118
  type RootEntry,
115
119
  type RootsIo,
116
- type ScopeCrossing,
117
120
  } from './validation/roots.ts';
118
121
  export {
119
122
  expandRunCommand,
@@ -271,7 +274,6 @@ export {
271
274
  export {
272
275
  buildReview,
273
276
  renderReviewHtml,
274
- specRelFor,
275
277
  type ReviewInput,
276
278
  type ReviewKind,
277
279
  type ReviewResult,
@@ -28,7 +28,7 @@ Agent 该做什么:
28
28
  4. 迁移后运行 llman-sdd validate --specs --strict 与项目 BDD 套件,全绿为收口标准。
29
29
 
30
30
  人类该做什么:
31
- - 审阅 diff 与 req 语义;把 # scope: 指向该规范管辖的真实源码目录(scope 承载 staleness 扫描,自引用无意义)。
31
+ - 审阅 diff 与 req 语义;确认规范描述与源码现状一致(自引用无意义)。
32
32
 
33
33
  陷阱:
34
34
  - spec.toon 的引号转义存在两种历史风格("" 翻倍与 \\" 反斜杠),手工读表须逐一确认。
@@ -45,7 +45,7 @@ What the agent does:
45
45
  4. After migration run llman-sdd validate --specs --strict and the project BDD suite; all-green is the bar.
46
46
 
47
47
  What the human does:
48
- - Review the diff and the req semantics; point # scope: at the real source directory the spec governs (scope drives staleness scanning; self-references are useless).
48
+ - Review the diff and the req semantics; confirm the spec matches the current source (self-references are useless).
49
49
 
50
50
  Pitfalls:
51
51
  - spec.toon quoting has two historical escaping styles ("" doubling and \\" backslash); verify cell by cell.
@@ -58,8 +58,8 @@ const SPECS_FLATTEN_ZH = `llman-sdd project migrate --kind specs-flatten — 目
58
58
  Agent 该做什么:
59
59
  1. 仅处理「目录内只有一个 <cap>.feature、无其他文件」的纯目录;目标 specs/<cap>.feature 已存在(冲突)、目录内有多个 .feature、或有附属文件 → 报告并跳过,勿强迁。
60
60
  2. 用 git mv specs/<cap>/<cap>.feature specs/<cap>.feature 保留历史,然后删除空目录。
61
- 3. 检查该文件 # scope: 是否自引用自身路径,是则改写为真实源码目录。
62
- 4. 迁移后运行 llman-sdd validate --specs 确认无 stale 警告。
61
+ 3. 检查该文件头部遗留的历史注释行是否仍反映现状,失效则删除。
62
+ 4. 迁移后运行 llman-sdd validate --specs 确认结构门全绿。
63
63
 
64
64
  人类该做什么:
65
65
  - 审阅 git diff(move 保历史);确认 scope 指向真实管辖面。`;
@@ -71,8 +71,8 @@ Background: v1 placed capabilities in specs/<cap>/<cap>.feature directories; v2
71
71
  What the agent does:
72
72
  1. Only handle pure directories (exactly one <cap>.feature inside, nothing else); if the target specs/<cap>.feature already exists (conflict), the directory holds multiple .feature files, or there are auxiliary entries → report and skip, never force.
73
73
  2. git mv specs/<cap>/<cap>.feature specs/<cap>.feature to preserve history, then remove the emptied directory.
74
- 3. Check the file's # scope: for a self-referential path and rewrite it to the real source directory.
75
- 4. After migration run llman-sdd validate --specs and confirm no stale warning remains.
74
+ 3. Check the file's leftover legacy header comment lines and drop any that no longer reflect reality.
75
+ 4. After migration run llman-sdd validate --specs and confirm the structural gate is green.
76
76
 
77
77
  What the human does:
78
78
  - Review the git diff (moves keep history); confirm scope points at the real governed surface.`;
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Versioned migration registry (project migrate, drop-review-stamp-and-scope
3
+ * follow-up): one entry per supported upgrade path. Prompt bodies are English
4
+ * per the house language convention (CLI output language) and are meant to be
5
+ * handed to any agent verbatim — steps are executable commands, checks are
6
+ * user-verifiable assertions. Pure: no IO, no clock.
7
+ */
8
+
9
+ export interface MigrationEntry {
10
+ /** Registry key, shape `<from>-><to>` (exact-match lookup). */
11
+ id: string;
12
+ title: string;
13
+ /** Agent-executable commands, in order. */
14
+ steps: readonly string[];
15
+ /** Post-conditions the user (or the agent) can verify. */
16
+ checks: readonly string[];
17
+ }
18
+
19
+ export const MIGRATIONS: readonly MigrationEntry[] = [
20
+ {
21
+ id: '0.7.5->0.8.0',
22
+ title: 'Governance metadata retirement (`# reviewed-through:` stamp & `# scope:` header)',
23
+ steps: [
24
+ 'Run `llman-sdd project migrate strip-legacy-headers --dry-run` to preview the affected spec files.',
25
+ 'Run `llman-sdd project migrate strip-legacy-headers` to strip the legacy `# scope:` / `# reviewed-through:` header comment lines (idempotent).',
26
+ 'Run `llman-sdd init --update` to refresh the managed AGENTS blocks and agent skills.',
27
+ 'Run `llman-sdd validate --all --strict` — it must pass.',
28
+ ],
29
+ checks: [
30
+ 'No `# scope:` / `# reviewed-through:` header lines remain under `llmanspec/specs/**`.',
31
+ '`llman-sdd review` signal kinds are exactly unbound / locked / validate (no `stale`).',
32
+ '`llman-sdd validate --specs --json` output carries no `staleness` key.',
33
+ 'A subsequent `llman-sdd` invocation prints no version-drift NOTE.',
34
+ ],
35
+ },
36
+ ];
37
+
38
+ const EXPR_RE = /^\d+\.\d+\.\d+->\d+\.\d+\.\d+$/u;
39
+
40
+ /** Exact-match lookup; null when the expr is well-formed but unknown. */
41
+ export function findMigration(expr: string): MigrationEntry | null {
42
+ return MIGRATIONS.find((m) => m.id === expr) ?? null;
43
+ }
44
+
45
+ export function knownMigrationIds(): string[] {
46
+ return MIGRATIONS.map((m) => m.id);
47
+ }
48
+
49
+ export function isValidMigrationExpr(expr: string): boolean {
50
+ return EXPR_RE.test(expr);
51
+ }
52
+
53
+ /** Agent-facing playbook for one migration — deterministic, English. */
54
+ export function migrationPrompt(entry: MigrationEntry): string {
55
+ const steps = entry.steps.map((s, i) => `${i + 1}. ${s}`).join('\n');
56
+ const checks = entry.checks.map((c) => `- [ ] ${c}`).join('\n');
57
+ return [
58
+ `# Migration playbook: ${entry.id}`,
59
+ '',
60
+ `${entry.title}.`,
61
+ '',
62
+ '## Steps',
63
+ '',
64
+ steps,
65
+ '',
66
+ '## Verification checklist',
67
+ '',
68
+ checks,
69
+ '',
70
+ ].join('\n');
71
+ }
72
+
73
+ /** Lines appended to the bare `project migrate` overview. */
74
+ export function migrationOverviewLines(): string[] {
75
+ const ids = knownMigrationIds()
76
+ .map((id) => ` - ${id}`)
77
+ .join('\n');
78
+ return [
79
+ '',
80
+ 'Versioned migration playbooks (agent-readable, via `project migrate prompt`):',
81
+ ids,
82
+ "Usage: llman-sdd project migrate prompt --version-expr '<from>-><to>'",
83
+ 'Mechanical spec-header strip: llman-sdd project migrate strip-legacy-headers [--dry-run]',
84
+ ];
85
+ }
@@ -63,8 +63,8 @@ export function skeletonContent(capability: string, reqId: string, locale: strin
63
63
  const language = officialKeywords(mapped) !== null ? mapped : 'en';
64
64
  const kw = officialKeywordsOrEn(language);
65
65
  const header = zh
66
- ? `# language: ${language}\n# capability: ${capability}\n# purpose: TODO: 一句话描述该能力与其目的。\n# scope: llmanspec/`
67
- : `# language: ${language}\n# capability: ${capability}\n# purpose: TODO: Describe this capability and its purpose.\n# scope: llmanspec/`;
66
+ ? `# language: ${language}\n# capability: ${capability}\n# purpose: TODO: 一句话描述该能力与其目的。`
67
+ : `# language: ${language}\n# capability: ${capability}\n# purpose: TODO: Describe this capability and its purpose.`;
68
68
  const ruleDesc = zh ? 'TODO: 需求描述(自由文本)。' : 'TODO: requirement statement (free text).';
69
69
  // Skeleton placeholder prose is not vocabulary — the zh/en copy stays; keywords do not.
70
70
  const steps = zh
@@ -23,10 +23,8 @@ export interface SpecSummary {
23
23
  id: string;
24
24
  title: string;
25
25
  purpose: string;
26
- validScope: string[];
27
26
  requirementCount: number;
28
27
  health: null;
29
- staleness: null;
30
28
  morphology: SpecMorphology;
31
29
  }
32
30
 
@@ -52,13 +50,8 @@ export function collectSpecs(entries: readonly SpecEntry[]): SpecSummary[] {
52
50
  id: specIdOf(e),
53
51
  title: specIdOf(e),
54
52
  purpose: e.doc.header.purpose ?? '',
55
- validScope: (e.doc.header.scope ?? '')
56
- .split(',')
57
- .map((s) => s.trim())
58
- .filter((s) => s !== ''),
59
53
  requirementCount: total,
60
54
  health: null,
61
- staleness: null,
62
55
  morphology,
63
56
  };
64
57
  });
@@ -1,13 +1,11 @@
1
- import type { GitLike } from '../git/spawnGit.ts';
2
1
  import { ruleHasRunnableScenario, specIdOf } from '../spec/ir.ts';
3
- import { evaluateStaleness, notApplicableStaleness } from '../validation/staleness.ts';
4
2
  /**
5
3
  * Review aggregation (review-freeze capability, r23): five-signal review over
6
4
  * spec IR + validate sweep. Port of predecessor sdd/review.rs observable contract.
7
5
  */
8
6
  import { validateAllSpecs, type SpecEntry, type SpecIo } from '../validation/validate.ts';
9
7
 
10
- export type ReviewKind = 'unbound' | 'stale' | 'locked' | 'validate';
8
+ export type ReviewKind = 'unbound' | 'locked' | 'validate';
11
9
 
12
10
  export interface ReviewSignal {
13
11
  kind: ReviewKind;
@@ -22,14 +20,8 @@ export interface ReviewInput {
22
20
  boundChangeCount: number;
23
21
  /** Active change summaries for the strict sweep (pending tasks → FAIL). */
24
22
  activeChanges?: readonly { name: string; completedTasks: number; totalTasks: number }[];
25
- /** Restrict per-capability signals (pending/unbound/stale) to this capability. */
23
+ /** Restrict per-capability signals (unbound) to this capability. */
26
24
  capability?: string;
27
- /** git + root for real staleness evaluation (predecessor parity). */
28
- git?: GitLike;
29
- root?: string;
30
- specsDir?: string;
31
- /** predecessor base-ref override env value (LLMANSPEC_BASE_REF), injected by caller. */
32
- baseRefEnv?: string;
33
25
  }
34
26
 
35
27
  export interface ReviewResult {
@@ -39,15 +31,6 @@ export interface ReviewResult {
39
31
  exitCode: number;
40
32
  }
41
33
 
42
- /**
43
- * Root-relative spec path for staleness (`specRel` contract): repo-root
44
- * discovery yields `llmanspec/…` paths while bare stems get the specs prefix.
45
- * Shared with the CLI's spec validate path.
46
- */
47
- export function specRelFor(fileName: string): string {
48
- return fileName.startsWith('llmanspec/') ? fileName : `llmanspec/specs/${fileName}`;
49
- }
50
-
51
34
  export function buildReview(input: ReviewInput, io: SpecIo): ReviewResult {
52
35
  const { entries, boundChangeCount } = input;
53
36
  const strictChangeFails = (input.activeChanges ?? []).filter(
@@ -73,24 +56,6 @@ export function buildReview(input: ReviewInput, io: SpecIo): ReviewResult {
73
56
  const unbound = entry.doc.rules.filter((r) => !ruleHasRunnableScenario(r)).length;
74
57
 
75
58
  push('unbound', cap, unbound);
76
-
77
- // staleness (predecessor evaluate): real base-ref/scope evaluation.
78
- let staleInfo = notApplicableStaleness();
79
- let staleCount = 0;
80
- if (input.git !== undefined && input.root !== undefined) {
81
- const specRel = specRelFor(entry.fileName);
82
- const evalResult = evaluateStaleness({
83
- git: input.git,
84
- root: input.root,
85
- specRel,
86
- scope: entry.doc.header.scope?.split(',').map((x) => x.trim()) ?? [],
87
- reviewedThrough: entry.doc.header.reviewedThrough,
88
- baseRefEnv: input.baseRefEnv,
89
- });
90
- staleInfo = evalResult.info;
91
- staleCount = staleInfo.status === 'OK' || staleInfo.status === 'NOTAPPLICABLE' ? 0 : 1;
92
- }
93
- push('stale', cap, staleCount, staleInfo.status === 'NOTAPPLICABLE' ? '' : staleInfo.status);
94
59
  }
95
60
 
96
61
  const failed = sweep.verdicts.filter((v) => !v.ok);
@@ -138,13 +103,13 @@ export function buildReview(input: ReviewInput, io: SpecIo): ReviewResult {
138
103
  );
139
104
 
140
105
  const warningCount = signals
141
- .filter((s) => s.kind !== 'validate' && s.kind !== 'locked')
106
+ .filter((s) => s.kind === 'unbound')
142
107
  .reduce((acc, s) => acc + s.count, 0);
143
108
  const criticalCount = failed.length;
144
109
 
145
110
  const lines: string[] = [`Review: critical=${criticalCount} warning=${warningCount}`];
146
111
  for (const cap of sorted.map((e) => specIdOf(e))) {
147
- for (const kind of ['unbound', 'stale'] as const) {
112
+ for (const kind of ['unbound'] as const) {
148
113
  const s = signals.find((x) => x.kind === kind && x.capability === cap);
149
114
  if (!s) continue;
150
115
  lines.push(`${kind}: ${cap} (${s.count})`);
package/src/spec/ir.ts CHANGED
@@ -13,13 +13,6 @@
13
13
  export interface CapabilityHeader {
14
14
  capability: string | null;
15
15
  purpose: string | null;
16
- scope: string | null;
17
- /**
18
- * `# reviewed-through: <change-id>` — newest change through which this
19
- * capability's governed behaviour was reviewed unchanged (re-review stamp
20
- * governance). Consumers (staleness) compare it against branch history.
21
- */
22
- reviewedThrough: string | null;
23
16
  }
24
17
 
25
18
  export type ScenarioStepKind = 'given' | 'when' | 'then';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Legacy governance-header strip (drop-review-stamp-and-scope): removes
3
+ * `# scope:` / `# reviewed-through:` comment lines anywhere in a .feature —
4
+ * both are inert comments since the header contract shrank to
5
+ * capability+purpose. Pure: source in, result out; idempotent by construction
6
+ * (a stripped source yields zero removals on the second pass).
7
+ */
8
+ export function stripLegacyHeaderLines(source: string): { content: string; removed: number } {
9
+ const lines = source.split('\n');
10
+ const kept = lines.filter((line) => !/^#\s*(scope|reviewed-through):/u.test(line));
11
+ return { content: kept.join('\n'), removed: lines.length - kept.length };
12
+ }
@@ -79,25 +79,19 @@ function stepKeywordToKind(keyword: string): ScenarioStepKind {
79
79
  return stepKeywordToOfficialKind(keyword) ?? 'given';
80
80
  }
81
81
 
82
- const HEADER_RE = /^#\s*(capability|purpose|scope|reviewed-through):\s*(.*)$/u;
82
+ const HEADER_RE = /^#\s*(capability|purpose):\s*(.*)$/u;
83
83
 
84
84
  function extractHeader(source: string): CapabilityHeader {
85
85
  const header: CapabilityHeader = {
86
86
  capability: null,
87
87
  purpose: null,
88
- scope: null,
89
- reviewedThrough: null,
90
88
  };
91
89
  for (const line of source.split('\n')) {
92
90
  if (line.trim() === '') continue;
93
91
  if (!line.trimStart().startsWith('#')) break;
94
92
  const m = line.trimStart().match(HEADER_RE);
95
93
  if (m?.[1]) {
96
- const raw = m[1];
97
- const field: 'capability' | 'purpose' | 'scope' | 'reviewedThrough' =
98
- raw === 'reviewed-through'
99
- ? 'reviewedThrough'
100
- : (raw as 'capability' | 'purpose' | 'scope');
94
+ const field = m[1] as 'capability' | 'purpose';
101
95
  header[field] = m[2]?.trim() ?? null;
102
96
  }
103
97
  }
@@ -149,7 +143,7 @@ function collectScenario(sc: {
149
143
  export function parseCapability(source: string, fileName = '<inline>'): CapabilityDoc {
150
144
  const errors: SpecStructuralError[] = [];
151
145
  const header = extractHeader(source);
152
- for (const key of ['capability', 'purpose', 'scope'] as const) {
146
+ for (const key of ['capability', 'purpose'] as const) {
153
147
  if (header[key] === null) {
154
148
  errors.push({ code: `missing-header:${key}`, message: `missing # ${key}: header comment` });
155
149
  }
@@ -36,7 +36,6 @@ export const UNIT_FILES: readonly string[] = [
36
36
  'skills/stage-guard.md',
37
37
  'skills/ethics-governance.md',
38
38
  'skills/version-drift.md',
39
- 'skills/review-stamp.md',
40
39
  'spec/feature-contract.md',
41
40
  'skills/structured-protocol.md',
42
41
  'skills/cli-footer.md',
@@ -70,43 +70,6 @@ export function discoverRoots(
70
70
  return roots;
71
71
  }
72
72
 
73
- export interface ScopeCrossing {
74
- scope: string;
75
- rootDir: string;
76
- }
77
-
78
- /**
79
- * Single-ownership rule (r92): a file path belongs to exactly one llmanspec
80
- * root. Scope entries are resolved against the owning instance root; a scope
81
- * that reaches into another root's instance directory crosses the boundary
82
- * and is reported with the offending scope and the other root. Ancestor roots
83
- * are exempt: a sub-root scoping its own subtree always resolves under the
84
- * ancestor's directory, but ownership there belongs to the descendant.
85
- */
86
- export function scopeCrossings(
87
- scopePaths: readonly string[],
88
- instanceRootDir: string,
89
- otherRoots: readonly RootEntry[],
90
- ): ScopeCrossing[] {
91
- const crossings: ScopeCrossing[] = [];
92
- for (const raw of scopePaths) {
93
- const scope = raw.trim().replace(/^\.\//u, '').replace(/\/+$/u, '');
94
- if (scope === '') continue;
95
- const abs = joinPath(instanceRootDir, scope);
96
- for (const other of otherRoots) {
97
- if (other.rootDir === instanceRootDir) continue;
98
- // Ancestor exemption: our own subtree necessarily sits inside the
99
- // ancestor's directory — the ancestor does not own it.
100
- if (instanceRootDir.startsWith(`${other.rootDir}/`)) continue;
101
- if (abs === other.rootDir || abs.startsWith(`${other.rootDir}/`)) {
102
- crossings.push({ scope: raw.trim(), rootDir: other.rootDir });
103
- break;
104
- }
105
- }
106
- }
107
- return crossings;
108
- }
109
-
110
73
  /**
111
74
  * Nearest instance root at or above `startDir` (inclusive) — the cwd
112
75
  * resolution behind "cd into the subpackage and run" (r94). Returns null when
@@ -46,12 +46,11 @@ const coveragePath = (cap: string): string => `${cap}/coverage`;
46
46
  export function validateCapability(
47
47
  entry: SpecEntry,
48
48
  duplicatesFor: (reqId: string) => boolean,
49
- io: SpecIo,
50
- opts: { strict?: boolean } = {},
49
+ _io: SpecIo,
50
+ _opts: { strict?: boolean } = {},
51
51
  ): SpecVerdict {
52
52
  const { doc } = entry;
53
53
  const cap = specIdOf(entry);
54
- const strict = opts.strict === true;
55
54
  const items: ValidationItem[] = [];
56
55
 
57
56
  const push = (level: ValidationLevel, id: string, message: string): void => {
@@ -70,29 +69,6 @@ export function validateCapability(
70
69
  if (doc.header.purpose === null || doc.header.purpose.trim() === '') {
71
70
  push('ERROR', `${cap}/purpose`, '`# purpose:` header comment must not be empty');
72
71
  }
73
- if (doc.header.scope === null) {
74
- push(
75
- 'ERROR',
76
- `${cap}/valid_scope`,
77
- 'Spec valid_scope must not be empty (declare it in the "# scope:" header comment).',
78
- );
79
- } else {
80
- // r42: missing valid_scope paths are independent failures —
81
- // ERROR (nonzero exit) under --strict, WARNING otherwise.
82
- const missing = doc.header.scope
83
- .split(',')
84
- .map((s) => s.trim())
85
- .filter((s) => s !== '')
86
- .filter((s) => !io.exists(s));
87
- if (missing.length > 0) {
88
- push(
89
- strict ? 'ERROR' : 'WARNING',
90
- `${cap}/valid_scope`,
91
- `valid_scope path(s) do not exist on disk: ${missing.join(', ')}`,
92
- );
93
- }
94
- }
95
-
96
72
  // Spec name must match the capability id (flat stem).
97
73
  if (doc.header.capability !== null && doc.header.capability.trim() !== cap) {
98
74
  push(
@@ -200,8 +176,3 @@ export function validateAllSpecs(entries: readonly SpecEntry[], io: SpecIo): Val
200
176
 
201
177
  return { verdicts, lines, failed };
202
178
  }
203
-
204
- /** predecessor `apply_strict`: WARNING issues escalate to ERROR when --strict. */
205
- export function applyStrict<T extends { level: ValidationLevel }>(items: readonly T[]): T[] {
206
- return items.map((i) => (i.level === 'WARNING' ? { ...i, level: 'ERROR' as const } : i));
207
- }
@@ -28,6 +28,7 @@ flowchart LR
28
28
 
29
29
  - **Single-source-of-truth driven**: `proposal.md` / `design.md` / `tasks.md` and `llmanspec/specs/**` on the branch; every behavioral-contract requirement in specs must be fulfilled.
30
30
  - **Scope-locked**: only implement the current change's scope; never fix "unrelated issues" on the side; keep changes minimal.
31
+ - **Governing scope**: the SDD flow (change branch, proposal, spec-edit gates) governs the behavior-contract surface only — `llmanspec/**` and its artifact alignment (e.g. `.agents/skills` render freshness). Everything else in the repo (build scripts, CI, general docs, test implementations) follows the project's regular engineering flow with direct edits and commits; no change wrapping required. Return to the corresponding skill flow only when a change reaches behavior-contract semantics.
31
32
  - **No guessing**: unclear requirements or specs contradicting reality → STOP and report; don't assume.
32
33
  - **No legacy compatibility layers**: if the change requires new behavior, upgrade all call sites directly, unless tasks/proposal explicitly require compatibility.
33
34
  - **Close-out**: this loop ends by suggesting `llman-sdd-verify`; finalize/archive belongs to `llman-sdd-archive` (do not finalize inside the self-healing loop).
@@ -44,7 +45,7 @@ flowchart LR
44
45
  - Read and obey `llmanspec/config.yaml`, `AGENTS.md` (if present).
45
46
  - `git status --porcelain`: if the tree is dirty with changes not belonging to this change → `git stash push -u -m "llman-sdd-apply autopilot backup"` first.
46
47
  - `llman-sdd validate --all --strict`: if it fails for reasons unrelated to this change → stop and report (inconsistent artifacts prevent source-of-truth-driven implementation).
47
- - **Check spec valid_scope integrity**: `llman-sdd list --specs --json` lists all specs; for each, verify every `valid_scope` path exists on disk. On missing paths → stop and suggest updating the spec (remove the deleted path).
48
+ - **Specs list readable**: `llman-sdd list --specs` returns the list without errors; on anomaly → stop and report.
48
49
 
49
50
  ### 1) Select the change id and check prerequisites
50
51
  - If provided, use it; otherwise infer from context, and if ambiguous run `llman-sdd list --json` and let the user pick. Always announce "Using change: <id>" and how to override.
@@ -70,14 +71,13 @@ For each unchecked task:
70
71
  4. Task unclear, blocker hit, or specs/design contradict reality → STOP and report; don't assume.
71
72
 
72
73
  ### 5) Verification and self-healing loop (after each task or batch)
73
- Run the project gates as appropriate:
74
- - Test suite: `just test` or `cargo test --all`; format/lint: `just check` or `just lint` + `just fmt`
74
+ - Tests and static gates: run the verification means this repo has declared — as recorded in repo docs and configuration; for repos with `specs.check_command` configured, use the command reported by `llman-sdd config`. If the repo declares none, ask the user; never assume a specific task runner exists.
75
75
  - Edit `llmanspec/specs/<capability>.feature` on the branch as needed (flat or directory main file; canonical native layout: `@req:<id>` on the `规则:` block header, nested `场景:` as executable examples); run `llman-sdd validate --specs` after spec edits; commit on the branch freely.
76
76
  - SDD validation: `llman-sdd validate <id> --strict`
77
77
 
78
78
  **Verification ladder (opt-in discipline, escalate by cost)**:
79
- - L1 minimal unit: `bun test tests/unit/<relevant>` (<1s, direct import), covers only the current change point.
80
- - L2 targeted behavior: `bun test tests/bdd -t "<scenario/rule title pattern>"` — exercises only the relevant real-CLI path.
79
+ - L1 minimal unit: the fastest declared verification means that loads the changed module directly; covers only the current change point.
80
+ - L2 targeted behavior: run the subset of declared verification means matching the current scenario (prefer targeted `specs.check_command` invocation when configured); reproduce the target behavior only.
81
81
  - L3 explicit full harness: `llman-sdd validate --check` (with `specs.check_command` configured; plain `validate` no longer runs the harness).
82
82
  - L4 close-out backstop: `change finalize` runs the real harness pre-merge — at least one full run per close-out.
83
83
  - Self-heal loops default to L1/L2 for fast reproduction; use L3 only when full-acceptance evidence is needed; avoid paying full-suite cost needlessly.
@@ -112,8 +112,6 @@ After all tasks complete + all gates green, output a structured report (see Outp
112
112
 
113
113
  {{ unit("skills/version-drift") }}
114
114
 
115
- {{ unit("skills/review-stamp") }}
116
-
117
115
  {{ unit("skills/validation-hints") }}
118
116
 
119
117
  {{ unit("skills/structured-protocol") }}
@@ -47,7 +47,7 @@ If the user just wants to **capture an idea** ("draft a proposal", "note down X"
47
47
  ### 0) Preflight
48
48
  - Read `llmanspec/config.yaml` for project context, rules, locale.
49
49
  - `llman-sdd validate --all --strict` to ensure current artifacts are clean; on pre-existing errors, STOP and report (stacking a new change on dirty artifacts causes cascading errors).
50
- - **Check spec valid_scope integrity**: `llman-sdd list --specs --json` lists all specs; for each, verify every `valid_scope` path exists on disk. On missing paths, STOP and suggest updating the spec (remove the deleted path).
50
+ - **Specs list readable**: `llman-sdd list --specs` returns the list without errors; on anomaly, STOP and report.
51
51
 
52
52
  ### 1) Assess change scale
53
53
  1. Classify:
@@ -79,9 +79,9 @@ If the user just wants to **capture an idea** ("draft a proposal", "note down X"
79
79
 
80
80
  ### 4) Validate
81
81
  ```bash
82
- llman-sdd validate <change-id> --strict
82
+ llman-sdd validate <change-id>
83
83
  ```
84
- This MUST pass before proceeding; failing items are listed one by one in the validate output's `items[].issues[]` — fix each and re-run.
84
+ The structure gate MUST pass before proceeding; failing items are listed one by one in the validate output's `items[].issues[]` — fix each and re-run. `--strict` promotes warnings (including unchecked tasks) to failures — reserve it for the post-implementation completion check, once every task is checked.
85
85
 
86
86
  ### 4a) Optional BDD runner (`specs:` block)
87
87
  - Read `llmanspec/config.yaml`. Is there a `specs:` block?
@@ -7,7 +7,7 @@ metadata:
7
7
 
8
8
  # LLMAN SDD Validate
9
9
 
10
- Validate change/spec format and staleness.
10
+ Validate change/spec format.
11
11
 
12
12
  ## Steps
13
13
  1. Single item: `llman-sdd validate <id>`; batch: `llman-sdd validate --all` (or `--changes` / `--specs`); use `--strict` in CI/automation.
@@ -72,8 +72,6 @@ flowchart LR
72
72
 
73
73
  {{ unit("skills/version-drift") }}
74
74
 
75
- {{ unit("skills/review-stamp") }}
76
-
77
75
  {{ unit("skills/validation-hints") }}
78
76
 
79
77
  {{ unit("skills/structured-protocol") }}
@@ -5,7 +5,6 @@ Validation fixes (single-track feature-as-spec):
5
5
  # language: zh-CN
6
6
  # capability: <capability>
7
7
  # purpose: One-line overview.
8
- # scope: src/
9
8
  ```
10
9
 
11
10
  2) Native layout (`rule must carry an @req:<req_id> tag on the rule header`):
@@ -8,7 +8,6 @@ The format is the **native Gherkin hierarchy**: `功能:` → `规则:` (the req
8
8
  # language: zh-CN
9
9
  # capability: sample
10
10
  # purpose: One-line overview.
11
- # scope: src/
12
11
 
13
12
  功能: sample
14
13
 
@@ -30,7 +29,7 @@ The format is the **native Gherkin hierarchy**: `功能:` → `规则:` (the req
30
29
  down or converting them.
31
30
  ```
32
31
 
33
- - Header comments (`# capability:` / `# purpose:` / `# scope:`) are REQUIRED; `scope` drives staleness checks.
32
+ - Header comments (`# capability:` / `# purpose:`) are REQUIRED.
34
33
  - **Executable scenarios preferred**: express behavior as nested `场景:` (`Given/When/Then`) bound to BDD step code and executed by the runner — the default. Only use a `规则:` block without executable scenarios for requirements that cannot be expressed programmatically (abstract goals, architecture decisions, governance/human judgment) or are not yet converted; record the rationale in proposal/design.
35
34
  - `@req:<id>` lives on the `规则:` block header: the global unique requirement handle (shared by resolve-req/next-req-id/citation). Missing or duplicate ids are validate ERRORs.
36
35
  - Rule description is free text: no MUST/SHALL enforcement; wrap long text across lines for reviewability, with no `- ` list marker (it would enter the description verbatim).
@@ -28,6 +28,7 @@ flowchart LR
28
28
 
29
29
  - **唯一事实来源驱动**:`proposal.md` / `design.md` / `tasks.md` 与分支上的 `llmanspec/specs/**`;specs 的行为合约条款逐条落实。
30
30
  - **范围锁定**:只做当前 change 范围,不得顺手修无关问题;改动保持最小。
31
+ - **管辖范围**:SDD 流程(change 分支、proposal、specs 编辑门)只约束行为合约面——`llmanspec/**` 及其产物对齐(如 `.agents/skills` 渲染新鲜度)。仓库其余文件(构建脚本、CI、一般文档、测试实现)按项目常规工程流程直改直提交,不经 change 包装;改动触及行为合约语义时,回到对应 skill 流程。
31
32
  - **不得猜测**:需求不明或 specs 与现实矛盾 → STOP 报告,不自行假定。
32
33
  - **不留旧兼容层**:change 要求改行为就全量升级到新写法,除非 tasks/proposal 明确要兼容。
33
34
  - **收尾**:该轮以宜接 `llman-sdd-verify` 收束;finalize/archive 归 `llman-sdd-archive`(不得在自修复循环里 finalize)。
@@ -44,7 +45,7 @@ flowchart LR
44
45
  - 读取并遵守 `llmanspec/config.yaml`、`AGENTS.md`(若存在)。
45
46
  - `git status --porcelain`:工作区不干净且改动不属于本 change → 先 `git stash push -u -m "llman-sdd-apply autopilot backup"`。
46
47
  - `llman-sdd validate --all --strict`:失败且与本 change 无关 → 停下报告(工件不一致则无法以事实来源驱动实现)。
47
- - **检查 spec valid_scope 完整性**:`llman-sdd list --specs --json` 列出所有 spec,逐个核对 `valid_scope` 路径存在于磁盘;有缺失 → 停下并宜更新 spec(移除已删路径)。
48
+ - **specs 清单可读**:`llman-sdd list --specs` 返回清单且无错误;异常 → 停下报告。
48
49
 
49
50
  ### 1) 选定 change id 并查前置
50
51
  - 已提供则直接用;否则从上下文推断,不明确就跑 `llman-sdd list --json` 让用户选。始终说明“使用变更:<id>”并告知如何覆盖。
@@ -70,14 +71,13 @@ flowchart LR
70
71
  4. task 不明、遇 blocker、或 specs/design 与现实不一致 → STOP 报告,不自行假定。
71
72
 
72
73
  ### 5) 验证与自修复循环(每个 task 或每批 task 后跑一次)
73
- 按项目实际跑门禁:
74
- - 测试集:`just test` 或 `cargo test --all`;格式/lint:`just check` 或 `just lint` + `just fmt`
74
+ - 测试与静态门禁:执行本仓已声明的验证手段——以仓库文档与配置记载为准;已配置 `specs.check_command` 的项目,以 `llman-sdd config` 读得的命令为准。仓库未声明时,询问用户;不假定任何具体任务工具存在。
75
75
  - 分支上按需编辑 `llmanspec/specs/<capability>.feature`(扁平或目录主文件;统一原生分层:`@req:<id>` 挂 `规则:` 块头、嵌套 `场景:` 为可执行示例),spec 改动后跑 `llman-sdd validate --specs`;分支上可自由提交。
76
76
  - SDD 校验:`llman-sdd validate <id> --strict`
77
77
 
78
78
  **验证阶梯(opt-in 纪律,按成本逐级扩大)**:
79
- - L1 最小单元:`bun test tests/unit/<改动对应目录>`(<1s,直接导入),仅覆盖当前改动点。
80
- - L2 定向行为:`bun test tests/bdd -t "<场景/规则标题模式>"`——只跑匹配 -t 模式场景的真实 CLI 调用。
79
+ - L1 最小单元:已声明验证手段中能直接加载被改模块的最快一层,仅覆盖当前改动点。
80
+ - L2 定向行为:定向执行已声明验证手段中匹配当前场景的子集(已配置 `specs.check_command` 时优先),只复现目标行为。
81
81
  - L3 显式全量:`llman-sdd validate --check`(配置 `specs.check_command` 时执行全量 harness;缺省 validate 不再执行 harness)。
82
82
  - L4 收口兜底:`change finalize` 预合并强制真实 harness——每次收口至少 1 次全量。
83
83
  - 自修复循环默认用 L1/L2 快速复现;只有需要全量验收时才 L3;避免无谓白付全量成本。
@@ -112,8 +112,6 @@ flowchart LR
112
112
 
113
113
  {{ unit("skills/version-drift") }}
114
114
 
115
- {{ unit("skills/review-stamp") }}
116
-
117
115
  {{ unit("skills/validation-hints") }}
118
116
 
119
117
  {{ unit("skills/structured-protocol") }}
@@ -47,7 +47,7 @@ flowchart LR
47
47
  ### 0) 预检
48
48
  - 读 `llmanspec/config.yaml` 获取项目上下文、规则、locale。
49
49
  - `llman-sdd validate --all --strict` 确认现有工件干净;有错误则 STOP 并报告(脏工件上叠新 change 会级联出错)。
50
- - **检查 spec valid_scope 完整性**:`llman-sdd list --specs --json` 列出全部 specs,逐个核对 `valid_scope` 路径在磁盘上存在;有缺失则 STOP 并宜更新该 spec(移除已删路径)。
50
+ - **specs 清单可读**:`llman-sdd list --specs` 返回清单且无错误;异常则 STOP 报告。
51
51
 
52
52
  ### 1) 判断变更规模
53
53
  1. 分类:
@@ -79,9 +79,9 @@ flowchart LR
79
79
 
80
80
  ### 4) 校验
81
81
  ```bash
82
- llman-sdd validate <change-id> --strict
82
+ llman-sdd validate <change-id>
83
83
  ```
84
- 必须 通过才能继续;失败项在 validate 输出的 `items[].issues[]` 逐条指明,按条修复后重跑。
84
+ 结构门必须 通过才能继续;失败项在 validate 输出的 `items[].issues[]` 逐条指明,按条修复后重跑。`--strict` 会把警告(含未勾 task)一并升级为失败——留到实施收口、task 全勾后作完成判定。
85
85
 
86
86
  ### 4a) 可选 BDD runner(`specs:` 段)
87
87
  - 读 `llmanspec/config.yaml` 是否含 `specs:` 段:
@@ -72,8 +72,6 @@ flowchart LR
72
72
 
73
73
  {{ unit("skills/version-drift") }}
74
74
 
75
- {{ unit("skills/review-stamp") }}
76
-
77
75
  {{ unit("skills/validation-hints") }}
78
76
 
79
77
  {{ unit("skills/structured-protocol") }}
@@ -5,7 +5,6 @@
5
5
  # language: zh-CN
6
6
  # capability: <capability>
7
7
  # purpose: 一句话概述
8
- # scope: src/
9
8
  ```
10
9
 
11
10
  2)原生分层格式(`rule must carry an @req:<req_id> tag on the rule header`):
@@ -8,7 +8,6 @@
8
8
  # language: zh-CN
9
9
  # capability: sample
10
10
  # purpose: One-line overview.
11
- # scope: src/
12
11
 
13
12
  功能: sample
14
13
 
@@ -28,7 +27,7 @@
28
27
  specs-compact 持续压降。
29
28
  ```
30
29
 
31
- - 头注释(`# capability:` / `# purpose:` / `# scope:`)必填;`scope` 驱动过期检查。
30
+ - 头注释(`# capability:` / `# purpose:`)必填。
32
31
  - **可执行场景优先**:行为一律以嵌套 `场景:`(假如/当/那么)表达并绑定 BDD 步骤代码、由 runner 执行——默认首选。仅当需求无法程序化表达(抽象目标、架构决策、治理/人工约束)或暂不转写时,才以 `规则:` 块承载,并在 proposal/design 记录理由。
33
32
  - `@req:<id>` 挂在 `规则:` 头标签,是全局唯一的需求句柄(resolve-req/next-req-id/条款引用共用);重复或缺失由 validate 判 ERROR。
34
33
  - 规则描述为自由文本:不强制 MUST/SHALL 词;较长时拆多行便于审查,不使用 `- ` 列表前缀(会原样进入描述)。
@@ -1,206 +0,0 @@
1
- /**
2
- * Staleness evaluator (validation/staleness parity): predecessor `sdd/spec/staleness.rs`
3
- * observable contract — status/baseRef/scope/touchedPaths/specUpdated/dirty/
4
- * notes plus per-capability staleness issues. Pure: git + env are injected.
5
- */
6
-
7
- import type { GitLike } from '../git/spawnGit.ts';
8
-
9
- export type StalenessStatus = 'OK' | 'INFO' | 'WARN' | 'STALE' | 'NOTAPPLICABLE';
10
-
11
- export interface StalenessInfo {
12
- status: StalenessStatus;
13
- baseRef: string | null;
14
- scope: string[];
15
- touchedPaths: string[];
16
- specUpdated: boolean;
17
- dirty: boolean;
18
- notes: string[];
19
- }
20
-
21
- export interface StalenessIssue {
22
- level: 'ERROR' | 'WARNING' | 'INFO';
23
- path: string;
24
- message: string;
25
- }
26
-
27
- export interface StalenessDeps {
28
- git: GitLike;
29
- root: string;
30
- /** spec file path relative to root, e.g. `llmanspec/specs/auth.feature` */
31
- specRel: string;
32
- /** scope entries from the `# scope:` header (raw, unnormalized) */
33
- scope: string[];
34
- /**
35
- * `# reviewed-through: <id>` header value (re-review stamp governance): when
36
- * set, a STALE verdict is suppressed iff every scope-touching commit on the
37
- * branch mentions that change id — the recorded no-behavior-change review.
38
- */
39
- reviewedThrough?: string | null;
40
- /** env override for LLMANSPEC_BASE_REF */
41
- baseRefEnv?: string;
42
- defaultBranchName?: string;
43
- }
44
-
45
- const normalizePath = (value: string): string =>
46
- value.trim().replace(/^\.\//u, '').replace(/^\/+/u, '').replace(/\/+$/u, '');
47
-
48
- const scopeMatches = (path: string, scope: readonly string[]): boolean => {
49
- const p = normalizePath(path);
50
- return scope.some((s) => p === s || p.startsWith(`${s}/`));
51
- };
52
-
53
- export function notApplicableStaleness(): StalenessInfo {
54
- return {
55
- status: 'NOTAPPLICABLE',
56
- baseRef: null,
57
- scope: [],
58
- touchedPaths: [],
59
- specUpdated: false,
60
- dirty: false,
61
- notes: [],
62
- };
63
- }
64
-
65
- const DIRTY_MSG = 'Working tree is dirty; results may be unreliable.';
66
- const SCOPE_MISSING_MSG = 'Note: Spec validation scope is missing.';
67
- const BASE_MISSING_MSG =
68
- "Note: Unable to resolve base ref for staleness check. Set LLMANSPEC_BASE_REF (e.g. 'main' or 'origin/main'), or upgrade llman if below 0.0.60.";
69
-
70
- /**
71
- * Evaluate staleness for one capability spec — predecessor status semantics.
72
- * Returns the info object plus warning/info issues (strict escalation is the
73
- * caller's job, matching predecessor `apply_strict`).
74
- */
75
- export function evaluateStaleness(deps: StalenessDeps): {
76
- info: StalenessInfo;
77
- issues: StalenessIssue[];
78
- } {
79
- const { git, specRel, scope, baseRefEnv } = deps;
80
- const issues: StalenessIssue[] = [];
81
- const notes: string[] = [];
82
- const normScope = scope.map(normalizePath).filter((s) => s !== '');
83
-
84
- const rawBaseRef =
85
- baseRefEnv !== undefined && baseRefEnv.trim() !== '' ? baseRefEnv.trim() : null;
86
- let baseRef: string | null = null;
87
- let mergeBase: string | null = null;
88
-
89
- if (rawBaseRef !== null) {
90
- baseRef = rawBaseRef;
91
- mergeBase = revParse(git, rawBaseRef);
92
- } else {
93
- const defaultBranchName = deps.defaultBranchName ?? defaultBranchNameFn(git);
94
- mergeBase = git.runOpt(['merge-base', defaultBranchName, 'HEAD']);
95
- if (mergeBase !== null) baseRef = mergeBase;
96
- }
97
-
98
- let status: StalenessStatus = 'OK';
99
- if (normScope.length === 0) {
100
- status = 'WARN';
101
- notes.push(SCOPE_MISSING_MSG);
102
- issues.push({ level: 'WARNING', path: `${specId()}/staleness`, message: SCOPE_MISSING_MSG });
103
- }
104
- if (mergeBase === null && rawBaseRef === null) {
105
- status = 'WARN';
106
- notes.push(BASE_MISSING_MSG);
107
- issues.push({ level: 'WARNING', path: `${specId()}/staleness`, message: BASE_MISSING_MSG });
108
- }
109
-
110
- let touchedPaths: string[] = [];
111
- let specUpdated = false;
112
- if (status !== 'WARN' && baseRef !== null && mergeBase !== null) {
113
- const diff = git.runOpt(['diff', '--name-only', `${baseRef}...HEAD`]) ?? '';
114
- const paths =
115
- diff === ''
116
- ? []
117
- : diff
118
- .split('\n')
119
- .map((l) => l.trim())
120
- .filter((l) => l !== '');
121
- if (paths.length > 0) {
122
- specUpdated = paths.some((p) => normalizePath(p) === normalizePath(specRel));
123
- touchedPaths = paths.filter((p) => scopeMatches(p, normScope));
124
- }
125
- const reviewAcked =
126
- touchedPaths.length > 0 &&
127
- !specUpdated &&
128
- reviewCoversBranch(deps.reviewedThrough ?? null, git, baseRef);
129
- if (touchedPaths.length > 0 && !specUpdated && !reviewAcked) {
130
- status = 'STALE' as StalenessStatus;
131
- issues.push({ level: 'WARNING', path: `${specId()}/staleness`, message: STALE_MSG });
132
- } else if (reviewAcked) {
133
- // confirm-style ack: scope touched, spec untouched, reviewed-through
134
- // covers the branch — downgrade to OK with an explanatory note.
135
- status = 'OK';
136
- notes.push(reviewAckedMsg(deps.reviewedThrough ?? ''));
137
- } else if (specUpdated && touchedPaths.length === 0) {
138
- status = 'INFO';
139
- notes.push(SPEC_UPDATED_MSG);
140
- }
141
- }
142
-
143
- // Tolerant: outside a git repo (or on git failure) treat as dirty (predecessor unwrap_or(true)).
144
- const dirty = (git.runOpt(['status', '--porcelain']) ?? 'dirty') !== '';
145
- if (dirty) {
146
- if (status === 'OK' || status === 'STALE') status = 'INFO';
147
- notes.push(DIRTY_MSG);
148
- issues.push({ level: 'INFO', path: `${specId()}/staleness`, message: DIRTY_MSG });
149
- }
150
-
151
- return {
152
- info: { status, baseRef, scope: normScope, touchedPaths, specUpdated, dirty, notes },
153
- issues,
154
- };
155
-
156
- function specId(): string {
157
- return deps.specRel.replace(/^llmanspec\/specs\//u, '').replace(/\.feature$/u, '');
158
- }
159
- }
160
-
161
- const STALE_MSG =
162
- "Note: Code in this spec's scope changed on this branch but the spec was not updated; re-review the spec.";
163
- const SPEC_UPDATED_MSG = 'Note: Spec updated on this branch.';
164
-
165
- const reviewAckedMsg = (id: string): string =>
166
- `Note: Scope changed on this branch; covered by the recorded review (reviewed-through: ${id}).`;
167
-
168
- /**
169
- * Re-review ack check: every scope-touching commit message on
170
- * `baseRef..HEAD` references the reviewed-through change id. Empty id or git
171
- * failure → not covered (falls back to the plain STALE verdict). A commit
172
- * referencing several changes satisfies any of them (`c2858`-style tokens).
173
- */
174
- function reviewCoversBranch(
175
- reviewedThrough: string | null,
176
- git: GitLike,
177
- baseRef: string,
178
- ): boolean {
179
- if (reviewedThrough === null || reviewedThrough.trim() === '') return false;
180
- const id = reviewedThrough.trim();
181
- const log = git.runOpt(['log', '--format=%s', `${baseRef}..HEAD`]);
182
- if (log === null || log === '') return false;
183
- return log
184
- .split('\n')
185
- .filter((l) => scopeLineRelevant(l))
186
- .every((l) => l.includes(id));
187
- }
188
-
189
- /** Lines without any `c<num>` token carry no change attribution — skip them. */
190
- function scopeLineRelevant(line: string): boolean {
191
- return /c\d+/u.test(line) || line.trim() === '';
192
- }
193
-
194
- function revParse(git: GitLike, ref: string): string | null {
195
- return git.runOpt(['rev-parse', '--verify', '--quiet', ref]) ?? null;
196
- }
197
-
198
- // Deliberately NOT shared with defaultBranch() in git/spawnGit.ts — this
199
- // predecessor staleness probe is local-only (main → master, 'main' fallback, no origin
200
- // consultation). Do not merge the two.
201
- function defaultBranchNameFn(git: GitLike): string {
202
- if (git.runOpt(['show-ref', '--verify', '--quiet', 'refs/heads/main']) !== null) return 'main';
203
- if (git.runOpt(['show-ref', '--verify', '--quiet', 'refs/heads/master']) !== null)
204
- return 'master';
205
- return 'main';
206
- }
@@ -1,3 +0,0 @@
1
- ## Re-review stamp discipline (`# reviewed-through:` header)
2
-
3
- When a review concludes "no governed behaviour change", **update** the spec header line `# reviewed-through: <change-id>` to this change — **never** append free-form `# re-review(...)` comments between rules (historical narrative belongs to `changes/archive/<id>/`; the spec keeps only the machine-readable pointer). Staleness consumes it to clear the STALE signal; legacy free-form comments are dropped mechanically on touch, not migrated.
@@ -1,3 +0,0 @@
1
- ## 复核戳纪律(re-review stamp → `# reviewed-through:` 头)
2
-
3
- 复核确认“本 capability 管辖行为不变”时,**只更新** spec 头部的 `# reviewed-through: <change-id>` 一行(改为本次 change id),**不得**在 rule 块间追加自由 `# re-review(...)` 注释——历史叙事归 `changes/archive/<id>/`,spec 只留机读指针。staleness 据此消警;旧版自由注释随触碰一并机械清理(删除、不搬运)。