docstate 0.2.4__tar.gz → 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. {docstate-0.2.4 → docstate-0.2.5}/CHANGELOG.md +6 -0
  2. {docstate-0.2.4/src/docstate.egg-info → docstate-0.2.5}/PKG-INFO +12 -6
  3. {docstate-0.2.4 → docstate-0.2.5}/README.md +11 -5
  4. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/__init__.py +1 -1
  5. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/check.py +73 -49
  6. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/config.py +50 -10
  7. {docstate-0.2.4 → docstate-0.2.5/src/docstate.egg-info}/PKG-INFO +12 -6
  8. {docstate-0.2.4 → docstate-0.2.5}/tests/test_config.py +13 -0
  9. {docstate-0.2.4 → docstate-0.2.5}/tests/test_frontmatter.py +23 -4
  10. {docstate-0.2.4 → docstate-0.2.5}/LICENSE +0 -0
  11. {docstate-0.2.4 → docstate-0.2.5}/MANIFEST.in +0 -0
  12. {docstate-0.2.4 → docstate-0.2.5}/examples/basic/README.md +0 -0
  13. {docstate-0.2.4 → docstate-0.2.5}/examples/basic/docs/guide.md +0 -0
  14. {docstate-0.2.4 → docstate-0.2.5}/examples/basic/docs/status.md +0 -0
  15. {docstate-0.2.4 → docstate-0.2.5}/examples/basic/docstate.toml +0 -0
  16. {docstate-0.2.4 → docstate-0.2.5}/examples/basic/facts/status.json +0 -0
  17. {docstate-0.2.4 → docstate-0.2.5}/examples/basic/templates/status.md +0 -0
  18. {docstate-0.2.4 → docstate-0.2.5}/examples/table/README.md +0 -0
  19. {docstate-0.2.4 → docstate-0.2.5}/examples/table/docs/judgments.md +0 -0
  20. {docstate-0.2.4 → docstate-0.2.5}/examples/table/docstate.toml +0 -0
  21. {docstate-0.2.4 → docstate-0.2.5}/examples/table/facts/judgments.json +0 -0
  22. {docstate-0.2.4 → docstate-0.2.5}/examples/table/templates/judgments.md +0 -0
  23. {docstate-0.2.4 → docstate-0.2.5}/pyproject.toml +0 -0
  24. {docstate-0.2.4 → docstate-0.2.5}/setup.cfg +0 -0
  25. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/__main__.py +0 -0
  26. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/cli.py +0 -0
  27. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/errors.py +0 -0
  28. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/facts.py +0 -0
  29. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/frontmatter.py +0 -0
  30. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/render.py +0 -0
  31. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/scan.py +0 -0
  32. {docstate-0.2.4 → docstate-0.2.5}/src/docstate/template.py +0 -0
  33. {docstate-0.2.4 → docstate-0.2.5}/src/docstate.egg-info/SOURCES.txt +0 -0
  34. {docstate-0.2.4 → docstate-0.2.5}/src/docstate.egg-info/dependency_links.txt +0 -0
  35. {docstate-0.2.4 → docstate-0.2.5}/src/docstate.egg-info/entry_points.txt +0 -0
  36. {docstate-0.2.4 → docstate-0.2.5}/src/docstate.egg-info/requires.txt +0 -0
  37. {docstate-0.2.4 → docstate-0.2.5}/src/docstate.egg-info/top_level.txt +0 -0
  38. {docstate-0.2.4 → docstate-0.2.5}/templates/docstate.schema.json +0 -0
  39. {docstate-0.2.4 → docstate-0.2.5}/templates/docstate.toml +0 -0
  40. {docstate-0.2.4 → docstate-0.2.5}/templates/pre-commit.yaml +0 -0
  41. {docstate-0.2.4 → docstate-0.2.5}/templates/status.md +0 -0
  42. {docstate-0.2.4 → docstate-0.2.5}/templates/vale.ini +0 -0
  43. {docstate-0.2.4 → docstate-0.2.5}/tests/conftest.py +0 -0
  44. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/bad-json/docs/status.md +0 -0
  45. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/bad-json/docstate.toml +0 -0
  46. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/bad-json/facts/status.json +0 -0
  47. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/bad-json/templates/status.md +0 -0
  48. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/bad-markers/docs/other.md +0 -0
  49. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/bad-markers/docs/status.md +0 -0
  50. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/bad-markers/docstate.toml +0 -0
  51. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/bad-markers/facts/status.json +0 -0
  52. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/bad-markers/templates/status.md +0 -0
  53. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/basic/README.md +0 -0
  54. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/basic/docs/guide.md +0 -0
  55. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/basic/docs/status.md +0 -0
  56. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/basic/docstate.toml +0 -0
  57. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/basic/facts/status.json +0 -0
  58. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/basic/templates/status.md +0 -0
  59. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/frontmatter/CHANGELOG.md +0 -0
  60. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/frontmatter/docs/README.md +0 -0
  61. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/frontmatter/docs/bad.md +0 -0
  62. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/frontmatter/docs/design.md +0 -0
  63. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/frontmatter/docstate.toml +0 -0
  64. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/frontmatter/facts/status.json +0 -0
  65. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/frontmatter/templates/summary.md +0 -0
  66. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/table/docs/status.md +0 -0
  67. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/table/docstate.toml +0 -0
  68. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/table/facts/judgments.json +0 -0
  69. {docstate-0.2.4 → docstate-0.2.5}/tests/fixtures/table/templates/judgments.md +0 -0
  70. {docstate-0.2.4 → docstate-0.2.5}/tests/test_anchors.py +0 -0
  71. {docstate-0.2.4 → docstate-0.2.5}/tests/test_check.py +0 -0
  72. {docstate-0.2.4 → docstate-0.2.5}/tests/test_cli.py +0 -0
  73. {docstate-0.2.4 → docstate-0.2.5}/tests/test_examples.py +0 -0
  74. {docstate-0.2.4 → docstate-0.2.5}/tests/test_render.py +0 -0
  75. {docstate-0.2.4 → docstate-0.2.5}/tests/test_scan.py +0 -0
  76. {docstate-0.2.4 → docstate-0.2.5}/tests/test_template.py +0 -0
  77. {docstate-0.2.4 → docstate-0.2.5}/tests/test_template_v2.py +0 -0
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.5 - 2026-12-06
4
+
5
+ - Add `docs` to `[[check.freshness]]`: one rule can cover many documents. The `changelog` path is resolved relative to each document's directory, and a missing changelog is a finding.
6
+ - `doc` and `docs` are mutually exclusive; `exclude` is allowed with `docs`.
7
+ - Used by the vault's third parallel cell: `check-status-lag.mjs` and the docstate freshness rule must report the same stale / missing-changelog document sets.
8
+
3
9
  ## 0.2.4 - 2026-12-06
