Refactor architecture into eight components and consolidate reliability work
Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts. Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation. Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
This commit is contained in:
1 parent
9dd425f765
commit
d5d21b7841
302 files changed
+20037
-3492
No files matched your search
@@ -9,6 +9,7 @@ Uses only the Python standard library.
|
||||
from __future__ import annotations
|
||||
|
||||
import difflib
|
||||
import fcntl
|
||||
import fnmatch
|
||||
import glob
|
||||
import hashlib
|
||||
@@ -336,6 +337,26 @@ class PagesWikiCLI:
|
||||
if not self.database_path.is_file():
|
||||
raise CLIError(f"SQLite database not found: {self.database_path}")
|
||||
|
||||
# Coordinate with offline DR snapshots/promotions. Do this before any
|
||||
# schema repair or content write. A standby never permits this CLI.
|
||||
self._instance_lock = None
|
||||
try:
|
||||
lock_path = self.database_path.parent / ".pageswiki-instance.lock"
|
||||
self._instance_lock = lock_path.open("rb") if lock_path.exists() else lock_path.open("a+b")
|
||||
fcntl.flock(self._instance_lock.fileno(), fcntl.LOCK_SH | fcntl.LOCK_NB)
|
||||
for root in {self.data_dir, self.database_path.parent, self.documents.parent}:
|
||||
config_path = root / "dr-node.json"
|
||||
if config_path.exists():
|
||||
config = json.loads(config_path.read_text())
|
||||
if not isinstance(config, dict) or config.get("version") != 1 or config.get("role") != "primary":
|
||||
raise CLIError("DR standby or invalid configuration: data CLI is disabled")
|
||||
if root != self.database_path.parent or self.documents != root / "documents":
|
||||
raise CLIError("DR requires DB and documents in the same instance data directory")
|
||||
except (OSError, ValueError, CLIError) as exc:
|
||||
if self._instance_lock is not None:
|
||||
self._instance_lock.close()
|
||||
raise CLIError(f"DR maintenance guard: {exc}") from exc
|
||||
|
||||
self.db = sqlite3.connect(
|
||||
self.database_path,
|
||||
timeout=30,
|
||||
@@ -351,6 +372,8 @@ class PagesWikiCLI:
|
||||
|
||||
def close(self) -> None:
|
||||
self.db.close()
|
||||
if self._instance_lock is not None:
|
||||
self._instance_lock.close()
|
||||
|
||||
def _check_schema(self) -> None:
|
||||
required = {"objects", "paths", "revisions"}
|
||||
|
||||
Reference in new issue
Block a user