Skip to content

Commit 2b5b345

Browse files
authored
docs: enforce current documentation lifecycle (#1107)
* docs: enforce current documentation lifecycle * ci: rebuild pages for docs lifecycle changes * docs: state inclusive health thresholds * test: cover approval-gated age field * test: bind health docs to runtime fields
1 parent e137917 commit 2b5b345

8 files changed

Lines changed: 344 additions & 46 deletions

File tree

‎.github/workflows/pages.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
paths:
88
- "docs/**"
9+
- "config/documentation-site.json"
910
- "scripts/build-docs-site.mjs"
1011
- ".github/workflows/pages.yml"
1112
workflow_dispatch:

‎config/documentation-site.json‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"version": 1,
3+
"sections": [
4+
{
5+
"name": "Start",
6+
"pages": ["README.md", "orchestration.md", "scheduler.md", "work-lane.md"]
7+
},
8+
{
9+
"name": "Review and policy",
10+
"pages": [
11+
"commit-sweeper.md",
12+
"review-cache.md",
13+
"pr-review-comments.md",
14+
"pr-proof-triage-dashboard.md",
15+
"author-pr-budget-close-policy.md",
16+
"obsolescence-close-policies.md",
17+
"product-direction-close-policy.md",
18+
"stalled-pr-close-policies.md",
19+
"unsponsored-feature-close-policy.md"
20+
]
21+
},
22+
{
23+
"name": "Operations",
24+
"pages": [
25+
"limits.md",
26+
"live-dashboard.md",
27+
"openclaw-bay-demo.md",
28+
"openclaw-event-hooks.md",
29+
"state-storage.md",
30+
"action-ledger.md",
31+
"target-dispatcher.md",
32+
"target-repositories.md",
33+
"triage-dashboard.md",
34+
"related-issue-discovery.md",
35+
"spam-scanner.md",
36+
"local-clawsweeper-skill.md"
37+
]
38+
},
39+
{
40+
"name": "Repair",
41+
"pages": [
42+
"steerable-repair-automation.md",
43+
"repair/README.md",
44+
"repair/operations.md",
45+
"repair/automatic-issue-prs.md",
46+
"repair/auto-update-prs.md",
47+
"repair/automerge-flow.md",
48+
"repair/automerge-e2e.md",
49+
"repair/internal-features.md"
50+
]
51+
}
52+
],
53+
"noncanonical": [
54+
{
55+
"path": "queue-service-split-runbook.md",
56+
"lifecycle": "proposed",
57+
"banner": "This is an unapproved proposal, not current operator guidance."
58+
},
59+
{
60+
"path": "repair/containment-validation-todo.md",
61+
"lifecycle": "historical",
62+
"banner": "This is historical decision evidence, not current operator guidance."
63+
},
64+
{
65+
"prefix": "proof/",
66+
"lifecycle": "historical proof",
67+
"banner": "This immutable proof records behavior at its stated revision and does not override current documentation."
68+
}
69+
]
70+
}

‎docs/README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,10 @@ The check deliberately does not crawl external URLs, infer policy, assign
169169
ownership, or treat historical proof commands and paths as current contracts.
170170
The index, lifecycle labels, and whether a configuration claim should become
171171
policy remain human-reviewed.
172+
173+
The public documentation build reads `config/documentation-site.json` as its
174+
exhaustive lifecycle manifest. Active pages appear in navigation, search, the
175+
sitemap, and `llms.txt`. Proposed, historical, and proof pages remain available
176+
at stable generated paths for evidence links, but carry a visible lifecycle
177+
banner and `noindex` metadata and are excluded from canonical discovery. The
178+
documentation check fails when a page is unclassified or classified twice.

‎docs/live-dashboard.md‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,10 @@ is absent or a cache event lands in another Cloudflare colo.
127127
- a budget-sized capacity rail plus lane filters for issue-to-PR, PR repair,
128128
review, repair, commit, assist, and other workers
129129
- queued/waiting run count
130-
- operational health derived from queue age and running age: queued runs become
131-
degraded after 30 minutes, and in-progress runs become stalled after 150
132-
minutes
130+
- operational health derived from queue age and running age: queued runs from
131+
30 through 1440 minutes old degrade operational health; queued runs older
132+
than 1440 minutes are reported separately as zombies; approval-gated runs are
133+
also reported separately; in-progress runs become stalled after 150 minutes
133134
- 24-hour and seven-day health trends for total queue depth, over-age queue
134135
depth, and the oldest queued/running ages
135136
- job-level worker attempt error rate, recovery rate, and unresolved failures,
@@ -232,16 +233,23 @@ rate appears about five minutes after deployment.
232233
Operational health remains a current-snapshot alert rather than a historical
233234
chart. `/api/status` classifies the already-fetched active workflow runs as:
234235

