tracecite-docs 0.0.1__py3-none-any.whl

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.
@@ -0,0 +1,240 @@
1
+ """Repository-neutral author and freshness-check documentation modes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import hashlib
6
+ import json
7
+ import os
8
+ import shutil
9
+ import subprocess
10
+ import tempfile
11
+ from dataclasses import dataclass, replace
12
+ from pathlib import Path
13
+
14
+ from .contract import DocsEvidenceContract
15
+ from .stage import stage_docs
16
+ from .vectorize import docs_index_freshness_diagnostics
17
+
18
+
19
+ @dataclass(frozen=True, slots=True)
20
+ class DocsModeResult:
21
+ mode: str
22
+ ok: bool
23
+ manifest_path: Path
24
+ diagnostics: tuple[str, ...] = ()
25
+
26
+
27
+ def _sha(path: Path) -> str:
28
+ return hashlib.sha256(path.read_bytes()).hexdigest()
29
+
30
+
31
+ def _repo_files(
32
+ root: Path, repo_root: Path, *, exclude: Path | None = None
33
+ ) -> dict[str, str]:
34
+ if not root.exists():
35
+ return {}
36
+ return {
37
+ path.relative_to(repo_root).as_posix(): _sha(path)
38
+ for path in sorted(root.rglob("*"))
39
+ if path.is_file() and path != exclude
40
+ }
41
+
42
+
43
+ def _staged_files(source: Path, destination: Path, repo_root: Path) -> dict[str, str]:
44
+ if not source.exists():
45
+ return {}
46
+ return {
47
+ (destination / path.relative_to(source))
48
+ .relative_to(repo_root)
49
+ .as_posix(): _sha(path)
50
+ for path in sorted(source.rglob("*"))
51
+ if path.is_file()
52
+ }
53
+
54
+
55
+ def _manifest(
56
+ contract: DocsEvidenceContract,
57
+ config_path: Path,
58
+ repo_root: Path,
59
+ public_root: Path,
60
+ ) -> dict[str, object]:
61
+ manifest_path = contract.retained_root / ".tracecite-manifest.json"
62
+ return {
63
+ "schema_version": 1,
64
+ "contract_sha256": _sha(config_path),
65
+ "retained": _repo_files(
66
+ contract.retained_root, repo_root, exclude=manifest_path
67
+ ),
68
+ "public": _staged_files(
69
+ public_root, contract.staged_root / "public", repo_root
70
+ ),
71
+ }
72
+
73
+
74
+ def _dump(data: dict[str, object], path: Path) -> None:
75
+ path.write_text(
76
+ json.dumps(data, ensure_ascii=False, sort_keys=True, indent=2) + "\n",
77
+ encoding="utf-8",
78
+ )
79
+
80
+
81
+ def author_docs(
82
+ contract: DocsEvidenceContract, *, config_path: str | Path, repo_root: str | Path
83
+ ) -> DocsModeResult:
84
+ root = Path(repo_root).resolve()
85
+ config = Path(config_path).resolve()
86
+ if contract.host_render_command is not None:
87
+ subprocess.run(list(contract.host_render_command), cwd=root, check=True)
88
+ parent = contract.staged_root.parent
89
+ parent.mkdir(parents=True, exist_ok=True)
90
+ temporary = Path(tempfile.mkdtemp(prefix=".tracecite-author-", dir=parent))
91
+ try:
92
+ staged_retained = temporary / "retained"
93
+ shutil.copytree(
94
+ contract.retained_root,
95
+ staged_retained,
96
+ ignore=shutil.ignore_patterns(".tracecite-manifest.json"),
97
+ )
98
+ staged = replace(contract, retained_root=staged_retained, staged_root=temporary)
99
+ canonical_retained = contract.retained_root
100
+ stage_docs(
101
+ staged,
102
+ target="local",
103
+ repo_root=root,
104
+ link_markdown_root=canonical_retained,
105
+ )
106
+ stage_docs(
107
+ staged,
108
+ target="public",
109
+ repo_root=root,
110
+ link_markdown_root=canonical_retained,
111
+ )
112
+ manifest = _manifest(contract, config, root, staged.staged_root / "public")
113
+ manifest_tmp = temporary / "manifest.json"
114
+ _dump(manifest, manifest_tmp)
115
+ targets = [
116
+ (contract.staged_root / "local", staged.staged_root / "local"),
117
+ (contract.staged_root / "public", staged.staged_root / "public"),
118
+ (contract.retained_root / ".tracecite-manifest.json", manifest_tmp),
119
+ ]
120
+ backups: list[tuple[Path, Path]] = []
121
+ promoted: list[Path] = []
122
+ try:
123
+ for destination, source in targets:
124
+ backup = destination.with_name(destination.name + ".tracecite-previous")
125
+ if backup.exists():
126
+ shutil.rmtree(backup) if backup.is_dir() else backup.unlink()
127
+ if destination.exists():
128
+ os.replace(destination, backup)
129
+ backups.append((destination, backup))
130
+ for destination, source in targets:
131
+ destination.parent.mkdir(parents=True, exist_ok=True)
132
+ os.replace(source, destination)
133
+ promoted.append(destination)
134
+ for _, backup in backups:
135
+ if backup.exists():
136
+ shutil.rmtree(backup) if backup.is_dir() else backup.unlink()
137
+ except Exception:
138
+ for destination in promoted:
139
+ if destination.exists():
140
+ shutil.rmtree(
141
+ destination
142
+ ) if destination.is_dir() else destination.unlink()
143
+ for destination, backup in reversed(backups):
144
+ if backup.exists():
145
+ os.replace(backup, destination)
146
+ raise
147
+ finally:
148
+ if temporary.exists():
149
+ shutil.rmtree(temporary)
150
+ return DocsModeResult(
151
+ "author", True, contract.retained_root / ".tracecite-manifest.json"
152
+ )
153
+
154
+
155
+ def check_docs(
156
+ contract: DocsEvidenceContract, *, config_path: str | Path, repo_root: str | Path
157
+ ) -> DocsModeResult:
158
+ root = Path(repo_root).resolve()
159
+ manifest_path = contract.retained_root / ".tracecite-manifest.json"
160
+ diagnostics: list[str] = []
161
+ try:
162
+ manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
163
+ if not isinstance(manifest, dict) or manifest.get("schema_version") != 1:
164
+ raise ValueError("invalid schema")
165
+ except (OSError, UnicodeError, ValueError, json.JSONDecodeError) as exc:
166
+ return DocsModeResult(
167
+ "check", False, manifest_path, (f"invalid manifest: {exc}",)
168
+ )
169
+ if manifest.get("contract_sha256") != _sha(Path(config_path).resolve()):
170
+ diagnostics.append("contract hash mismatch")
171
+ try:
172
+ temporary = Path(
173
+ tempfile.mkdtemp(
174
+ prefix=".tracecite-check-", dir=contract.staged_root.parent
175
+ )
176
+ )
177
+ except OSError as exc:
178
+ return DocsModeResult(
179
+ "check", False, manifest_path, (f"temporary staging setup failed: {exc}",)
180
+ )
181
+ try:
182
+ expected_retained = temporary / "retained"
183
+ shutil.copytree(
184
+ contract.retained_root,
185
+ expected_retained,
186
+ ignore=shutil.ignore_patterns(".tracecite-manifest.json"),
187
+ )
188
+ expected = replace(
189
+ contract, retained_root=expected_retained, staged_root=temporary
190
+ )
191
+ canonical_retained = contract.retained_root
192
+ stage_docs(
193
+ expected,
194
+ target="local",
195
+ repo_root=root,
196
+ link_markdown_root=canonical_retained,
197
+ )
198
+ stage_docs(
199
+ expected,
200
+ target="public",
201
+ repo_root=root,
202
+ link_markdown_root=canonical_retained,
203
+ )
204
+ expected_local = _staged_files(
205
+ expected.staged_root / "local", contract.staged_root / "local", root
206
+ )
207
+ expected_public = _staged_files(
208
+ expected.staged_root / "public", contract.staged_root / "public", root
209
+ )
210
+ actual_local = _staged_files(
211
+ contract.staged_root / "local", contract.staged_root / "local", root
212
+ )
213
+ actual_public = _staged_files(
214
+ contract.staged_root / "public", contract.staged_root / "public", root
215
+ )
216
+ retained = _repo_files(contract.retained_root, root, exclude=manifest_path)
217
+ manifest_retained = manifest.get("retained", {})
218
+ for label, actual, wanted in (
219
+ ("retained", retained, manifest_retained),
220
+ ("local staged", actual_local, expected_local),
221
+ ("public staged", actual_public, expected_public),
222
+ ):
223
+ if actual != wanted:
224
+ for path in sorted(set(actual) - set(wanted)):
225
+ diagnostics.append(f"{label} extra: {path}")
226
+ for path in sorted(set(wanted) - set(actual)):
227
+ diagnostics.append(f"{label} missing: {path}")
228
+ for path in sorted(set(actual) & set(wanted)):
229
+ if actual[path] != wanted[path]:
230
+ diagnostics.append(f"{label} hash mismatch: {path}")
231
+ recorded_public = manifest.get("public", {})
232
+ if recorded_public != expected_public:
233
+ diagnostics.append("public staged manifest is stale")
234
+ diagnostics.extend(docs_index_freshness_diagnostics(contract))
235
+ except Exception as exc: # noqa: BLE001
236
+ diagnostics.append(f"staging expectation failed: {exc}")
237
+ finally:
238
+ if temporary.exists():
239
+ shutil.rmtree(temporary)
240
+ return DocsModeResult("check", not diagnostics, manifest_path, tuple(diagnostics))
@@ -0,0 +1,408 @@
1
+ """Conservative, atomic schema-v3 local/public Markdown source-link staging."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import re
7
+ import shutil
8
+ import tempfile
9
+ from dataclasses import dataclass
10
+ from pathlib import Path
11
+ from typing import Literal
12
+
13
+ from tracecite.evidence.source_links import (
14
+ SourceLinkEntry,
15
+ load_source_links,
16
+ parse_staged_markdown_destination,
17
+ parse_staged_source_destination,
18
+ )
19
+
20
+ from .contract import DocsEvidenceContract
21
+
22
+ StageTarget = Literal["local", "public"]
23
+ _DEFINITION = re.compile(
24
+ r"^(?P<prefix>\s{0,3}\[[^\]]+\]:\s*)(?P<destination>\S+)(?P<suffix>\s*)$"
25
+ )
26
+ _INLINE = re.compile(r"(?P<prefix>\[[^\]]+\]\()(?P<destination>[^\s)]+)(?P<suffix>\))")
27
+ _FENCE = re.compile(r"^\s{0,3}(?P<marker>`{3,}|~{3,})(?P<suffix>.*)$")
28
+ _HTML_TAG = re.compile(r"</?[A-Za-z][^>]*>")
29
+ _HTML_OPEN_TAG = re.compile(r"<(?P<tag>[A-Za-z][\w:-]*)\b[^>]*>")
30
+ _HTML_ELEMENT = re.compile(
31
+ r"<(?P<tag>[A-Za-z][\w:-]*)\b[^>]*>.*?</(?P=tag)\s*>", re.DOTALL
32
+ )
33
+ _HTML_BLOCK_TAGS = {
34
+ "address",
35
+ "article",
36
+ "aside",
37
+ "blockquote",
38
+ "body",
39
+ "caption",
40
+ "center",
41
+ "colgroup",
42
+ "dd",
43
+ "details",
44
+ "dialog",
45
+ "dir",
46
+ "div",
47
+ "dl",
48
+ "dt",
49
+ "fieldset",
50
+ "figcaption",
51
+ "figure",
52
+ "footer",
53
+ "form",
54
+ "h1",
55
+ "h2",
56
+ "h3",
57
+ "h4",
58
+ "h5",
59
+ "h6",
60
+ "head",
61
+ "header",
62
+ "hgroup",
63
+ "hr",
64
+ "html",
65
+ "legend",
66
+ "li",
67
+ "main",
68
+ "menu",
69
+ "nav",
70
+ "ol",
71
+ "p",
72
+ "pre",
73
+ "script",
74
+ "section",
75
+ "summary",
76
+ "table",
77
+ "tbody",
78
+ "td",
79
+ "tfoot",
80
+ "th",
81
+ "thead",
82
+ "title",
83
+ "tr",
84
+ "ul",
85
+ }
86
+ _TABLE_SEPARATOR = re.compile(r"^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$")
87
+
88
+
89
+ def _protected_ranges(
90
+ line: str, in_comment: bool
91
+ ) -> tuple[list[tuple[int, int]], bool]:
92
+ ranges: list[tuple[int, int]] = []
93
+ cursor = 0
94
+ while cursor < len(line):
95
+ if in_comment:
96
+ end = line.find("-->", cursor)
97
+ if end < 0:
98
+ ranges.append((cursor, len(line)))
99
+ return ranges, True
100
+ ranges.append((cursor, end + 3))
101
+ cursor = end + 3
102
+ in_comment = False
103
+ continue
104
+ start = line.find("<!--", cursor)
105
+ if start < 0:
106
+ break
107
+ cursor = start
108
+ in_comment = True
109
+ ranges.extend(
110
+ (match.start(), match.end()) for match in _HTML_ELEMENT.finditer(line)
111
+ )
112
+ for match in _HTML_TAG.finditer(line):
113
+ if match.group(0).startswith("</"):
114
+ continue
115
+ if not any(start <= match.start() < end for start, end in ranges):
116
+ ranges.append((match.start(), len(line)))
117
+ return ranges, in_comment
118
+
119
+
120
+ @dataclass(frozen=True, slots=True)
121
+ class DocsStageResult:
122
+ target: StageTarget
123
+ staged_root: Path
124
+ changed_files: tuple[Path, ...]
125
+
126
+
127
+ def _registry_entries(
128
+ relative: str, markdown_path: Path, registry: dict[Path, list[SourceLinkEntry]]
129
+ ) -> list[SourceLinkEntry]:
130
+ return registry.get((markdown_path.parent / relative).resolve(), [])
131
+
132
+
133
+ def _routed_destination(
134
+ destination: str,
135
+ markdown_path: Path,
136
+ output_markdown_path: Path,
137
+ repo_root: Path,
138
+ registry: dict[Path, list[SourceLinkEntry]],
139
+ target: StageTarget,
140
+ ) -> str | None:
141
+ """Return the staged form of a source-link destination, or ``None`` to leave it unchanged.
142
+
143
+ A PDF ``#page=N`` destination must resolve to exactly one registry entry.
144
+ A local Markdown destination is routed only when it resolves to exactly
145
+ one entry; any other Markdown link is ordinary navigation.
146
+ """
147
+ if "://" in destination or "?" in destination:
148
+ return None
149
+ if ".pdf" in destination.lower() or "#page=" in destination:
150
+ parsed = parse_staged_source_destination(destination)
151
+ if parsed is None:
152
+ raise ValueError(f"malformed source-PDF destination: {destination}")
153
+ relative, page = parsed
154
+ entries = _registry_entries(relative, markdown_path, registry)
155
+ if len(entries) != 1:
156
+ raise ValueError(
157
+ f"source-link destination has {len(entries)} registry entries: {relative}"
158
+ )
159
+ fragment = f"#page={page}"
160
+ elif ".md" in destination.lower():
161
+ parsed = parse_staged_markdown_destination(destination)
162
+ if parsed is None:
163
+ return None
164
+ relative, anchor = parsed
165
+ entries = _registry_entries(relative, markdown_path, registry)
166
+ if len(entries) != 1:
167
+ return None
168
+ fragment = f"#{anchor}" if anchor else ""
169
+ else:
170
+ return None
171
+ if target == "public":
172
+ return f"{entries[0].public_url}{fragment}"
173
+ source = (repo_root / entries[0].local_path).resolve()
174
+ return f"{Path(os.path.relpath(source, output_markdown_path.parent)).as_posix()}{fragment}"
175
+
176
+
177
+ def _rewrite_markdown(
178
+ text: str,
179
+ markdown_path: Path,
180
+ output_markdown_path: Path,
181
+ repo_root: Path,
182
+ registry: dict[Path, list[SourceLinkEntry]],
183
+ target: StageTarget,
184
+ ) -> str:
185
+ output: list[str] = []
186
+ fenced = False
187
+ marker = ""
188
+ frontmatter = False
189
+ first_logical_line_seen = False
190
+ html_comment = False
191
+ html_block_tag: str | None = None
192
+ table_mode = False
193
+ lines = text.splitlines(keepends=True)
194
+ for index, line in enumerate(lines):
195
+ bare = line.rstrip("\r\n")
196
+ if not first_logical_line_seen and bare.strip() == "":
197
+ output.append(line)
198
+ continue
199
+ if not first_logical_line_seen and bare.strip() == "---":
200
+ frontmatter = True
201
+ first_logical_line_seen = True
202
+ output.append(line)
203
+ continue
204
+ first_logical_line_seen = True
205
+ if frontmatter:
206
+ output.append(line)
207
+ if bare.strip() == "---":
208
+ frontmatter = False
209
+ continue
210
+ if html_block_tag is not None:
211
+ output.append(line)
212
+ if re.search(rf"</{re.escape(html_block_tag)}\s*>", bare, re.IGNORECASE):
213
+ html_block_tag = None
214
+ continue
215
+ fence = _FENCE.match(bare)
216
+ if fenced:
217
+ output.append(line)
218
+ if (
219
+ fence
220
+ and fence.group("marker")[0] == marker
221
+ and not fence.group("suffix").strip()
222
+ ):
223
+ fenced = False
224
+ continue
225
+ if fence:
226
+ fenced = True
227
+ marker = fence.group("marker")[0]
228
+ output.append(line)
229
+ continue
230
+ next_bare = lines[index + 1].rstrip("\r\n") if index + 1 < len(lines) else ""
231
+ separator = bool(_TABLE_SEPARATOR.match(bare))
232
+ table_line = (
233
+ bare.lstrip().startswith("|")
234
+ or separator
235
+ or (table_mode and "|" in bare)
236
+ or ("|" in bare and bool(_TABLE_SEPARATOR.match(next_bare)))
237
+ )
238
+ if table_line:
239
+ table_mode = (
240
+ separator
241
+ or (table_mode and "|" in bare)
242
+ or bare.lstrip().startswith("|")
243
+ )
244
+ output.append(line)
245
+ continue
246
+ if not bare.strip():
247
+ table_mode = False
248
+ if bare.startswith((" ", "\t")):
249
+ output.append(line)
250
+ continue
251
+ protected, html_comment = _protected_ranges(bare, html_comment)
252
+ for opening in _HTML_OPEN_TAG.finditer(bare):
253
+ tag = opening.group("tag").lower()
254
+ if tag in _HTML_BLOCK_TAGS and not re.search(
255
+ rf"</{re.escape(tag)}\s*>", bare[opening.end() :], re.IGNORECASE
256
+ ):
257
+ html_block_tag = tag
258
+ break
259
+ definition = _DEFINITION.match(bare)
260
+ if definition and not any(
261
+ start < definition.end() and definition.start() < end
262
+ for start, end in protected
263
+ ):
264
+ replacement = _routed_destination(
265
+ definition.group("destination"),
266
+ markdown_path,
267
+ output_markdown_path,
268
+ repo_root,
269
+ registry,
270
+ target,
271
+ )
272
+ if replacement is not None:
273
+ line = (
274
+ f"{definition.group('prefix')}{replacement}{definition.group('suffix')}"
275
+ + line[len(bare) :]
276
+ )
277
+ output.append(line)
278
+ continue
279
+ cursor = 0
280
+ pieces: list[str] = []
281
+ for match in _INLINE.finditer(bare):
282
+ if bare[: match.start()].count("`") % 2 == 1:
283
+ continue
284
+ if any(
285
+ start < match.end() and match.start() < end for start, end in protected
286
+ ):
287
+ continue
288
+ if match.start() > 0 and bare[match.start() - 1] == "!":
289
+ continue
290
+ destination = match.group("destination")
291
+ if destination.startswith("<"):
292
+ continue
293
+ replacement = _routed_destination(
294
+ destination,
295
+ markdown_path,
296
+ output_markdown_path,
297
+ repo_root,
298
+ registry,
299
+ target,
300
+ )
301
+ if replacement is not None:
302
+ pieces.extend(
303
+ (
304
+ bare[cursor : match.start()],
305
+ match.group("prefix"),
306
+ replacement,
307
+ match.group("suffix"),
308
+ )
309
+ )
310
+ cursor = match.end()
311
+ if pieces:
312
+ pieces.append(bare[cursor:])
313
+ line = "".join(pieces) + line[len(bare) :]
314
+ output.append(line)
315
+ return "".join(output)
316
+
317
+
318
+ def stage_docs(
319
+ contract: DocsEvidenceContract,
320
+ *,
321
+ target: StageTarget,
322
+ repo_root: str | Path,
323
+ link_markdown_root: Path | None = None,
324
+ ) -> DocsStageResult:
325
+ if target not in {"local", "public"}:
326
+ raise ValueError("target must be local or public")
327
+ root = Path(repo_root).resolve()
328
+ registry, issues = load_source_links(contract.source_links, root)
329
+ if issues:
330
+ raise ValueError("invalid source-links registry: " + "; ".join(issues))
331
+ contract.staged_root.parent.mkdir(parents=True, exist_ok=True)
332
+ contract.staged_root.mkdir(parents=True, exist_ok=True)
333
+ temporary = Path(
334
+ tempfile.mkdtemp(prefix=f".{target}-", dir=contract.staged_root.parent)
335
+ )
336
+ target_path = contract.staged_root / target
337
+ backup = target_path.with_name(f".{target}.previous")
338
+ try:
339
+ shutil.copytree(contract.retained_root, temporary, dirs_exist_ok=True)
340
+ changed: list[Path] = []
341
+ link_root = link_markdown_root or contract.retained_root
342
+ if target == "public":
343
+ for entries in registry.values():
344
+ for entry in entries:
345
+ source = (root / entry.local_path).resolve()
346
+ try:
347
+ relative = source.relative_to(link_root.resolve())
348
+ except ValueError:
349
+ continue
350
+ candidate = temporary / relative
351
+ if candidate.is_file():
352
+ candidate.unlink()
353
+ for path in temporary.rglob("*.md"):
354
+ original = path.read_text(encoding="utf-8")
355
+ relative = path.relative_to(temporary)
356
+ link_path = link_root / relative
357
+ transformed = _rewrite_markdown(
358
+ original, link_path, target_path / relative, root, registry, target
359
+ )
360
+ if transformed != original:
361
+ path.write_text(transformed, encoding="utf-8")
362
+ changed.append(path.relative_to(temporary))
363
+ if backup.exists():
364
+ shutil.rmtree(backup)
365
+ if target_path.exists():
366
+ os.replace(target_path, backup)
367
+ os.replace(temporary, target_path)
368
+ if backup.exists():
369
+ shutil.rmtree(backup)
370
+ except Exception:
371
+ if temporary.exists():
372
+ shutil.rmtree(temporary)
373
+ if backup.exists() and not target_path.exists():
374
+ os.replace(backup, target_path)
375
+ raise
376
+ return DocsStageResult(target, target_path, tuple(changed))
377
+
378
+
379
+ def is_publication_excluded(path: Path, contract: DocsEvidenceContract) -> bool:
380
+ resolved = path.resolve()
381
+ return any(
382
+ resolved == target or (target.is_dir() and resolved.is_relative_to(target))
383
+ for target in (exclude.resolve() for exclude in contract.publication_exclude)
384
+ )
385
+
386
+
387
+ def validate_retained_source_links(
388
+ contract: DocsEvidenceContract,
389
+ *,
390
+ repo_root: str | Path,
391
+ ) -> tuple[str, ...]:
392
+ """Validate source-PDF/Markdown link candidates in retained Markdown without rewriting."""
393
+ root = Path(repo_root).resolve()
394
+ registry, issues = load_source_links(contract.source_links, root)
395
+ if issues:
396
+ return tuple(f"source-links registry: {issue}" for issue in issues)
397
+ diagnostics: list[str] = []
398
+ for path in sorted(contract.retained_root.rglob("*.md")):
399
+ if is_publication_excluded(path, contract):
400
+ continue
401
+ relative = path.relative_to(contract.retained_root).as_posix()
402
+ try:
403
+ _rewrite_markdown(
404
+ path.read_text(encoding="utf-8"), path, path, root, registry, "local"
405
+ )
406
+ except ValueError as exc:
407
+ diagnostics.append(f"{relative}: {exc}")
408
+ return tuple(diagnostics)