4
10
 
5
11
  - Add `exclude` to `[check.frontmatter]`. Matched files are removed before any frontmatter check, the same way `[[check.forbidden]].exclude` works.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstate
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Generate Markdown blocks from JSON facts and fail when the document drifts
5
5
  Author: The docstate authors
6
6
  License-Expression: MIT
@@ -56,14 +56,14 @@ pipx install docstate
56
56
  Pin a version:
57
57
 
58
58
  ```sh
59
- pipx install docstate==0.2.4
59
+ pipx install docstate==0.2.5
60
60
  ```
61
61
 
62
62
  Or install from the GitHub tag / release:
63
63
 
64
64
  ```sh
65
- pipx install "git+https://github.com/XinBuilds/docstate.git@v0.2.4"
66
- pip install https://github.com/XinBuilds/docstate/releases/download/v0.2.4/docstate-0.2.4-py3-none-any.whl
65
+ pipx install "git+https://github.com/XinBuilds/docstate.git@v0.2.5"
66
+ pip install https://github.com/XinBuilds/docstate/releases/download/v0.2.5/docstate-0.2.5-py3-none-any.whl
67
67
  ```
68
68
 
69
69
  Or install from a checkout:
@@ -123,7 +123,7 @@ content here is replaced by render
123
123
  To make drift fail in CI, add two steps:
124
124
 
125
125
  ```yaml
126
- - run: pipx install docstate==0.2.4
126
+ - run: pipx install docstate==0.2.5
127
127
  - run: docstate check --config docstate.toml --strict
128
128
  ```
129
129
 
@@ -241,6 +241,12 @@ applies_to = ["docs/**/*.md"]
241
241
  doc = "docs/README.md"
242
242
  field = "last_reviewed"
243
243
  changelog = "docs/CHANGELOG.md"
244
+
245
+ [[check.freshness]]
246
+ docs = ["projects/*/README.md"]
247
+ exclude = ["projects/legacy/**"]
248
+ field = "last_reviewed"
249
+ changelog = "development/CHANGELOG.md"
244
250
  ```
245
251
 
246
252
  Rules:
@@ -250,7 +256,7 @@ Rules:
250
256
  - `bom` reports a UTF-8 BOM; `warn` is the default, `ignore` disables it.
251
257
  - An owner declares the authoritative value of a field (for example `project_stage`). Other matched documents may omit the field, but if they set it, the value must match the owner.
252
258
  - `status_review` uses git. If the working tree changed a file, it compares the file with `HEAD`; otherwise it compares `HEAD` with `HEAD~1`. If the body changed but both the status field and `updated` stayed the same, it reports `status` (warning by default). If the status changed but `updated` did not, it reports an error.
253
- - `[[check.freshness]]` reports when a date field is older than the newest dated heading in a changelog, or when the field is missing or malformed.
259
+ - `[[check.freshness]]` reports when a date field is older than the newest dated heading in a changelog, or when the field is missing, malformed, or has no changelog. With `docs`, `changelog` is resolved relative to each document's directory and `exclude` filters the matched documents.
254
260
  - `status_review = "off"` avoids git entirely. When enabled, the directory must be a git repository; untracked files are skipped.
255
261
 
256
262
  This is a discipline check, not a semantic verdict. It cannot decide that `status: draft` should have become `decided`; it can only prove the field was not reviewed, is outside the vocabulary, or disagrees with its owner. The status check looks at the working tree or the latest commit, not the whole history.
@@ -27,14 +27,14 @@ pipx install docstate
27
27
  Pin a version:
28
28
 
29
29
  ```sh
30
- pipx install docstate==0.2.4
30
+ pipx install docstate==0.2.5
31
31
  ```
32
32
 
33
33
  Or install from the GitHub tag / release:
34
34
 
35
35
  ```sh
36
- pipx install "git+https://github.com/XinBuilds/docstate.git@v0.2.4"
37
- pip install https://github.com/XinBuilds/docstate/releases/download/v0.2.4/docstate-0.2.4-py3-none-any.whl
36
+ pipx install "git+https://github.com/XinBuilds/docstate.git@v0.2.5"
37
+ pip install https://github.com/XinBuilds/docstate/releases/download/v0.2.5/docstate-0.2.5-py3-none-any.whl
38
38
  ```
39
39
 
40
40
  Or install from a checkout:
@@ -94,7 +94,7 @@ content here is replaced by render
94
94
  To make drift fail in CI, add two steps:
95
95
 
96
96
  ```yaml
97
- - run: pipx install docstate==0.2.4
97
+ - run: pipx install docstate==0.2.5
98
98
  - run: docstate check --config docstate.toml --strict