235-
- `healthy`: complete telemetry and no over-age runs;
236-
- `degraded`: at least one queued run is 30 minutes old;
236+
- `healthy`: complete telemetry and no non-zombie over-age runs;
237+
- `degraded`: at least one queued run is from 30 through 1440 minutes old;
237238
- `stalled`: at least one in-progress run is 150 minutes old;
238239
- `unknown`: one or more actionable-status reads failed.
239240

240-
Healthy status stays hidden. A queued run over 30 minutes, an in-progress run
241-
over 150 minutes, or incomplete Actions telemetry opens the expandable “Work
242-
execution needs attention” alert. This live diagnostic reuses the status
243-
snapshot's Actions reads; the history cron no longer stores queue pressure or
244-
oldest-run values.
241+
Healthy status stays hidden. A non-zombie queued run at least 30 minutes old, an
242+
in-progress run at least 150 minutes old, or incomplete Actions telemetry opens the
243+
expandable “Work execution needs attention” alert. This live diagnostic reuses
244+
the status snapshot's Actions reads; the history cron no longer stores queue
245+
pressure or oldest-run values.
246+
247+
Queued runs older than 1440 minutes are reported separately as zombies and do
248+
not contribute to `queued_over_threshold` or `oldest_queued_minutes`; they
249+
therefore do not make an otherwise healthy snapshot degraded. The API exposes
250+
them as `zombie_queued_runs` and `oldest_zombie_queued_minutes`. Runs waiting on
251+
deployment approval are also excluded from queue pressure and exposed as
252+
`approval_gated_runs` and `oldest_approval_gated_minutes`.
245253

246254
## Boundaries
247255

‎scripts/build-docs-site.mjs‎

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,9 @@ const outDir = path.join(root, "dist", "docs-site");
99
const repoUrl = "https://github.com/openclaw/clawsweeper";
1010
const repoEditBase = `${repoUrl}/edit/main/docs`;
1111
const customDomain = "clawsweeper.bot";
12-
13-
const sections = [
14-
["Start", ["README.md", "scheduler.md", "work-lane.md"]],
15-
[
16-
"Lanes",
17-
[
18-
"commit-sweeper.md",
19-
"target-dispatcher.md",
20-
"pr-review-comments.md",
21-
"openclaw-event-hooks.md",
22-
],
23-
],
24-
[
25-
"Repair",
26-
[
27-
"repair/README.md",
28-
"repair/operations.md",
29-
"repair/automatic-issue-prs.md",
30-
"repair/auto-update-prs.md",
31-
"repair/automerge-flow.md",
32-
"repair/internal-features.md",
33-
],
34-
],
35-
];
12+
const siteManifest = JSON.parse(
13+
fs.readFileSync(path.join(root, "config", "documentation-site.json"), "utf8"),
14+
);
3615

3716
fs.rmSync(outDir, { recursive: true, force: true });
3817
fs.mkdirSync(outDir, { recursive: true });
@@ -41,7 +20,15 @@ const pages = allMarkdown(docsDir).map((file) => {
4120
const rel = path.relative(docsDir, file).replaceAll(path.sep, "/");
4221
const markdown = fs.readFileSync(file, "utf8");
4322
const title = firstHeading(markdown) || titleize(path.basename(rel, ".md"));
44-
return { file, rel, title, outRel: outPath(rel), markdown, synthetic: false };
23+
return {
24+
file,
25+
rel,
26+
title,
27+
outRel: outPath(rel),
28+
markdown,
29+
synthetic: false,
30+
lifecycle: lifecycleFor(rel),
31+
};
4532
});
4633

