docs(prds): normalise statuses and remove writing dated to its own day
Three defects the first sweep left behind, each caught by a rule the guard did not yet have. Statuses. RULES.md gives three; the tree had 25 values, and the free-text ones were carrying progress. "Implemented (wiring landed)" and "Ratified (rev. 2e). Rev. 2e adds the OpenTaskByPR lookup. Rev. 2d revised section 10..." were both changelogs living in the one field the other rules exempt. Every PRD now declares Draft, Approved or Finalised and nothing else; five that declared nothing now declare one. A revision number moves to **Revision:**, a pointer to the authoritative document to **Authority:**, and what a past revision changed to git. CLAUDE.md's citation of state-store-contract rev. 2e still resolves. Stale cross-references. "Supersedes the 2026-09-03 open question", "this bullet previously said", "an earlier draft of this document claimed" all point at text the reader cannot see, because it was replaced. A supersede marker survives only when it names a file, a section or a symbol that can be found. Temporal hedges. 100 uses of today, currently and right now across 31 files. Each dates its sentence to the day it was written: "[notify] today is one webhook URL, read in one place" stops being true the moment this design lands, while still reading as the premise it rests on. The header-field exemption was also too wide. "**Date:** 2026-09-03, Channel resolved 2026-09-22" smuggled a dated status into the one line the rules did not read; the exemption is now a Date holding only a date and a Status holding only one of the three.
This commit is contained in:
1 parent
2eba3487a8
commit
fcde69c76c
48 files changed
+344
-258
No files matched your search
+54
-7
@@ -37,7 +37,7 @@ var rules = []rule{
|
||||
},
|
||||
{
|
||||
name: "dated-status",
|
||||
pattern: regexp.MustCompile(`(?i)\b(status|resolved|settled|decided|agreed|approved|shipped|landed|complete|completed|done|wired|verified|corrected|confirmed)\b[^.\n]{0,30}\b20\d\d-\d\d-\d\d\b`),
|
||||
pattern: regexp.MustCompile(`(?i)\b(status|resolved|settled|decided|agreed|approved|supersedes|superseded|withdrawn|shipped|landed|complete|completed|done|wired|verified|corrected|confirmed)\b[^.\n]{0,30}\b20\d\d-\d\d-\d\d\b`),
|
||||
remedy: "drop the date and the state. A PRD says what the design is; the tracker and git history say when it happened.",
|
||||
},
|
||||
{
|
||||
@@ -50,6 +50,16 @@ var rules = []rule{
|
||||
pattern: regexp.MustCompile(`(?i)\bphases?\s+\d[^.\n]{0,40}\b(complete|completed|done|shipped|landed|in progress|underway|remaining)\b|\b(complete|completed|done|shipped|landed|in progress)\b[^.\n]{0,20}\bphases?\s+\d`),
|
||||
remedy: "a phased plan is durable design; which phase is finished is not. Name the phases, not their state.",
|
||||
},
|
||||
{
|
||||
name: "temporal-hedge",
|
||||
pattern: regexp.MustCompile(`(?i)\b(today|currently|right now|at present|at the moment|as things stand|for now)\b`),
|
||||
remedy: "\"today\" dates the sentence to the day it was written, so the claim it qualifies is false the moment the design lands. Describe the shape being replaced without asserting it is the present.",
|
||||
},
|
||||
{
|
||||
name: "stale-cross-reference",
|
||||
pattern: regexp.MustCompile(`(?i)\bthis (bullet|section|document|doc|paragraph|note) (previously|originally|earlier)\b|\b(an?|the) earlier (draft|note|version|section) of this\b|\bthe earlier (draft|note|version)\b|\bpreviously said\b|\bused to say\b`),
|
||||
remedy: "a reader cannot see what the document used to say, so the reference resolves to nothing. State the current decision; git history holds the rest. A supersede marker is fine when it names a file, a section or a symbol the reader can find.",
|
||||
},
|
||||
{
|
||||
name: "session-artefact",
|
||||
pattern: regexp.MustCompile(`(?i)\b(crew investigation|investigation pass|not committed|caught in review|this session|at time of writing|in this session)\b`),
|
||||
@@ -62,12 +72,33 @@ var rules = []rule{
|
||||
// content being specified.
|
||||
var codeFence = regexp.MustCompile("^\\s*```")
|
||||
|
||||
// headerField matches the leading metadata block's own fields. A PRD records
|
||||
// its own status and date there by design (RULES.md gives three statuses), so
|
||||
// those lines are the one place a date and a status belong.
|
||||
var headerField = regexp.MustCompile(`^\*\*(Status|Date|Parent|Blocked on|Supersedes|Superseded by):\*\*`)
|
||||
// exemptHeader matches the two metadata fields that carry a status and a date
|
||||
// by design (RULES.md gives three statuses). The match is deliberately narrow:
|
||||
// a Date field holding only a date, and a Status field holding only one of the
|
||||
// three. A wider exemption let "**Date:** 2026-09-03, Channel resolved
|
||||
// 2026-09-22" smuggle a dated status into the one line the rules did not read.
|
||||
var exemptHeader = regexp.MustCompile(`^\*\*Date:\*\*\s*20\d\d-\d\d-\d\d\s*$|^\*\*Status:\*\*\s*(Draft|Approved|Finalised)\s*$`)
|
||||
|
||||
// Lint reports every rule violation in one document.
|
||||
// statusField matches the document's own status line, whatever it holds.
|
||||
var statusField = regexp.MustCompile(`^\*\*Status:\*\*\s*(.*)$`)
|
||||
|
||||
// statuses is the closed set from RULES.md. A status outside it is how a
|
||||
// progress report gets into the one field the rules cannot read: "Implemented
|
||||
// (wiring landed)" and "Ratified (rev. 2e). Rev. 2e adds..." were both really
|
||||
// changelogs.
|
||||
var statuses = map[string]bool{"Draft": true, "Approved": true, "Finalised": true}
|
||||
|
||||
// statusRemedy is the status rule's fix. It is not in rules because the check
|
||||
// is document-level: a missing field has no line to point at.
|
||||
const statusRemedy = "every PRD carries exactly one of Draft, Approved or Finalised. Anything else is a progress report in the one field the other rules exempt."
|
||||
|
||||
// LintDocument reports every violation in a whole document: the status the
|
||||
// document must declare, then each line.
|
||||
func LintDocument(name, content string) []Finding {
|
||||
return append(lintStatus(name, content), Lint(name, content)...)
|
||||
}
|
||||
|
||||
// Lint reports every line-level rule violation in one document.
|
||||
func Lint(name, content string) []Finding {
|
||||
var findings []Finding
|
||||
inFence := false
|
||||
@@ -76,7 +107,7 @@ func Lint(name, content string) []Finding {
|
||||
inFence = !inFence
|
||||
continue
|
||||
}
|
||||
if inFence || headerField.MatchString(line) {
|
||||
if inFence || exemptHeader.MatchString(line) {
|
||||
continue
|
||||
}
|
||||
for _, r := range rules {
|
||||
@@ -87,3 +118,19 @@ func Lint(name, content string) []Finding {
|
||||
}
|
||||
return findings
|
||||
}
|
||||
|
||||
// lintStatus checks the one status line RULES.md requires, since a missing or
|
||||
// free-text status is not a line-level violation any pattern above would see.
|
||||
func lintStatus(name, content string) []Finding {
|
||||
for i, line := range strings.Split(content, "\n") {
|
||||
m := statusField.FindStringSubmatch(line)
|
||||
if m == nil {
|
||||
continue
|
||||
}
|
||||
if statuses[strings.TrimSpace(m[1])] {
|
||||
return nil
|
||||
}
|
||||
return []Finding{{File: name, Line: i + 1, Rule: "status", Text: line}}
|
||||
}
|
||||
return []Finding{{File: name, Line: 1, Rule: "status", Text: "no **Status:** field"}}
|
||||
}
|
||||
@@ -56,6 +56,11 @@ func TestLintRejectsSessionBoundWriting(t *testing.T) {
|
||||
doc: "Phase 2 is complete and Phase 3 starts next.",
|
||||
rule: "phase-progress",
|
||||
},
|
||||
{
|
||||
name: "temporal hedge",
|
||||
doc: "`[notify]` today is one webhook URL, read in one place.",
|
||||
rule: "temporal-hedge",
|
||||
},
|
||||
{
|
||||
name: "session artefact",
|
||||
doc: "Grounded by a crew investigation pass.",
|
||||
@@ -95,6 +100,35 @@ func TestLintAcceptsDurableWriting(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestLintRequiresACanonicalStatus: RULES.md gives three statuses, and a
|
||||
// free-text one is where "Implemented (wiring landed)" hid a progress report.
|
||||
func TestLintRequiresACanonicalStatus(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
doc string
|
||||
want bool
|
||||
}{
|
||||
{"draft", "# T\n\n**Status:** Draft\n", false},
|
||||
{"approved", "# T\n\n**Status:** Approved\n", false},
|
||||
{"finalised", "# T\n\n**Status:** Finalised\n", false},
|
||||
{"free text", "# T\n\n**Status:** Implemented (wiring landed)\n", true},
|
||||
{"status with a changelog", "# T\n\n**Status:** Ratified (rev. 2e). Rev. 2e adds a lookup\n", true},
|
||||
{"missing entirely", "# T\n\nBody.\n", true},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var got bool
|
||||
for _, f := range LintDocument("x.md", tc.doc) {
|
||||
if f.Rule == "status" {
|
||||
got = true
|
||||
}
|
||||
}
|
||||
if got != tc.want {
|
||||
t.Fatalf("status finding = %v, want %v", got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestLintSkipsFencedBlocks: a code listing may legitimately contain a line
|
||||
// reference or a status string as the content being specified.
|
||||
func TestLintSkipsFencedBlocks(t *testing.T) {
|
||||
|
||||
@@ -79,7 +79,7 @@ func lintDir(dir string) ([]Finding, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
findings = append(findings, Lint(name, string(data))...)
|
||||
findings = append(findings, LintDocument(name, string(data))...)
|
||||
}
|
||||
return findings, nil
|
||||
}
|
||||
@@ -89,6 +89,12 @@ func lintDir(dir string) ([]Finding, error) {
|
||||
func remedies(findings []Finding) []string {
|
||||
seen := map[string]bool{}
|
||||
var out []string
|
||||
for _, f := range findings {
|
||||
if f.Rule == "status" && !seen["status"] {
|
||||
seen["status"] = true
|
||||
out = append(out, " status: "+statusRemedy)
|
||||
}
|
||||
}
|
||||
for _, r := range rules {
|
||||
for _, f := range findings {
|
||||
if f.Rule == r.name && !seen[r.name] {
|
||||
|
||||
Reference in new issue
Block a user