99
99
  ```
100
100
 
@@ -212,6 +212,12 @@ applies_to = ["docs/**/*.md"]
212
212
  doc = "docs/README.md"
213
213
  field = "last_reviewed"
214
214
  changelog = "docs/CHANGELOG.md"
215
+
216
+ [[check.freshness]]
217
+ docs = ["projects/*/README.md"]
218
+ exclude = ["projects/legacy/**"]
219
+ field = "last_reviewed"
220
+ changelog = "development/CHANGELOG.md"
215
221
  ```
216
222
 
217
223
  Rules:
@@ -221,7 +227,7 @@ Rules:
221
227
  - `bom` reports a UTF-8 BOM; `warn` is the default, `ignore` disables it.
222
228
  - An owner declares the authoritative value of a field (for example `project_stage`). Other matched documents may omit the field, but if they set it, the value must match the owner.
223
229
  - `status_review` uses git. If the working tree changed a file, it compares the file with `HEAD`; otherwise it compares `HEAD` with `HEAD~1`. If the body changed but both the status field and `updated` stayed the same, it reports `status` (warning by default). If the status changed but `updated` did not, it reports an error.
224
- - `[[check.freshness]]` reports when a date field is older than the newest dated heading in a changelog, or when the field is missing or malformed.
230
+ - `[[check.freshness]]` reports when a date field is older than the newest dated heading in a changelog, or when the field is missing, malformed, or has no changelog. With `docs`, `changelog` is resolved relative to each document's directory and `exclude` filters the matched documents.
225
231
  - `status_review = "off"` avoids git entirely. When enabled, the directory must be a git repository; untracked files are skipped.
226
232
 
227
233
  This is a discipline check, not a semantic verdict. It cannot decide that `status: draft` should have become `decided`; it can only prove the field was not reviewed, is outside the vocabulary, or disagrees with its owner. The status check looks at the working tree or the latest commit, not the whole history.
@@ -1,4 +1,4 @@
1
1
  """docstate: keep Markdown status blocks in sync with JSON facts."""
2
2
 
3
- __version__ = "0.2.4"
3
+ __version__ = "0.2.5"
4
4
 
@@ -333,58 +333,82 @@ def _status_findings(rule: FrontmatterRule, base: Path) -> list[Finding]:
333
333
  return findings
334
334
 
335
335
 