4734
const homePage = {
@@ -51,21 +38,23 @@ const homePage = {
5138
outRel: "index.html",
5239
markdown: "",
5340
synthetic: true,
41+
lifecycle: { canonical: true, name: "active" },
5442
};
5543
pages.unshift(homePage);
5644

5745
const pageMap = new Map(pages.map((page) => [page.rel, page]));
58-
const nav = sections
59-
.map(([name, rels]) => ({
60-
name,
61-
pages: rels.map((rel) => pageMap.get(rel)).filter(Boolean),
46+
const nav = siteManifest.sections
47+
.map((section) => ({
48+
name: section.name,
49+
pages: section.pages.map((rel) => pageMap.get(rel)).filter(Boolean),
6250
}))
6351
.filter((section) => section.pages.length);
6452

6553
const sectionByRel = new Map();
6654
for (const section of nav)
6755
for (const page of section.pages) sectionByRel.set(page.rel, section.name);
6856
const orderedPages = [homePage, ...nav.flatMap((s) => s.pages)];
57+
const canonicalPages = orderedPages;
6958

7059
for (const page of pages) {
7160
const html = page.synthetic ? "" : markdownToHtml(page.markdown, page.rel);
@@ -89,7 +78,7 @@ fs.writeFileSync(
8978
`User-agent: *\nAllow: /\nSitemap: https://${customDomain}/sitemap.xml\n`,
9079
"utf8",
9180
);
92-
fs.writeFileSync(path.join(outDir, "sitemap.xml"), sitemap(orderedPages), "utf8");
81+
fs.writeFileSync(path.join(outDir, "sitemap.xml"), sitemap(canonicalPages), "utf8");
9382
fs.writeFileSync(path.join(outDir, "llms.txt"), llmsTxt(), "utf8");
9483
console.log(`built docs site: ${path.relative(root, outDir)} (${pages.length} pages)`);
9584

@@ -120,11 +109,22 @@ function llmsTxt() {
120109
}
121110

122111
function docsLlmsPages() {
123-
const seen = new Set();
124-
const ordered = typeof orderedPages !== "undefined" ? orderedPages : [];
125-
return [...ordered, ...pages].filter(
126-
(page) => page.outRel && !seen.has(page.outRel) && seen.add(page.outRel),
112+
return canonicalPages;
113+
}
114+
115+
function lifecycleFor(rel) {
116+
const canonical = siteManifest.sections.some((section) => section.pages.includes(rel));
117+
const matches = siteManifest.noncanonical.filter(
118+
(entry) => entry.path === rel || (entry.prefix && rel.startsWith(entry.prefix)),
127119
);
120+
if (canonical && matches.length)
121+
throw new Error(`documentation page has conflicting lifecycle: ${rel}`);
122+
if (canonical) return { canonical: true, name: "active" };
123+
if (matches.length === 1)
124+
return { canonical: false, name: matches[0].lifecycle, banner: matches[0].banner };
125+
if (matches.length > 1)
126+
throw new Error(`documentation page has multiple lifecycle matches: ${rel}`);
127+
throw new Error(`documentation page is not classified in config/documentation-site.json: ${rel}`);
128128
}
129129

130130
function docsOrigin() {
@@ -409,6 +409,7 @@ function layout({ page, html, toc, prev, next, sectionName }) {
409409
<meta name="viewport" content="width=device-width, initial-scale=1">
410410
<title>${escapeHtml(page.title)}${isHome ? " - Conservative maintenance bot" : " - ClawSweeper Docs"}</title>
411411
<meta name="description" content="${escapeAttr(description)}">
412+
${page.lifecycle.canonical ? "" : '<meta name="robots" content="noindex, follow">'}
412413
<meta name="theme-color" content="#f4ead7">
413414
<meta property="og:title" content="${escapeAttr(page.title)}${isHome ? " - ClawSweeper" : " - ClawSweeper docs"}">
414415
<meta property="og:description" content="${escapeAttr(description)}">
@@ -483,7 +484,11 @@ function standardHero(page, sectionName, editUrl) {
483484
<a class="repo" href="${repoUrl}" rel="noopener">GitHub</a>
484485
<a class="edit" href="${escapeAttr(editUrl)}" rel="noopener">Edit page</a>
485486
</div>
486-
</header>`;
487+
</header>${
488+
page.lifecycle.canonical
489+
? ""
490+
: `<aside class="lifecycle-banner" role="note"><strong>${escapeHtml(page.lifecycle.name)}</strong>: ${escapeHtml(page.lifecycle.banner)}</aside>`
491+
}`;
487492
}
488493

489494
function landingHero(rootPrefix) {

‎scripts/check-docs.mjs‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,116 @@ export function checkDocumentation(root = process.cwd()) {
9494
}
9595

9696
checkConfiguredClaims({ root, inventory, findings });
97+
checkDocumentationSiteManifest({ root, inventory, findings });
98+
checkOperationalHealthDocumentation({ root, findings });
9799
return findings.sort(compareFindings);
98100
}
99101

102+
function checkDocumentationSiteManifest({ root, inventory, findings }) {
103+
const manifestPath = "config/documentation-site.json";
104+
const manifest = readJson(path.join(root, manifestPath));
105+
const canonical = new Set();
106+
for (const section of manifest.sections ?? []) {
107+
for (const page of section.pages ?? []) {
108+
if (canonical.has(page)) {
109+
addFinding(
110+
findings,
111+
manifestPath,
112+
1,
113+
"docs-lifecycle",
114+
`duplicates canonical page ${page}`,
115+
);
116+
}
117+
canonical.add(page);
118+
if (!inventory.exact.has(`docs/${page}`)) {
119+
addFinding(
120+
findings,
121+
manifestPath,
122+
1,
123+
"docs-lifecycle",
124+
`references missing page docs/${page}`,
125+
);
126+
}
127+
}
128+
}
129+
130+
const docsPages = [...inventory.exact]
131+
.filter((file) => file.startsWith("docs/") && file.endsWith(".md"))
132+
.map((file) => file.slice("docs/".length));
133+
for (const page of docsPages) {
134+
const matches = (manifest.noncanonical ?? []).filter(
135+
(entry) => entry.path === page || (entry.prefix && page.startsWith(entry.prefix)),
136+
);
137+
const classifications = Number(canonical.has(page)) + matches.length;
138+
if (classifications !== 1) {
139+
addFinding(
140+
findings,
141+
manifestPath,
142+
1,
143+
"docs-lifecycle",
144+
`${page} has ${classifications === 0 ? "no" : "multiple"} lifecycle classifications`,
145+
);
146+
}
147+
}
148+
}
149+
150+
function checkOperationalHealthDocumentation({ root, findings }) {
151+
const sourcePath = "dashboard/operational-health.ts";
152+
const documentPath = "docs/live-dashboard.md";
153+
const source = fs.readFileSync(path.join(root, sourcePath), "utf8");
154+
const document = normalizeWhitespace(fs.readFileSync(path.join(root, documentPath), "utf8"));
155+
const minutes = (name) => {
156+
const expression = source.match(new RegExp(`export const ${name} = ([0-9 *]+);`))?.[1];
157+
if (!expression) return null;
158+
return (
159+
expression
160+
.split("*")
161+
.map(Number)
162+
.reduce((total, value) => total * value, 1) / 60_000
163+
);
164+
};
165+
const documentedFields = [
166+
"zombie_queued_runs",
167+
"oldest_zombie_queued_minutes",
168+
"approval_gated_runs",
169+
"oldest_approval_gated_minutes",
170+
];
171+
const operationalHealthType = source.match(
172+
/export type OperationalHealth = \{([\s\S]*?)\n\};/,
173+
)?.[1];
174+
for (const field of documentedFields) {
175+
if (
176+
!operationalHealthType ||
177+
!new RegExp(`^\\s*${field}\\s*:`, "m").test(operationalHealthType)
178+
) {
179+
addFinding(
180+
findings,
181+
sourcePath,
182+
1,
183+
"operational-health-source",
184+
`documented field is missing from OperationalHealth: ${field}`,
185+
);
186+
}
187+
}
188+
const expected = [
189+
`queued runs from ${minutes("OPERATIONAL_QUEUE_DEGRADED_MS")} through ${minutes("OPERATIONAL_QUEUE_ZOMBIE_MS")} minutes old degrade operational health`,
190+
`queued runs older than ${minutes("OPERATIONAL_QUEUE_ZOMBIE_MS")} minutes are reported separately as zombies`,
191+
`in-progress runs become stalled after ${minutes("OPERATIONAL_RUNNING_STALLED_MS")} minutes`,
192+
...documentedFields,
193+
];
194+
for (const claim of expected) {
195+
if (!document.includes(claim)) {
196+
addFinding(
197+
findings,
198+
documentPath,
199+
1,
200+
"operational-health-claim",
201+
`missing source-derived claim: ${claim}`,
202+
);
203+
}
204+
}
205+
}
206+
100207
function buildInventory(root) {
101208
const exact = new Set();
102209
const lower = new Map();

0 commit comments

Comments
 (0)