diff --git a/patterns/default.yaml b/patterns/default.yaml index 54c87a3..ab6f1d4 100644 --- a/patterns/default.yaml +++ b/patterns/default.yaml @@ -211,10 +211,10 @@ patterns: domain: media description: Plex EasyAudioEncoder (EAC3 Dolby audio transcoder) crashed — service restart required - # - name: avcx_device_error + # - name: ext_device_error # pattern: "ERR-\d{4}" # severity: ERROR - # description: AVCX device error code + # description: vendor device structured error code # ── VPN / tunnel patterns ────────────────────────────────────────────────── diff --git a/scripts/gen_corpus.py b/scripts/gen_corpus.py index 406c863..c1a4ed4 100644 --- a/scripts/gen_corpus.py +++ b/scripts/gen_corpus.py @@ -12,7 +12,7 @@ Output tree: /journald/system.jsonl — systemd/kernel journald JSON /docker/services.jsonl — containerised app stdout /qbittorrent/qbt.log — hotio-format qBittorrent log - /avcx/device.log — AVCX device plaintext log + /ext_device/device.log — vendor device plaintext log """ from __future__ import annotations @@ -191,7 +191,7 @@ _QBT_MESSAGES: dict[str, list[str]] = { ], } -_AVCX_CODES: dict[str, list[str]] = { +_EXT_DEVICE_CODES: dict[str, list[str]] = { "INFO": [ "SYS-0100 Device boot complete, firmware v{n}.{n}.{n}", "SYS-0101 Sensor array calibration OK", @@ -307,13 +307,13 @@ def gen_qbittorrent(path: Path, start: datetime, end: datetime, rng: random.Rand return lines -def gen_avcx(path: Path, start: datetime, end: datetime, rng: random.Random, error_rate: float) -> int: - """Emit AVCX device plaintext log (ISO timestamp + level + ERR/SYS/NET code + message).""" +def gen_ext_device(path: Path, start: datetime, end: datetime, rng: random.Random, error_rate: float) -> int: + """Emit vendor device plaintext log (ISO timestamp + level + ERR/SYS/NET code + message).""" lines = 0 with path.open("w") as fh: for dt in _ts_seq(start, end, rng): severity = _pick_severity(rng, error_rate) - msg = _pick_msg(_AVCX_CODES, severity, rng) + msg = _pick_msg(_EXT_DEVICE_CODES, severity, rng) ts_str = dt.strftime("%Y-%m-%dT%H:%M:%S") fh.write(f"{ts_str} [{severity}] {msg}\n") lines += 1 @@ -326,7 +326,7 @@ _GENERATORS: list[tuple[str, str, Callable]] = [ ("journald", "system.jsonl", gen_journald), ("docker", "services.jsonl", gen_docker), ("qbittorrent", "qbt.log", gen_qbittorrent), - ("avcx", "device.log", gen_avcx), + ("ext_device", "device.log", gen_ext_device), ] diff --git a/tests/test_gen_corpus.py b/tests/test_gen_corpus.py index 0a03d75..8328c62 100644 --- a/tests/test_gen_corpus.py +++ b/tests/test_gen_corpus.py @@ -31,7 +31,7 @@ class TestOutputStructure: assert (tmp_path / "journald" / "system.jsonl").exists() assert (tmp_path / "docker" / "services.jsonl").exists() assert (tmp_path / "qbittorrent" / "qbt.log").exists() - assert (tmp_path / "avcx" / "device.log").exists() + assert (tmp_path / "ext_device" / "device.log").exists() def test_returns_line_counts(self, tmp_path: Path) -> None: totals = _run(tmp_path) @@ -129,12 +129,12 @@ class TestQbittorrentFormat: assert severities <= {"INFO", "WARN", "CRITICAL"} -# ── AVCX format ──────────────────────────────────────────────────────────────── +# ── Vendor device format ──────────────────────────────────────────────────────────────── class TestAvcxFormat: def test_iso_timestamp_prefix(self, tmp_path: Path) -> None: _run(tmp_path) - lines = (tmp_path / "avcx/device.log").read_text().splitlines() + lines = (tmp_path / "ext_device/device.log").read_text().splitlines() import re pattern = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2} \[.+\] .+$") assert all(pattern.match(line) for line in lines[:50]) @@ -142,7 +142,7 @@ class TestAvcxFormat: def test_parseable_by_plaintext_glean(self, tmp_path: Path) -> None: from app.glean.plaintext import parse _run(tmp_path) - with (tmp_path / "avcx/device.log").open() as fh: + with (tmp_path / "ext_device/device.log").open() as fh: entries = list(parse(fh, "test", [])) assert len(entries) > 0 # ISO timestamps should parse cleanly