@llman-sdd/core 0.7.4 → 0.8.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.
- package/package.json +1 -1
- package/src/archive/freeze.ts +6 -2
- package/src/archive/frozenCard.ts +11 -9
- package/src/change/frontmatter.ts +12 -0
- package/src/change/lifecycle.ts +3 -1
- package/src/context/retrieve.ts +1 -1
- package/src/git/spawnGit.ts +2 -2
- package/src/index.ts +12 -9
- package/src/project/migrateNotes.ts +6 -6
- package/src/project/migrations.ts +85 -0
- package/src/report/graph/deps.ts +12 -1
- package/src/report/specHelpers.ts +2 -2
- package/src/report/specs.ts +0 -7
- package/src/review/review.ts +4 -39
- package/src/spec/ir.ts +0 -7
- package/src/spec/migrateScope.ts +12 -0
- package/src/spec/parser.ts +3 -9
- package/src/templates/skills.ts +0 -1
- package/src/validation/changeCheck.ts +12 -0
- package/src/validation/roots.ts +0 -37
- package/src/validation/validate.ts +2 -31
- package/templates/en/skills/llman-sdd-apply.md +1 -3
- package/templates/en/skills/llman-sdd-draft.md +2 -2
- package/templates/en/skills/llman-sdd-propose.md +3 -3
- package/templates/en/skills/llman-sdd-quick.md +2 -2
- package/templates/en/skills/llman-sdd-research.md +1 -1
- package/templates/en/skills/llman-sdd-validate.md +1 -1
- package/templates/en/skills/llman-sdd-verify.md +0 -2
- package/templates/en/units/skills/validation-hints.md +1 -2
- package/templates/en/units/spec/feature-contract.md +1 -2
- package/templates/en/units/workflow/archive-freeze-guidance.md +2 -2
- package/templates/zh-Hans/skills/llman-sdd-apply.md +1 -3
- package/templates/zh-Hans/skills/llman-sdd-draft.md +2 -2
- package/templates/zh-Hans/skills/llman-sdd-propose.md +3 -3
- package/templates/zh-Hans/skills/llman-sdd-quick.md +2 -2
- package/templates/zh-Hans/skills/llman-sdd-research.md +1 -1
- package/templates/zh-Hans/skills/llman-sdd-verify.md +0 -2
- package/templates/zh-Hans/units/skills/validation-hints.md +1 -2
- package/templates/zh-Hans/units/spec/feature-contract.md +1 -2
- package/templates/zh-Hans/units/workflow/archive-freeze-guidance.md +2 -2
- package/src/validation/staleness.ts +0 -206
- package/templates/en/units/skills/review-stamp.md +0 -3
- package/templates/zh-Hans/units/skills/review-stamp.md +0 -3
package/package.json
CHANGED
package/src/archive/freeze.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { join } from 'node:path';
|
|
10
10
|
|
|
11
11
|
import { firstH1 } from '../change/collect.ts';
|
|
12
|
-
import { extractFrontmatter } from '../change/frontmatter.ts';
|
|
12
|
+
import { extractFrontmatter, readFrontmatterTitle } from '../change/frontmatter.ts';
|
|
13
13
|
import {
|
|
14
14
|
FROZEN_CARD_EXT,
|
|
15
15
|
composeFrozenCard,
|
|
@@ -102,9 +102,13 @@ export async function runFreeze(
|
|
|
102
102
|
const proposalRel = `${ARCHIVE_DIR_REL}/${c}/proposal.md`;
|
|
103
103
|
const proposal = io.exists(proposalRel) ? io.readText(proposalRel) : '';
|
|
104
104
|
const frontmatter = extractFrontmatter(proposal) ?? '';
|
|
105
|
+
// r24: frontmatter `title` wins when non-empty; H1 is the legacy fallback.
|
|
105
106
|
cards.push({
|
|
106
107
|
datedId: c,
|
|
107
|
-
source: composeFrozenCard(
|
|
108
|
+
source: composeFrozenCard(
|
|
109
|
+
readFrontmatterTitle(frontmatter) || firstH1(proposal),
|
|
110
|
+
frontmatter,
|
|
111
|
+
),
|
|
108
112
|
});
|
|
109
113
|
}
|
|
110
114
|
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
* Frozen-change relationship-index card contract (review-freeze capability,
|
|
3
3
|
* r24/r25): `freeze` replaces a dated archive dir with a flat card
|
|
4
4
|
* `<YYYY-MM-DD>-<id>.yaml` whose content carries only the change's `title`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* is in the cold backup.
|
|
5
|
+
* and `depends_on` — a human/agent readable navigation index. id and date are
|
|
6
|
+
* implied by the file name; bodies live in the 7z cold backup. Cards are the
|
|
7
|
+
* authoritative record that a change is in the cold backup.
|
|
9
8
|
*
|
|
10
|
-
* The card is a
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* The card is a single-document plain YAML file (no `---` fences — standard
|
|
10
|
+
* single-doc parsers must accept it). Reading `depends_on` from a card is
|
|
11
|
+
* dual-format (parseDeps in report/graph): fenced cards written by
|
|
12
|
+
* predecessors keep working; this writer only produces the fenced-free form.
|
|
13
|
+
* Title source: frontmatter `title` wins when non-empty, else the proposal H1
|
|
14
|
+
* (legacy archive dirs).
|
|
13
15
|
*
|
|
14
16
|
* Depends_on extraction is deliberately dependency-free (no `yaml` package):
|
|
15
17
|
* it recognizes single-line flow `[a, b]`, block `- item` lists and multi-line
|
|
@@ -98,8 +100,8 @@ export function extractDependsOn(frontmatter: string): string {
|
|
|
98
100
|
return 'depends_on: []';
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
/** Compose a relationship-index card: `title` + `depends_on
|
|
103
|
+
/** Compose a relationship-index card: single-document YAML, `title` + `depends_on`. */
|
|
102
104
|
export function composeFrozenCard(title: string, frontmatter: string): string {
|
|
103
105
|
const dependsOn = extractDependsOn(frontmatter);
|
|
104
|
-
return [
|
|
106
|
+
return [`title: "${escapeYamlScalar(title)}"`, dependsOn].join('\n') + '\n';
|
|
105
107
|
}
|
|
@@ -43,6 +43,18 @@ export function extractFrontmatter(proposal: string): string | null {
|
|
|
43
43
|
return splitFrontmatter(proposal).frontmatter;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* r99: frontmatter `title` value ('' when absent/empty/non-string) — the
|
|
48
|
+
* authoritative change title; freeze prefers it over the proposal H1.
|
|
49
|
+
* Internal whitespace (incl. YAML folded newlines) collapses to single
|
|
50
|
+
* spaces so the frozen card stays a single-line YAML scalar.
|
|
51
|
+
*/
|
|
52
|
+
export function readFrontmatterTitle(frontmatter: string | null): string {
|
|
53
|
+
if (frontmatter === null) return '';
|
|
54
|
+
const title = parseDocument(frontmatter).get('title');
|
|
55
|
+
return typeof title === 'string' ? title.replaceAll(/\s+/gu, ' ').trim() : '';
|
|
56
|
+
}
|
|
57
|
+
|
|
46
58
|
/**
|
|
47
59
|
* r73: `needs_specs_change` is read from the frontmatter block only — a
|
|
48
60
|
* body line with the same text must not flip the verdict. Default true.
|
package/src/change/lifecycle.ts
CHANGED
|
@@ -59,7 +59,9 @@ export function newChange(
|
|
|
59
59
|
`change proposal already exists: ./${path} (pass --force to overwrite)`,
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
// r99: skeleton carries a non-empty title placeholder so a fresh draft
|
|
63
|
+
// passes the title gate; agents rewrite it when filling the proposal.
|
|
64
|
+
io.writeText(path, `---\ndepends_on: []\ntitle: TODO\n---\n\n${DRAFT_PROPOSAL_TEMPLATE}`);
|
|
63
65
|
return { id, path };
|
|
64
66
|
}
|
|
65
67
|
|
package/src/context/retrieve.ts
CHANGED
|
@@ -79,7 +79,7 @@ const SYSTEM_PROMPT = `You are a spec retriever. Given a task, classify which ca
|
|
|
79
79
|
3. For requirements that look relevant, call get_spec_content(spec_id, req_ids) to read the requirement text.
|
|
80
80
|
Then output ONLY this JSON (no markdown fence):
|
|
81
81
|
{\\"direct\\": [{\\"id\\": \\"<spec_id>\\", \\"reason\\": \\"<one sentence why this MUST be read>\\"}], \\"related\\": [{\\"id\\": \\"<spec_id>\\", \\"reason\\": \\"<one sentence>\\"}]}
|
|
82
|
-
- "direct" = specs whose behavior contract (any
|
|
82
|
+
- "direct" = specs whose behavior contract (any requirement-semantics statement, command behavior) the task changes or depends on.
|
|
83
83
|
- "related" = specs that provide useful context but whose contract won't change.
|
|
84
84
|
- If the task changes behavior, the governing spec MUST be in "direct".
|
|
85
85
|
- Decide based on the requirement text you read, not on the spec id alone.`;
|
package/src/git/spawnGit.ts
CHANGED
|
@@ -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
|
-
//
|
|
70
|
-
//
|
|
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
|
|
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,
|
|
@@ -128,6 +131,7 @@ export {
|
|
|
128
131
|
readBinding,
|
|
129
132
|
writeBinding,
|
|
130
133
|
extractFrontmatter,
|
|
134
|
+
readFrontmatterTitle,
|
|
131
135
|
readNeedsSpecsChange,
|
|
132
136
|
} from './change/frontmatter.ts';
|
|
133
137
|
export {
|
|
@@ -270,7 +274,6 @@ export {
|
|
|
270
274
|
export {
|
|
271
275
|
buildReview,
|
|
272
276
|
renderReviewHtml,
|
|
273
|
-
specRelFor,
|
|
274
277
|
type ReviewInput,
|
|
275
278
|
type ReviewKind,
|
|
276
279
|
type ReviewResult,
|
|
@@ -28,7 +28,7 @@ Agent 该做什么:
|
|
|
28
28
|
4. 迁移后运行 llman-sdd validate --specs --strict 与项目 BDD 套件,全绿为收口标准。
|
|
29
29
|
|
|
30
30
|
人类该做什么:
|
|
31
|
-
- 审阅 diff 与 req
|
|
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;
|
|
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.
|
|
62
|
-
4. 迁移后运行 llman-sdd validate --specs
|
|
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
|
|
75
|
-
4. After migration run llman-sdd validate --specs and confirm
|
|
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
|
+
}
|
package/src/report/graph/deps.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
/** Extract depends_on entries (flow + block styles, r30). */
|
|
2
2
|
import { extractFrontmatter } from '../../change/frontmatter.ts';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* r54 dual-format card reading: a fence-free frozen card is a plain YAML doc
|
|
6
|
+
* whose FIRST line opens with `title:`/`depends_on:` — feed the whole text to
|
|
7
|
+
* the same depends_on scan. Proposal.md bodies never open with those keys, so
|
|
8
|
+
* no misfire.
|
|
9
|
+
*/
|
|
10
|
+
function cardYamlSource(input: string): string | null {
|
|
11
|
+
const firstLine = input.trimStart().split('\n')[0] ?? '';
|
|
12
|
+
return /^(title|depends_on):/u.test(firstLine) ? input : null;
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
export function parseDeps(proposal: string): string[] {
|
|
5
|
-
const fm = extractFrontmatter(proposal);
|
|
16
|
+
const fm = extractFrontmatter(proposal) ?? cardYamlSource(proposal);
|
|
6
17
|
const deps: string[] = [];
|
|
7
18
|
if (!fm) return deps;
|
|
8
19
|
let inDeps = false;
|
|
@@ -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:
|
|
67
|
-
: `# language: ${language}\n# capability: ${capability}\n# purpose: TODO: Describe this capability and its purpose
|
|
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
|
package/src/report/specs.ts
CHANGED
|
@@ -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
|
});
|
package/src/review/review.ts
CHANGED
|
@@ -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' | '
|
|
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 (
|
|
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
|
|
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'
|
|
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
|
+
}
|
package/src/spec/parser.ts
CHANGED
|
@@ -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
|
|
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
|
|
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'
|
|
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
|
}
|
package/src/templates/skills.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { stageFor, walkActiveChangeDirs } from '../change/collect.ts';
|
|
|
2
2
|
import {
|
|
3
3
|
extractFrontmatter,
|
|
4
4
|
readBinding,
|
|
5
|
+
readFrontmatterTitle,
|
|
5
6
|
readNeedsSpecsChange,
|
|
6
7
|
specsLanded,
|
|
7
8
|
} from '../change/frontmatter.ts';
|
|
@@ -256,6 +257,16 @@ export function validateChange(
|
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
259
|
|
|
260
|
+
// r99 title gate: active changes require a non-empty frontmatter title
|
|
261
|
+
// (archived proposals never reach validateChange — archive is exempt).
|
|
262
|
+
if (readFrontmatterTitle(fm) === '') {
|
|
263
|
+
push(
|
|
264
|
+
'ERROR',
|
|
265
|
+
'proposal.md/frontmatter.title',
|
|
266
|
+
"proposal.md frontmatter requires a non-empty 'title' — add `title: <one-sentence concept title>` (do not repeat the change id).",
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
259
270
|
const binding = readBinding(text);
|
|
260
271
|
// stageFor (change/collect) is the monotonic stage SSOT (r34).
|
|
261
272
|
const stage = stageFor(hasDesign, hasTasks, binding !== null);
|
|
@@ -361,4 +372,5 @@ const ALLOWED_FIELDS = [
|
|
|
361
372
|
'base_branch',
|
|
362
373
|
'base_sha',
|
|
363
374
|
'needs_specs_change',
|
|
375
|
+
'title',
|
|
364
376
|
];
|
package/src/validation/roots.ts
CHANGED
|
@@ -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
|
-
|
|
50
|
-
|
|
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
|
-
}
|
|
@@ -26,7 +26,7 @@ flowchart LR
|
|
|
26
26
|
|
|
27
27
|
## Hard Constraints
|
|
28
28
|
|
|
29
|
-
- **Single-source-of-truth driven**: `proposal.md` / `design.md` / `tasks.md` and `llmanspec/specs/**` on the branch; every
|
|
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
31
|
- **No guessing**: unclear requirements or specs contradicting reality → STOP and report; don't assume.
|
|
32
32
|
- **No legacy compatibility layers**: if the change requires new behavior, upgrade all call sites directly, unless tasks/proposal explicitly require compatibility.
|
|
@@ -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") }}
|
|
@@ -26,8 +26,8 @@ flowchart LR
|
|
|
26
26
|
- **MUST NOT ask the user for a change id**: derive it from the description via `change new --from` and announce it.
|
|
27
27
|
- **MUST NOT create tasks/design/specs/attach**: only the `proposal.md` draft; full planning belongs to `llman-sdd-propose`.
|
|
28
28
|
- **MUST NOT assess change scale**: that is propose's job. If the user wants to start implementing → suggest `llman-sdd-propose`.
|
|
29
|
-
- **Scope boundary**: if the description clearly involves
|
|
30
|
-
- **Frontmatter has a fixed schema**: `proposal.md` accepts only the allowed fields in `llmanspec/AGENTS.md` "Change Proposal Frontmatter SSOT" (`depends_on`, `blocks`, `branch`, `base_sha`, `needs_specs_change`, etc.); `
|
|
29
|
+
- **Scope boundary**: if the description clearly involves behavioral-contract (requirement semantics) changes or multi-file impact, suggest `llman-sdd-propose` — but still create the draft first so the idea isn't lost.
|
|
30
|
+
- **Frontmatter has a fixed schema**: `proposal.md` accepts only the allowed fields in `llmanspec/AGENTS.md` "Change Proposal Frontmatter SSOT" (`depends_on`, `title`, `blocks`, `branch`, `base_sha`, `needs_specs_change`, etc.); `title` MUST be a non-empty one-sentence concept title and MUST NOT repeat the change id — missing or empty values are rejected by `llman-sdd validate` as ERROR, and so are out-of-set fields like `status`/`priority`/`author`. Lifecycle stage is inferred (query via `llman-sdd show`/`list`), never stored in frontmatter. Do not re-declare frontmatter fields in the prose body (no `## Status` block); the H1 MAY keep a human-readable title (freeze prefers the frontmatter `title`, falling back to the H1), not a repeat of the change id.
|
|
31
31
|
|
|
32
32
|
## Steps
|
|
33
33
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: "llman-sdd-propose"
|
|
3
|
-
description: "Create a proposal for
|
|
3
|
+
description: "Create a proposal for behavioral-contract (requirement semantics) changes (proposal/tasks → bind branch → land specs). Small changes → quick; ideas → draft."
|
|
4
4
|
metadata:
|
|
5
5
|
version: "{{ llman_version }}"
|
|
6
6
|
---
|
|
@@ -36,7 +36,7 @@ flowchart LR
|
|
|
36
36
|
{% else %}
|
|
37
37
|
- **If the change already exists**: STOP. If the specs-landed gate is green, suggest `llman-sdd-apply`; otherwise finish the planning docs / binding / landing specs (edit `llmanspec/changes/<id>/`, or enable `extra_skills: [llman-sdd-continue]`).
|
|
38
38
|
{% endif %}
|
|
39
|
-
- **Frontmatter has a fixed schema**: `proposal.md` accepts only the allowed fields in `llmanspec/AGENTS.md` "Change Proposal Frontmatter SSOT" (`depends_on`, `blocks`, `branch`, `base_sha`, `needs_specs_change`, etc.); `
|
|
39
|
+
- **Frontmatter has a fixed schema**: `proposal.md` accepts only the allowed fields in `llmanspec/AGENTS.md` "Change Proposal Frontmatter SSOT" (`depends_on`, `title`, `blocks`, `branch`, `base_sha`, `needs_specs_change`, etc.); `title` MUST be a non-empty one-sentence concept title and MUST NOT repeat the change id — missing or empty values are rejected by `llman-sdd validate` as ERROR, and so are out-of-set fields like `status`/`priority`/`author`. Lifecycle stage is inferred (query via `llman-sdd show`/`list`), never stored in frontmatter. Do not re-declare frontmatter fields in the prose body; the H1 MAY keep a human-readable title (freeze prefers the frontmatter `title`, falling back to the H1), not a repeat of the change id.
|
|
40
40
|
|
|
41
41
|
## Quick-capture routing
|
|
42
42
|
|
|
@@ -51,7 +51,7 @@ If the user just wants to **capture an idea** ("draft a proposal", "note down X"
|
|
|
51
51
|
|
|
52
52
|
### 1) Assess change scale
|
|
53
53
|
1. Classify:
|
|
54
|
-
- **Behavioral contract change** (modify
|
|
54
|
+
- **Behavioral contract change** (modify requirement semantics, change external behavior) → full SDD
|
|
55
55
|
- **Implementation change** (refactor, typo, perf) → `llman-sdd-quick`
|
|
56
56
|
- **Meta-spec change** (SDD templates/process) → full SDD
|
|
57
57
|
- When uncertain, choose full SDD (conservative).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: "llman-sdd-quick"
|
|
3
|
-
description: "Quick path for small changes that don't touch behavioral contracts (refactor/typo/perf). If a
|
|
3
|
+
description: "Quick path for small changes that don't touch behavioral contracts (refactor/typo/perf). If a behavioral-contract (requirement semantics) change emerges, stop and switch to propose."
|
|
4
4
|
metadata:
|
|
5
5
|
version: "{{ llman_version }}"
|
|
6
6
|
---
|
|
@@ -22,7 +22,7 @@ flowchart LR
|
|
|
22
22
|
> 📍 Quick path: edit code and commit directly. If you find a contract change is needed → STOP, switch to `llman-sdd-propose`.
|
|
23
23
|
|
|
24
24
|
## Conditions (all must hold)
|
|
25
|
-
- Does not change any
|
|
25
|
+
- Does not change any requirement-semantics-defined externally observable behavior
|
|
26
26
|
- Does not cross capability boundaries; no migration/compatibility concerns; not an SDD meta-spec change
|
|
27
27
|
|
|
28
28
|
## Steps
|
|
@@ -14,7 +14,7 @@ Spin up a **background agent** to do the research while you keep working. Auxili
|
|
|
14
14
|
1. Investigate against **primary sources** — official docs, source code, specs, first-party APIs, not secondary write-ups; trace every claim back to the source that owns it.
|
|
15
15
|
2. Write findings to a single Markdown file, citing each claim's source.
|
|
16
16
|
3. Save location (repo convention wins if it has one): **default** `llmanspec/changes/<current-change>/research/<topic>.md` (change docs, **not** specs). Write to `docs/research/` only when the topic spans multiple changes and will still be referenced after archiving; **never** put single-change decisions or decaying deep-dives into `docs/research/`.
|
|
17
|
-
4. **MUST NOT** edit `llmanspec/specs/**` in this skill. If research shows
|
|
17
|
+
4. **MUST NOT** edit `llmanspec/specs/**` in this skill. If research shows requirement semantics must change → suggest `llman-sdd-propose` (bind branch → land specs).
|
|
18
18
|
|
|
19
19
|
## Steps
|
|
20
20
|
|
|
@@ -7,7 +7,7 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# LLMAN SDD Validate
|
|
9
9
|
|
|
10
|
-
Validate change/spec format
|
|
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.
|
|
@@ -5,12 +5,11 @@ 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`):
|
|
12
11
|
- One canonical style: `@req:<id>` on the `规则:` block header, nested `场景:` (Given/When/Then) as executable examples — the default preferred shape.
|
|
13
|
-
- Only keep a `规则:` block with no nested scenario (bare rule) for requirements that cannot be expressed programmatically or are not yet converted: free-text description, no
|
|
12
|
+
- Only keep a `规则:` block with no nested scenario (bare rule) for requirements that cannot be expressed programmatically or are not yet converted: free-text description, no modal-verb enforcement; validate reports an aggregate count, the review `pending` signal measures it, specs-compact keeps reducing it.
|
|
14
13
|
- Legacy tags `@executable`/`@rule`/`@human`/`@manual` are gone and parse inert; when old files hit structural problems run `llman-sdd spec migrate-native`.
|
|
15
14
|
- Top-level `场景:` outside any `规则:` are plain feature-level examples: no rule handle, no warning, not part of rule accounting (native Gherkin).
|
|
16
15
|
|
|
@@ -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:`
|
|
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).
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
## Archive Cold Backup Guidance
|
|
2
|
-
- When archived directories grow too large, use cold backup maintenance (freeze moves bodies into the 7z cold backup and replaces the dir with a flat `<YYYY-MM-DD>-<id>.yaml` index card carrying only `title` and `depends_on`):
|
|
2
|
+
- When archived directories grow too large, use cold backup maintenance (freeze moves bodies into the 7z cold backup and replaces the dir with a flat `<YYYY-MM-DD>-<id>.yaml` index card — single-document plain YAML carrying only `title` and `depends_on`):
|
|
3
3
|
- Preview freeze candidates: `llman-sdd archive freeze --dry-run`
|
|
4
4
|
- Freeze old archives: `llman-sdd archive freeze --before <YYYY-MM-DD> --keep-recent <N>`
|
|
5
5
|
- List frozen entries: `llman-sdd archive freeze --list`
|
|
6
6
|
- Restore when needed: `llman-sdd archive thaw --change <YYYY-MM-DD-id>` (extracts bodies back and removes the card)
|
|
7
7
|
- Apply freeze/thaw only to dated archive directories (`YYYY-MM-DD-*`); keep a small recent window unfrozen.
|
|
8
|
-
- The flat index card stays on disk: `title` (
|
|
8
|
+
- The flat index card stays on disk: `title` (the frontmatter `title` when non-empty, else the proposal H1) and `depends_on` (seed for graph dependency edges) are grep-able and traceable; the id and date are implied by the file name — the purpose and dependencies of a frozen change are inspectable without thawing, while bodies live in the 7z cold backup and are fetched on demand.
|
|
9
9
|
- Running outside the main checkout (a worktree not holding the default branch) prints a warning (never blocks) — continue there only intentionally.
|
|
@@ -26,7 +26,7 @@ flowchart LR
|
|
|
26
26
|
|
|
27
27
|
## 硬约束
|
|
28
28
|
|
|
29
|
-
- **唯一事实来源驱动**:`proposal.md` / `design.md` / `tasks.md` 与分支上的 `llmanspec/specs/**`;specs
|
|
29
|
+
- **唯一事实来源驱动**:`proposal.md` / `design.md` / `tasks.md` 与分支上的 `llmanspec/specs/**`;specs 的行为合约条款逐条落实。
|
|
30
30
|
- **范围锁定**:只做当前 change 范围,不得顺手修无关问题;改动保持最小。
|
|
31
31
|
- **不得猜测**:需求不明或 specs 与现实矛盾 → STOP 报告,不自行假定。
|
|
32
32
|
- **不留旧兼容层**:change 要求改行为就全量升级到新写法,除非 tasks/proposal 明确要兼容。
|
|
@@ -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") }}
|
|
@@ -26,8 +26,8 @@ flowchart LR
|
|
|
26
26
|
- **不得 询问 change id**:由 `change new --from` 从描述推导并告知用户。
|
|
27
27
|
- **不得 创建 tasks/design/specs/attach**:只建 `proposal.md` 草案;完整规划归 `llman-sdd-propose`。
|
|
28
28
|
- **不得 判断变更规模**:那是 propose 的职责。用户想开始实现 → 宜转 `llman-sdd-propose`。
|
|
29
|
-
-
|
|
30
|
-
- **frontmatter 有固定 schema**:`proposal.md` 只接受 `llmanspec/AGENTS.md`“Change Proposal Frontmatter SSOT”的合法字段(`depends_on`、`blocks`、`branch`、`base_sha`、`needs_specs_change` 等);`
|
|
29
|
+
- **适用边界**:描述明显涉及行为合约(需求语义)变更或多文件改动时,宜转 `llman-sdd-propose`——但仍先建草案以免想法丢失。
|
|
30
|
+
- **frontmatter 有固定 schema**:`proposal.md` 只接受 `llmanspec/AGENTS.md`“Change Proposal Frontmatter SSOT”的合法字段(`depends_on`、`title`、`blocks`、`branch`、`base_sha`、`needs_specs_change` 等);`title` 必须为非空的一句话概念式标题,不得复读 change id——缺失或为空串时 `llman-sdd validate` 报 ERROR;`status`/`priority`/`author` 等集外字段同样报 ERROR。生命周期阶段是推断量(用 `llman-sdd show`/`list` 查),不得写进 frontmatter。正文不得复读 frontmatter 字段(不得 `## Status` 段);H1 宜保留人类可读标题(freeze 取 title 时 frontmatter 优先、H1 回退),不复读 change id。
|
|
31
31
|
|
|
32
32
|
## 步骤
|
|
33
33
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: "llman-sdd-propose"
|
|
3
|
-
description: "
|
|
3
|
+
description: "为行为合约(需求语义)变更创建提案(proposal/tasks → 绑定分支 → 提交 specs)。小改动走 quick,记想法走 draft。"
|
|
4
4
|
metadata:
|
|
5
5
|
version: "{{ llman_version }}"
|
|
6
6
|
---
|
|
@@ -36,7 +36,7 @@ flowchart LR
|
|
|
36
36
|
{% else %}
|
|
37
37
|
- **change 已存在**:STOP。specs-landed 门已绿 → 宜接 `llman-sdd-apply`;否则补规划文档 / 绑定分支 / 提交 specs(编辑 `llmanspec/changes/<id>/`,或配置 `extra_skills: [llman-sdd-continue]`)。
|
|
38
38
|
{% endif %}
|
|
39
|
-
- **frontmatter 有固定 schema**:`proposal.md` 只接受 `llmanspec/AGENTS.md`“Change Proposal Frontmatter SSOT”的合法字段(`depends_on`、`blocks`、`branch`、`base_sha`、`needs_specs_change` 等);`
|
|
39
|
+
- **frontmatter 有固定 schema**:`proposal.md` 只接受 `llmanspec/AGENTS.md`“Change Proposal Frontmatter SSOT”的合法字段(`depends_on`、`title`、`blocks`、`branch`、`base_sha`、`needs_specs_change` 等);`title` 必须为非空的一句话概念式标题,不得复读 change id——缺失或为空串时 `llman-sdd validate` 报 ERROR;`status`/`priority`/`author` 等集外字段同样报 ERROR。生命周期阶段是推断量(用 `llman-sdd show`/`list` 查),不得写进 frontmatter。正文不得复读 frontmatter 字段;H1 宜保留人类可读标题(freeze 取 title 时 frontmatter 优先、H1 回退),不复读 change id。
|
|
40
40
|
|
|
41
41
|
## 快速记录分流
|
|
42
42
|
|
|
@@ -51,7 +51,7 @@ flowchart LR
|
|
|
51
51
|
|
|
52
52
|
### 1) 判断变更规模
|
|
53
53
|
1. 分类:
|
|
54
|
-
-
|
|
54
|
+
- **行为合约变更**(改需求语义、改外部行为)→ 完整 SDD
|
|
55
55
|
- **实现层变更**(重构、typo、性能)→ `llman-sdd-quick`
|
|
56
56
|
- **元规范变更**(SDD 模板/流程)→ 完整 SDD
|
|
57
57
|
- 不确定选完整 SDD(保守)。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: "llman-sdd-quick"
|
|
3
|
-
description: "
|
|
3
|
+
description: "快速路径:不改行为合约的小改动(重构/错字/性能)。要改行为合约(需求语义)就停,转 propose。"
|
|
4
4
|
metadata:
|
|
5
5
|
version: "{{ llman_version }}"
|
|
6
6
|
---
|
|
@@ -22,7 +22,7 @@ flowchart LR
|
|
|
22
22
|
> 📍 快速路径:直接改代码 commit。发现要改合约 → STOP,转 `llman-sdd-propose`。
|
|
23
23
|
|
|
24
24
|
## 使用条件(全部满足)
|
|
25
|
-
- 不改变任何 spec
|
|
25
|
+
- 不改变任何 spec 中需求语义定义的外部可观测行为
|
|
26
26
|
- 不跨 capability;不涉及迁移/兼容性;不是 SDD 元规范变更
|
|
27
27
|
|
|
28
28
|
## 步骤
|
|
@@ -14,7 +14,7 @@ metadata:
|
|
|
14
14
|
1. 针对**一手资料**调研——官方文档、源码、spec、第一方 API,而非二手转述;每个论断追溯到拥有它的源头。
|
|
15
15
|
2. 发现写入单个 Markdown 文件,每条论断标注来源。
|
|
16
16
|
3. 存放(仓库另有约定时优先):**默认** `llmanspec/changes/<current-change>/research/<topic>.md`(change 文档,**不是** specs)。仅当主题跨多个 change、归档后仍常引用时才写 `docs/research/`;**不得**把单 change 选型/易腐深挖塞进 `docs/research/`。
|
|
17
|
-
4. **不得**本 skill 直接编辑 `llmanspec/specs
|
|
17
|
+
4. **不得**本 skill 直接编辑 `llmanspec/specs/**`。调研表明行为合约(需求语义)必须改 → 宜转 `llman-sdd-propose`(绑定分支 → 提交 specs)。
|
|
18
18
|
|
|
19
19
|
## 步骤
|
|
20
20
|
|
|
@@ -5,12 +5,11 @@
|
|
|
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`):
|
|
12
11
|
- 规范样式只有一种:`@req:<id>` 挂在 `规则:` 块头标签,块内嵌套 `场景:`(假如/当/那么)是可执行示例——默认首选。
|
|
13
|
-
- 仅当需求无法程序化表达或暂不转写时才保留无嵌套场景的 `规则:`(裸规则)
|
|
12
|
+
- 仅当需求无法程序化表达或暂不转写时才保留无嵌套场景的 `规则:`(裸规则):描述自由文本,不强制情态词;validate 以聚合计数提示,review `pending` 信号计量,specs-compact 负责压降。
|
|
14
13
|
- 历史标签 `@executable`/`@rule`/`@human`/`@manual` 不再使用、解析惰性;旧文件报结构问题时运行 `llman-sdd spec migrate-native` 迁移。
|
|
15
14
|
- 不在任何 `规则:` 内的顶层 `场景:` 是功能级示例:无规则句柄、不告警、不参与规则统计(Gherkin 原生语义)。
|
|
16
15
|
|
|
@@ -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
|
|
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,10 +1,10 @@
|
|
|
1
1
|
## Archive 冷备引导
|
|
2
|
-
- archive 目录过大时用冷备维护(冻结 = 正文入 7z 冷备 + 以 `<YYYY-MM-DD>-<id>.yaml`
|
|
2
|
+
- archive 目录过大时用冷备维护(冻结 = 正文入 7z 冷备 + 以 `<YYYY-MM-DD>-<id>.yaml` 平铺索引卡替代目录,卡为单文档纯 YAML、仅含 title 与 depends_on):
|
|
3
3
|
- 预览冻结候选:`llman-sdd archive freeze --dry-run`
|
|
4
4
|
- 冻结旧归档:`llman-sdd archive freeze --before <YYYY-MM-DD> --keep-recent <N>`
|
|
5
5
|
- 列出已冻结条目:`llman-sdd archive freeze --list`
|
|
6
6
|
- 需要恢复时:`llman-sdd archive thaw --change <YYYY-MM-DD-id>`(正文解回目录并移除平铺卡)
|
|
7
7
|
- freeze/thaw 仅用于日期归档目录(`YYYY-MM-DD-*`);宜保留最近 2 个目录不冻结。
|
|
8
|
-
- 平铺索引卡常驻磁盘:title
|
|
8
|
+
- 平铺索引卡常驻磁盘:title(frontmatter `title` 非空时优先,否则取 proposal H1)与 depends_on(graph 依赖边种子)可 grep、可追溯;
|
|
9
9
|
id 与日期由文件名隐含——冻结 change 的用途与依赖关系无需解冻即可查阅,正文在 7z 冷备按需取用。
|
|
10
10
|
- 在非主检出(不持有默认分支的 worktree)运行时打印警告(仅提示、不阻断)——有意为之才在该处继续。
|
|
@@ -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 据此消警;旧版自由注释随触碰一并机械清理(删除、不搬运)。
|