MCPcopy Create free account
hub / github.com/base/base / find_problems

Function find_problems

etc/scripts/local/docs-index.py:301–331  ·  view source on GitHub ↗

Return every reason the index does not match the docs on disk.

(entries: list[Entry], docs: dict[str, str])

Source from the content-addressed store, hash-verified

299
300
301def find_problems(entries: list[Entry], docs: dict[str, str]) -> list[str]:
302 """Return every reason the index does not match the docs on disk."""
303 problems = []
304 paths = [entry.path for entry in entries]
305 seen: set[str] = set()
306 for path in paths:
307 if path in seen:
308 problems.append(f"{path}: listed more than once")
309 seen.add(path)
310 if paths != sorted(paths):
311 problems.append("entries are not sorted by path (run `sync` to reorder)")
312
313 for entry in entries:
314 if entry.path not in docs:
315 problems.append(f"{entry.path}: indexed but no such doc exists (run `sync`)")
316 if entry.summary.startswith(PLACEHOLDER):
317 problems.append(f"{entry.path}: summary is still a placeholder")
318 elif len(entry.summary) > MAX_SUMMARY_LEN:
319 problems.append(
320 f"{entry.path}: summary is {len(entry.summary)} characters (max {MAX_SUMMARY_LEN})"
321 )
322 elif entry.path in docs and entry.digest != docs[entry.path]:
323 problems.append(
324 f"{entry.path}: doc changed since its summary was reviewed; "
325 f"update the summary if needed, then run `stamp {entry.path}`"
326 )
327 problems.extend(
328 f"{path}: not in the manifest (run `sync`, then write a summary)"
329 for path in sorted(docs.keys() - seen)
330 )
331 return problems
332
333
334def sync_entries(entries: list[Entry], docs: dict[str, str]) -> list[Entry]:

Calls 4

appendMethod · 0.80
addMethod · 0.45
extendMethod · 0.45
keysMethod · 0.45