336
- def _freshness_findings(rule: FreshnessRule) -> list[Finding]:
337
- frontmatter = _read_frontmatter(rule.doc, rule.doc_rel)
338
- value = frontmatter.value(rule.field)
339
- if value is None:
340
- return [
341
- Finding(
342
- kind="freshness",
343
- path=rule.doc_rel,
344
- line=1,
345
- field=rule.field,
346
- message=f"missing field: {rule.field}",
336
+ def _freshness_findings(rule: FreshnessRule, base: Path) -> list[Finding]:
337
+ findings: list[Finding] = []
338
+ targets = [rule.doc] if rule.doc is not None else list(rule.docs)
339
+ for doc in targets:
340
+ doc_rel = doc.relative_to(base).as_posix()
341
+ if rule.doc is not None:
342
+ changelog = rule.changelog
343
+ changelog_rel = rule.changelog_rel
344
+ else:
345
+ changelog = doc.parent / rule.changelog_template
346
+ changelog_rel = changelog.relative_to(base).as_posix()
347
+ frontmatter = _read_frontmatter(doc, doc_rel)
348
+ value = frontmatter.value(rule.field)
349
+ if value is None:
350
+ findings.append(
351
+ Finding(
352
+ kind="freshness",
353
+ path=doc_rel,
354
+ line=1,
355
+ field=rule.field,
356
+ message=f"missing field: {rule.field}",
357
+ )
347
358
  )
348
- ]
349
- if not DATE_RE.match(value):
350
- return [
351
- Finding(
352
- kind="freshness",
353
- path=rule.doc_rel,
354
- line=frontmatter.line(rule.field),
355
- field=rule.field,
356
- message=f"date must be YYYY-MM-DD: {value!r}",
359
+ continue
360
+ if not DATE_RE.match(value):
361
+ findings.append(
362
+ Finding(
363
+ kind="freshness",
364
+ path=doc_rel,
365
+ line=frontmatter.line(rule.field),
366
+ field=rule.field,
367
+ message=f"date must be YYYY-MM-DD: {value!r}",
368
+ )
357
369
  )
358
- ]
359
- try:
360
- text = rule.changelog.read_text(encoding="utf-8-sig")
361
- except OSError as exc:
362
- fail("FILE_READ", f"cannot read changelog: {exc}", path=rule.changelog_rel)
363
- except UnicodeDecodeError as exc:
364
- fail("FILE_ENCODING", f"changelog is not UTF-8: {exc}", path=rule.changelog_rel)
365
- dates = CHANGELOG_DATE_RE.findall(text)
366
- if not dates:
367
- return [
368
- Finding(
369
- kind="freshness",
370
- path=rule.changelog_rel,
371
- line=1,
372
- field=rule.field,
373
- message="no dated heading found in changelog",
370
+ continue
371
+ try:
372
+ text = changelog.read_text(encoding="utf-8-sig")
373
+ except FileNotFoundError:
374
+ findings.append(
375
+ Finding(
376
+ kind="freshness",
377
+ path=doc_rel,
378
+ line=frontmatter.line(rule.field),
379
+ field=rule.field,
380
+ message=f"changelog not found: {changelog_rel}",
381
+ )
374
382
  )
375
- ]
376
- newest = max(dates)
377
- if value < newest:
378
- return [
379
- Finding(
380
- kind="freshness",
381
- path=rule.doc_rel,
382
- line=frontmatter.line(rule.field),
383
- field=rule.field,
384
- message=f"{value} is older than changelog {newest}",
383
+ continue
384
+ except OSError as exc:
385
+ fail("FILE_READ", f"cannot read changelog: {exc}", path=changelog_rel)
386
+ except UnicodeDecodeError as exc:
387
+ fail("FILE_ENCODING", f"changelog is not UTF-8: {exc}", path=changelog_rel)
388
+ dates = CHANGELOG_DATE_RE.findall(text)
389
+ if not dates:
390
+ findings.append(
391
+ Finding(
392
+ kind="freshness",
393
+ path=changelog_rel,
394
+ line=1,
395
+ field=rule.field,
396
+ message="no dated heading found in changelog",
397
+ )
385
398
  )
386
- ]
387
- return []
399
+ continue
400
+ newest = max(dates)
401
+ if value < newest:
402
+ findings.append(
403
+ Finding(
404
+ kind="freshness",
405
+ path=doc_rel,
406
+ line=frontmatter.line(rule.field),
407
+ field=rule.field,
408
+ message=f"{value} is older than changelog {newest}",
409
+ )
410
+ )
411
+ return findings
388
412
 
389
413
 
390
414
  def _anchor_findings(rule: AnchorRule, base: Path) -> list[Finding]:
@@ -499,7 +523,7 @@ def check_project(config: Config) -> tuple[list[Finding], int, int]:
499
523
  findings.extend(_frontmatter_findings(config.frontmatter, config.base))
500
524
  findings.extend(_status_findings(config.frontmatter, config.base))
501
525
  for rule in config.freshness:
502
- findings.extend(_freshness_findings(rule))
526
+ findings.extend(_freshness_findings(rule, config.base))
503
527
  for rule in config.anchors:
504
528
  findings.extend(_anchor_findings(rule, config.base))
505
529
  for rule in config.forbidden:
@@ -51,11 +51,13 @@ class FrontmatterRule:
51
51
 
52
52
  @dataclass(frozen=True)
53
53
  class FreshnessRule:
54
- doc: Path
54
+ doc: Path | None
55
55
  doc_rel: str
56
56
  field: str
57
- changelog: Path
57
+ changelog: Path | None
58
58
  changelog_rel: str
59
+ docs: tuple[Path, ...] = ()
60
+ changelog_template: str = ""
59
61
 
60
62
 
61
63
  @dataclass(frozen=True)
@@ -313,19 +315,57 @@ def _parse_freshness_rules(base: Path, raw: object) -> list[FreshnessRule]:
313
315
  for index, item in enumerate(raw):
314
316
  if not isinstance(item, dict):
315
317
  fail("CFG_SCHEMA", f"check.freshness[{index}] must be a table")
316
- _reject_unknown(item, {"doc", "field", "changelog"}, f"check.freshness[{index}]")
317
- doc = _resolve_file(base, item.get("doc"), suffix=".md", where=f"check.freshness[{index}].doc")
318
- changelog = _resolve_file(
319
- base, item.get("changelog"), suffix=".md", where=f"check.freshness[{index}].changelog"
318
+ _reject_unknown(
319
+ item, {"doc", "docs", "exclude", "field", "changelog"}, f"check.freshness[{index}]"
320
320
  )
321
321
  field_name = _validate_field(item.get("field"), f"check.freshness[{index}].field")
322
+ has_doc = item.get("doc") is not None
323
+ has_docs = item.get("docs") is not None
324
+ if has_doc == has_docs:
325
+ fail("CFG_SCHEMA", f"check.freshness[{index}] needs exactly one of doc or docs")
326
+ if has_doc:
327
+ if item.get("exclude") is not None:
328
+ fail("CFG_SCHEMA", f"check.freshness[{index}].exclude requires docs")
329
+ doc = _resolve_file(base, item.get("doc"), suffix=".md", where=f"check.freshness[{index}].doc")
330
+ changelog = _resolve_file(
331
+ base, item.get("changelog"), suffix=".md", where=f"check.freshness[{index}].changelog"
332
+ )
333
+ rules.append(
334
+ FreshnessRule(
335
+ doc=doc,
336
+ doc_rel=_relative(base, doc),
337
+ field=field_name,
338
+ changelog=changelog,
339
+ changelog_rel=_relative(base, changelog),
340
+ )
341
+ )
342
+ continue
343
+ patterns = _list_of_strings(item.get("docs"), f"check.freshness[{index}].docs")
344
+ if not patterns:
345
+ fail("CFG_SCHEMA", f"check.freshness[{index}].docs must not be empty")
346
+ exclude = _list_of_strings(item.get("exclude"), f"check.freshness[{index}].exclude")
347
+ for value in exclude:
348
+ _check_pattern(value, f"check.freshness[{index}].exclude")
349
+ template = item.get("changelog")
350
+ if not isinstance(template, str) or not template:
351
+ fail("CFG_SCHEMA", f"check.freshness[{index}].changelog must be a non-empty string")
352
+ pure = PurePosixPath(template)
353
+ if pure.is_absolute() or ".." in pure.parts:
354
+ fail(
355
+ "CFG_PATH",
356
+ f"check.freshness[{index}].changelog must be relative and must not contain '..': {template}",
357
+ )
358
+ if pure.suffix != ".md":
359
+ fail("CFG_SCHEMA", f"check.freshness[{index}].changelog must end with .md: {template}")
322
360
  rules.append(
323
361
  FreshnessRule(
324
- doc=doc,
325
- doc_rel=_relative(base, doc),
362
+ doc=None,
363
+ doc_rel="",
326
364
  field=field_name,
327
- changelog=changelog,
328
- changelog_rel=_relative(base, changelog),
365
+ changelog=None,
366
+ changelog_rel="",
367
+ docs=tuple(_expand_check_files(base, patterns, [], exclude)),
368
+ changelog_template=template,
329
369
  )
330
370
  )
331
371
  return rules
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docstate
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Generate Markdown blocks from JSON facts and fail when the document drifts
5
5
  Author: The docstate authors
6
6
  License-Expression: MIT
@@ -56,14 +56,14 @@ pipx install docstate
56
56
  Pin a version:
57
57
 
58
58
  ```sh
59
- pipx install docstate==0.2.4
59
+ pipx install docstate==0.2.5
60
60
  ```
61
61
 
62
62
  Or install from the GitHub tag / release:
63
63
 
64
64
  ```sh
65
- pipx install "git+https://github.com/XinBuilds/docstate.git@v0.2.4"
66
- pip install https://github.com/XinBuilds/docstate/releases/download/v0.2.4/docstate-0.2.4-py3-none-any.whl
65
+ pipx install "git+https://github.com/XinBuilds/docstate.git@v0.2.5"
66
+ pip install https://github.com/XinBuilds/docstate/releases/download/v0.2.5/docstate-0.2.5-py3-none-any.whl
67
67
  ```
68
68
 
69
69
  Or install from a checkout:
@@ -123,7 +123,7 @@ content here is replaced by render
123
123
  To make drift fail in CI, add two steps:
124
124
 
125
125
  ```yaml
126
- - run: pipx install docstate==0.2.4
126
+ - run: pipx install docstate==0.2.5
127
127
  - run: docstate check --config docstate.toml --strict
128
128
  ```
129
129
 
@@ -241,6 +241,12 @@ applies_to = ["docs/**/*.md"]
241
241
  doc = "docs/README.md"
242
242
  field = "last_reviewed"
243
243
  changelog = "docs/CHANGELOG.md"
244
+
245
+ [[check.freshness]]
246
+ docs = ["projects/*/README.md"]
247
+ exclude = ["projects/legacy/**"]
248
+ field = "last_reviewed"
249
+ changelog = "development/CHANGELOG.md"
244
250
  ```
245
251
 
246
252
  Rules:
@@ -250,7 +256,7 @@ Rules:
250
256
  - `bom` reports a UTF-8 BOM; `warn` is the default, `ignore` disables it.
251
257
  - An owner declares the authoritative value of a field (for example `project_stage`). Other matched documents may omit the field, but if they set it, the value must match the owner.
252
258
  - `status_review` uses git. If the working tree changed a file, it compares the file with `HEAD`; otherwise it compares `HEAD` with `HEAD~1`. If the body changed but both the status field and `updated` stayed the same, it reports `status` (warning by default). If the status changed but `updated` did not, it reports an error.
253
- - `[[check.freshness]]` reports when a date field is older than the newest dated heading in a changelog, or when the field is missing or malformed.
259
+ - `[[check.freshness]]` reports when a date field is older than the newest dated heading in a changelog, or when the field is missing, malformed, or has no changelog. With `docs`, `changelog` is resolved relative to each document's directory and `exclude` filters the matched documents.
254
260
  - `status_review = "off"` avoids git entirely. When enabled, the directory must be a git repository; untracked files are skipped.
255
261
 
256
262
  This is a discipline check, not a semantic verdict. It cannot decide that `status: draft` should have become `decided`; it can only prove the field was not reviewed, is outside the vocabulary, or disagrees with its owner. The status check looks at the working tree or the latest commit, not the whole history.
@@ -115,3 +115,16 @@ def test_frontmatter_exclude_rejects_parent_paths(tmp_path):
115
115
  with pytest.raises(DocstateError) as error:
116
116
  load_config(config_path)
117
117
  assert error.value.code == "CFG_PATH"
118
+
119
+
120
+ def test_freshness_requires_exactly_one_of_doc_or_docs(tmp_path):
121
+ (tmp_path / "README.md").write_text("---\nlast_reviewed: 2026-12-06\n---\n", encoding="utf-8")
122
+ config_path = tmp_path / "docstate.toml"
123
+ config_path.write_text(
124
+ 'version = 1\ndialect = "scalar-v1"\n\n[[check.freshness]]\n'
125
+ 'doc = "README.md"\ndocs = ["README.md"]\nfield = "last_reviewed"\nchangelog = "README.md"\n',
126
+ encoding="utf-8",
127
+ )
128
+ with pytest.raises(DocstateError) as error:
129
+ load_config(config_path)
130
+ assert error.value.code == "CFG_SCHEMA"
@@ -126,25 +126,44 @@ def test_freshness_stale_and_current(tmp_path):
126
126
  doc = write(tmp_path / "README.md", "---\nlast_reviewed: 2026-11-01\n---\n# doc\n")
127
127
  changelog = write(tmp_path / "CHANGELOG.md", "# Log\n\n## 2026-12-06 shipped\n\n## 2026-11-01 started\n")
128
128
  stale = FreshnessRule(doc=doc, doc_rel="README.md", field="last_reviewed", changelog=changelog, changelog_rel="CHANGELOG.md")
129
- findings = _freshness_findings(stale)
129
+ findings = _freshness_findings(stale, tmp_path)
130
130
  assert len(findings) == 1
131
131
  assert "older than changelog 2026-12-06" in findings[0].message
132
132
 
133
133
  write(doc, "---\nlast_reviewed: 2026-12-06\n---\n# doc\n")
134
- assert _freshness_findings(stale) == []
134
+ assert _freshness_findings(stale, tmp_path) == []
135
135
 
136
136
 
137
137
  def test_freshness_missing_and_invalid(tmp_path):
138
138
  changelog = write(tmp_path / "CHANGELOG.md", "## 2026-12-06 shipped\n")
139
139
  doc = write(tmp_path / "README.md", "# no frontmatter\n")
140
140
  missing = FreshnessRule(doc=doc, doc_rel="README.md", field="last_reviewed", changelog=changelog, changelog_rel="CHANGELOG.md")
141
- assert "missing field" in _freshness_findings(missing)[0].message
141
+ assert "missing field" in _freshness_findings(missing, tmp_path)[0].message
142
142
 
143
143
  write(doc, "---\nlast_reviewed: yesterday\n---\n# doc\n")
144
- invalid = _freshness_findings(missing)[0]
144
+ invalid = _freshness_findings(missing, tmp_path)[0]
145
145
  assert "YYYY-MM-DD" in invalid.message
146
146
 
147
147
 
148
+ def test_freshness_globs_use_sibling_changelog(tmp_path):
149
+ write(tmp_path / "a" / "README.md", "---\nlast_reviewed: 2026-11-01\n---\n")
150
+ write(tmp_path / "a" / "development" / "CHANGELOG.md", "## 2026-12-06 shipped\n")
151
+ write(tmp_path / "b" / "README.md", "---\nlast_reviewed: 2026-12-06\n---\n")
152
+ write(tmp_path / "b" / "development" / "CHANGELOG.md", "## 2026-12-01 shipped\n")
153
+ write(tmp_path / "c" / "README.md", "---\nlast_reviewed: 2026-12-06\n---\n")
154
+ config_path = write(
155
+ tmp_path / "docstate.toml",
156
+ 'version = 1\ndialect = "scalar-v1"\n\n[[check.freshness]]\n'
157
+ 'docs = ["*/README.md"]\nfield = "last_reviewed"\nchangelog = "development/CHANGELOG.md"\n',
158
+ )
159
+ config = load_config(config_path)
160
+ findings = _freshness_findings(config.freshness[0], tmp_path)
161
+ assert {(finding.path, finding.message.split(":")[0]) for finding in findings} == {
162
+ ("a/README.md", "2026-11-01 is older than changelog 2026-12-06"),
163
+ ("c/README.md", "changelog not found"),
164
+ }
165
+
166
+
148
167
  def test_config_runs_frontmatter_and_freshness(copy_fixture):
149
168
  root = copy_fixture("frontmatter")
150
169
  config = load_config(root / "docstate.toml")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes