@teevee98/synapse-hub 4.2.3 → 4.2.4

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 (36) hide show
  1. package/.agents/rules/mandatory-playwright-live.md +1 -1
  2. package/.agents/skills/01-web-automation/playwright-live-interaction/SKILL.md +2 -2
  3. package/.agents/skills/01-web-automation/playwright-live-interaction/references/recipes.md +14 -31
  4. package/.agents/skills/05-security-and-compliance/wcag-audit-patterns/SKILL.md +5 -4
  5. package/AGENTS.md +1 -1
  6. package/README.en.md +2 -2
  7. package/README.md +2 -2
  8. package/agentskills.json +1 -1
  9. package/docs/ARCHITECTURE.en.md +1 -1
  10. package/docs/ARCHITECTURE.md +1 -1
  11. package/docs/PERFORMANCE_AUDIT_REPORT.md +2 -2
  12. package/docs/TOOL_CATALOG.md +25 -20
  13. package/package.json +1 -1
  14. package/plugin.json +1 -1
  15. package/scripts/setup.sh +6 -1
  16. package/skills_manifest.json +1 -1
  17. package/synapse.config.json +1 -1
  18. package/tools/TOOL_CATALOG.json +112 -31
  19. package/tools/__init__.py +1 -1
  20. package/tools/browser_helpers.js +2 -2
  21. package/tools/cli.py +3 -3
  22. package/tools/core/file_lock.py +7 -0
  23. package/tools/core/memory_bus.py +44 -40
  24. package/tools/core/process_supervisor.py +12 -4
  25. package/tools/core/telemetry.py +54 -16
  26. package/tools/dashboard_generator.py +6 -6
  27. package/tools/db_sandbox.py +8 -2
  28. package/tools/generate_tool_catalog.py +32 -2
  29. package/tools/mcp_docx_server.py +1 -1
  30. package/tools/mcp_excel_server.py +1 -1
  31. package/tools/mcp_server.py +1 -1
  32. package/tools/package_release.py +22 -27
  33. package/tools/reversible_sandbox.py +43 -10
  34. package/tools/ui_server.py +1 -1
  35. package/tools/update_sentinel.py +3 -3
  36. package/tools/welcome_page.py +1 -1
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema_version": "1.0.0",
3
- "updated_at": "2026-11-15T03:21:02.088778+00:00",
4
- "total_tools": 125,
5
- "stable_count": 125,
3
+ "updated_at": "2026-11-16T07:34:48.105553+00:00",
4
+ "total_tools": 130,
5
+ "stable_count": 130,
6
6
  "experimental_count": 0,
7
7
  "tools": [
8
8
  {
@@ -41,7 +41,7 @@
41
41
  "category": "Auxiliary Utilities",
42
42
  "owner_role": "orchestrator",
43
43
  "status": "stable",
44
- "risk_level": "read_only",
44
+ "risk_level": "modifying",
45
45
  "inputs": [
46
46
  "CLI options"
47
47
  ],
@@ -154,7 +154,7 @@
154
154
  "category": "Auxiliary Utilities",
155
155
  "owner_role": "orchestrator",
156
156
  "status": "stable",
157
- "risk_level": "read_only",
157
+ "risk_level": "modifying",
158
158
  "inputs": [
159
159
  "CLI options"
160
160
  ],
@@ -195,6 +195,21 @@
195
195
  ],
196
196
  "description": "Empirical context token reduction benchmark harness proving >= 40% savings."
197
197
  },
198
+ {
199
+ "file": "tools/break_ui_generator.py",
200
+ "command": "python tools/break_ui_generator.py",
201
+ "category": "Auxiliary Utilities",
202
+ "owner_role": "orchestrator",
203
+ "status": "stable",
204
+ "risk_level": "read_only",
205
+ "inputs": [
206
+ "CLI options"
207
+ ],
208
+ "outputs": [
209
+ "Artifacts / Telemetry"
210
+ ],
211
+ "description": "tools/break_ui_generator.py — Edge-Case UI Stress Testing Data Generator"
212
+ },
198
213
  {
199
214
  "file": "tools/browsergym_eval.py",
200
215
  "command": "python tools/browsergym_eval.py",
@@ -246,7 +261,7 @@
246
261
  "category": "Auxiliary Utilities",
247
262
  "owner_role": "orchestrator",
248
263
  "status": "stable",
249
- "risk_level": "read_only",
264
+ "risk_level": "modifying",
250
265
  "inputs": [
251
266
  "CLI options"
252
267
  ],
@@ -291,7 +306,7 @@
291
306
  "category": "Auxiliary Utilities",
292
307
  "owner_role": "orchestrator",
293
308
  "status": "stable",
294
- "risk_level": "read_only",
309
+ "risk_level": "modifying",
295
310
  "inputs": [
296
311
  "CLI options"
297
312
  ],
@@ -306,7 +321,7 @@
306
321
  "category": "Auxiliary Utilities",
307
322
  "owner_role": "orchestrator",
308
323
  "status": "stable",
309
- "risk_level": "read_only",
324
+ "risk_level": "modifying",
310
325
  "inputs": [
311
326
  "CLI options"
312
327
  ],
@@ -423,17 +438,20 @@
423
438
  {
424
439
  "file": "tools/db_sandbox.py",
425
440
  "command": "python tools/db_sandbox.py",
426
- "category": "Auxiliary Utilities",
427
- "owner_role": "orchestrator",
441
+ "category": "Sandboxing & Isolation",
442
+ "owner_role": "failure-analyst",
428
443
  "status": "stable",
429
- "risk_level": "read_only",
444
+ "risk_level": "modifying",
430
445
  "inputs": [
431
- "CLI options"
446
+ "--mode audit|purge|restore",
447
+ "--db-path",
448
+ "--consent"
432
449
  ],
433
450
  "outputs": [
434
- "Artifacts / Telemetry"
451
+ "Database snapshots",
452
+ "Purge audit logs"
435
453
  ],
436
- "description": "Enterprise Zero-Pollution Database Sandbox & Ephemeral Teardown Engine"
454
+ "description": "Database state isolation sentinel with granular consent-governed snapshot and purge capabilities."
437
455
  },
438
456
  {
439
457
  "file": "tools/debt_harvester.py",
@@ -480,6 +498,21 @@
480
498
  ],
481
499
  "description": "tools/distill_log.py — Enterprise Multi-Framework Log Distiller (Token & Failure Sentinel)"
482
500
  },
501
+ {
502
+ "file": "tools/distill_skill.py",
503
+ "command": "python tools/distill_skill.py",
504
+ "category": "Auxiliary Utilities",
505
+ "owner_role": "orchestrator",
506
+ "status": "stable",
507
+ "risk_level": "destructive",
508
+ "inputs": [
509
+ "CLI options"
510
+ ],
511
+ "outputs": [
512
+ "Artifacts / Telemetry"
513
+ ],
514
+ "description": "tools/distill_skill.py — Dual-Skill Distillation Engine"
515
+ },
483
516
  {
484
517
  "file": "tools/dspy_qa_signatures.py",
485
518
  "command": "python tools/dspy_qa_signatures.py",
@@ -774,7 +807,7 @@
774
807
  "category": "Auxiliary Utilities",
775
808
  "owner_role": "orchestrator",
776
809
  "status": "stable",
777
- "risk_level": "read_only",
810
+ "risk_level": "modifying",
778
811
  "inputs": [
779
812
  "CLI options"
780
813
  ],
@@ -889,7 +922,7 @@
889
922
  "category": "Auxiliary Utilities",
890
923
  "owner_role": "orchestrator",
891
924
  "status": "stable",
892
- "risk_level": "read_only",
925
+ "risk_level": "modifying",
893
926
  "inputs": [
894
927
  "CLI options"
895
928
  ],
@@ -1210,7 +1243,7 @@
1210
1243
  "category": "CI/CD & Packaging",
1211
1244
  "owner_role": "orchestrator",
1212
1245
  "status": "stable",
1213
- "risk_level": "read_only",
1246
+ "risk_level": "modifying",
1214
1247
  "inputs": [
1215
1248
  "--output-dir",
1216
1249
  "--format zip|tar.gz|both",
@@ -1317,17 +1350,20 @@
1317
1350
  {
1318
1351
  "file": "tools/reversible_sandbox.py",
1319
1352
  "command": "python tools/reversible_sandbox.py",
1320
- "category": "Auxiliary Utilities",
1321
- "owner_role": "orchestrator",
1353
+ "category": "Sandboxing & Isolation",
1354
+ "owner_role": "failure-analyst",
1322
1355
  "status": "stable",
1323
- "risk_level": "read_only",
1356
+ "risk_level": "modifying",
1324
1357
  "inputs": [
1325
- "CLI options"
1358
+ "--execute-stateful",
1359
+ "--rollback",
1360
+ "--recover-wal"
1326
1361
  ],
1327
1362
  "outputs": [
1328
- "Artifacts / Telemetry"
1363
+ ".agent_memory/undo_wal.jsonl",
1364
+ "Reversible execution rollbacks"
1329
1365
  ],
1330
- "description": "Reversible Execution Sandbox & Automated Teardown Engine (GoEx Pattern)"
1366
+ "description": "Two-phase commit write-ahead logging (WAL) execution sandbox providing crash-resilient rollback guarantees."
1331
1367
  },
1332
1368
  {
1333
1369
  "file": "tools/rules_router.py",
@@ -1448,7 +1484,7 @@
1448
1484
  "category": "Auxiliary Utilities",
1449
1485
  "owner_role": "orchestrator",
1450
1486
  "status": "stable",
1451
- "risk_level": "read_only",
1487
+ "risk_level": "destructive",
1452
1488
  "inputs": [
1453
1489
  "CLI options"
1454
1490
  ],
@@ -1463,7 +1499,7 @@
1463
1499
  "category": "Auxiliary Utilities",
1464
1500
  "owner_role": "orchestrator",
1465
1501
  "status": "stable",
1466
- "risk_level": "read_only",
1502
+ "risk_level": "destructive",
1467
1503
  "inputs": [
1468
1504
  "CLI options"
1469
1505
  ],
@@ -1478,7 +1514,7 @@
1478
1514
  "category": "Auxiliary Utilities",
1479
1515
  "owner_role": "orchestrator",
1480
1516
  "status": "stable",
1481
- "risk_level": "read_only",
1517
+ "risk_level": "destructive",
1482
1518
  "inputs": [
1483
1519
  "CLI options"
1484
1520
  ],
@@ -1493,7 +1529,7 @@
1493
1529
  "category": "Auxiliary Utilities",
1494
1530
  "owner_role": "orchestrator",
1495
1531
  "status": "stable",
1496
- "risk_level": "read_only",
1532
+ "risk_level": "destructive",
1497
1533
  "inputs": [
1498
1534
  "CLI options"
1499
1535
  ],
@@ -1519,6 +1555,21 @@
1519
1555
  ],
1520
1556
  "description": "Security scanner detecting prompt injection, Unicode obfuscation, and dangerous CLI tools."
1521
1557
  },
1558
+ {
1559
+ "file": "tools/slide_deck_exporter.py",
1560
+ "command": "python tools/slide_deck_exporter.py",
1561
+ "category": "Auxiliary Utilities",
1562
+ "owner_role": "orchestrator",
1563
+ "status": "stable",
1564
+ "risk_level": "read_only",
1565
+ "inputs": [
1566
+ "CLI options"
1567
+ ],
1568
+ "outputs": [
1569
+ "Artifacts / Telemetry"
1570
+ ],
1571
+ "description": "tools/slide_deck_exporter.py — Pure HTML/CSS 16:9 Vector Slide Deck Exporter"
1572
+ },
1522
1573
  {
1523
1574
  "file": "tools/smart_visual_masker.py",
1524
1575
  "command": "python tools/smart_visual_masker.py",
@@ -1600,7 +1651,7 @@
1600
1651
  "category": "Auxiliary Utilities",
1601
1652
  "owner_role": "orchestrator",
1602
1653
  "status": "stable",
1603
- "risk_level": "read_only",
1654
+ "risk_level": "modifying",
1604
1655
  "inputs": [
1605
1656
  "CLI options"
1606
1657
  ],
@@ -1615,7 +1666,7 @@
1615
1666
  "category": "Auxiliary Utilities",
1616
1667
  "owner_role": "orchestrator",
1617
1668
  "status": "stable",
1618
- "risk_level": "read_only",
1669
+ "risk_level": "destructive",
1619
1670
  "inputs": [
1620
1671
  "CLI options"
1621
1672
  ],
@@ -1624,6 +1675,21 @@
1624
1675
  ],
1625
1676
  "description": "tools/sync_skills_manifest.py — Synchronize Skill Policies & Frontmatter into Manifest"
1626
1677
  },
1678
+ {
1679
+ "file": "tools/task_memory_manager.py",
1680
+ "command": "python tools/task_memory_manager.py",
1681
+ "category": "Auxiliary Utilities",
1682
+ "owner_role": "orchestrator",
1683
+ "status": "stable",
1684
+ "risk_level": "read_only",
1685
+ "inputs": [
1686
+ "CLI options"
1687
+ ],
1688
+ "outputs": [
1689
+ "Artifacts / Telemetry"
1690
+ ],
1691
+ "description": "tools/task_memory_manager.py — Compaction-Resilient Working Memory Manager"
1692
+ },
1627
1693
  {
1628
1694
  "file": "tools/telemetry_correlator.py",
1629
1695
  "command": "python tools/telemetry_correlator.py",
@@ -1717,7 +1783,7 @@
1717
1783
  "category": "Auxiliary Utilities",
1718
1784
  "owner_role": "orchestrator",
1719
1785
  "status": "stable",
1720
- "risk_level": "read_only",
1786
+ "risk_level": "modifying",
1721
1787
  "inputs": [
1722
1788
  "CLI options"
1723
1789
  ],
@@ -1866,13 +1932,28 @@
1866
1932
  ],
1867
1933
  "description": "Pre-check validator for Groovy scripts and POM keywords in enterprise test suites."
1868
1934
  },
1935
+ {
1936
+ "file": "tools/validate_host_interop.py",
1937
+ "command": "python tools/validate_host_interop.py",
1938
+ "category": "Auxiliary Utilities",
1939
+ "owner_role": "orchestrator",
1940
+ "status": "stable",
1941
+ "risk_level": "read_only",
1942
+ "inputs": [
1943
+ "CLI options"
1944
+ ],
1945
+ "outputs": [
1946
+ "Artifacts / Telemetry"
1947
+ ],
1948
+ "description": "tools/validate_host_interop.py — Multi-Host AI Agent Interoperability Sentinel"
1949
+ },
1869
1950
  {
1870
1951
  "file": "tools/validate_skills_schema.py",
1871
1952
  "command": "python tools/validate_skills_schema.py",
1872
1953
  "category": "Auxiliary Utilities",
1873
1954
  "owner_role": "orchestrator",
1874
1955
  "status": "stable",
1875
- "risk_level": "read_only",
1956
+ "risk_level": "destructive",
1876
1957
  "inputs": [
1877
1958
  "CLI options"
1878
1959
  ],
package/tools/__init__.py CHANGED
@@ -17,7 +17,7 @@ Domain Packages:
17
17
  - tools.mcp: Model Context Protocol servers (core QA and Excel manipulation).
18
18
  """
19
19
 
20
- __version__ = "4.2.3"
20
+ __version__ = "4.2.4"
21
21
  __author__ = "Thế Vị (@TeeVee98)"
22
22
 
23
23
  # Expose domain packages
@@ -13,7 +13,7 @@
13
13
  (function () {
14
14
  'use strict';
15
15
 
16
- if (window.__qa && window.__qa.__version === '4.2.3') {
16
+ if (window.__qa && window.__qa.__version === '4.2.4') {
17
17
  return window.__qa;
18
18
  }
19
19
 
@@ -47,7 +47,7 @@
47
47
  }
48
48
 
49
49
  const qa = {
50
- __version: '4.2.3',
50
+ __version: '4.2.4',
51
51
 
52
52
  /**
53
53
  * 1. Smart Action Batching
package/tools/cli.py CHANGED
@@ -133,7 +133,7 @@ def _resolve_manifest_path(repo_root: Optional[str] = None) -> Optional[str]:
133
133
  def cmd_version(args):
134
134
  """Displays the current hub version, skill catalog count, and license information."""
135
135
  manifest_path = _resolve_manifest_path()
136
- version = "4.2.3"
136
+ version = "4.2.4"
137
137
  manifest_skills = 53
138
138
  if manifest_path and os.path.exists(manifest_path):
139
139
  try:
@@ -775,14 +775,14 @@ def cmd_trend(args):
775
775
 
776
776
  def _hub_version():
777
777
  manifest_path = _resolve_manifest_path()
778
- version = "4.2.3"
778
+ version = "4.2.4"
779
779
  if manifest_path and os.path.exists(manifest_path):
780
780
  try:
781
781
  import json
782
782
  with open(manifest_path, "r", encoding="utf-8") as f:
783
783
  version = json.load(f).get("version", version)
784
784
  except (OSError, json.JSONDecodeError):
785
- version = "4.2.3"
785
+ version = "4.2.4"
786
786
  return version
787
787
 
788
788
 
@@ -62,6 +62,10 @@ def _win32_lock(fd: int, shared: bool = False) -> bool:
62
62
  Provides genuine shared (LOCKFILE_FAIL_IMMEDIATELY) and exclusive
63
63
  (LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY) locks with an OVERLAPPED structure.
64
64
  Gracefully falls back to msvcrt.locking if ctypes or LockFileEx is unavailable.
65
+
66
+ Note on fallback: msvcrt.locking natively only supports exclusive locks (LK_NBLCK).
67
+ When fallback is engaged, shared lock requests are safely upgraded to exclusive,
68
+ serializing concurrent readers.
65
69
  """
66
70
  msvcrt_mod = sys.modules.get("msvcrt")
67
71
  use_ctypes = _HAS_CTYPES and hasattr(ctypes, "windll") and hasattr(ctypes.windll, "kernel32")
@@ -92,6 +96,9 @@ def _win32_lock(fd: int, shared: bool = False) -> bool:
92
96
 
93
97
  # Graceful fallback to msvcrt.locking (exclusive lock only)
94
98
  if msvcrt_mod is not None:
99
+ if shared:
100
+ import logging
101
+ logging.getLogger("file_lock").debug("msvcrt fallback lacks native shared lock support; acquiring exclusive lock")
95
102
  os.lseek(fd, 0, os.SEEK_SET)
96
103
  msvcrt_mod.locking(fd, msvcrt_mod.LK_NBLCK, 1)
97
104
  return True
@@ -389,47 +389,51 @@ class UnifiedMemoryBus:
389
389
  mark_read: bool = True,
390
390
  session_id: Optional[str] = None
391
391
  ) -> List[Dict[str, Any]]:
392
- """Retrieves and optionally marks messages as PROCESSED for recipient."""
392
+ """Retrieves and atomically marks messages as PROCESSED for recipient across processes."""
393
393
  with self._lock:
394
- cur = self._conn.cursor()
395
- query = "SELECT * FROM actor_mailbox WHERE recipient = ? AND status = ?"
396
- params: List[Any] = [recipient, status]
397
- if stage:
398
- query += " AND stage = ?"
399
- params.append(stage)
400
- if session_id:
401
- query += " AND (session_id = ? OR session_id IS NULL)"
402
- params.append(session_id)
403
- query += " ORDER BY created_at ASC;"
404
-
405
- cur.execute(query, params)
406
- rows = cur.fetchall()
407
-
408
- messages = []
409
- msg_ids = []
410
- for r in rows:
411
- msg_ids.append(r["message_id"])
412
- messages.append({
413
- "message_id": r["message_id"],
414
- "session_id": r["session_id"] if "session_id" in r.keys() else None,
415
- "sender": r["sender"],
416
- "recipient": r["recipient"],
417
- "stage": r["stage"],
418
- "payload": _json_loads(r["payload"]),
419
- "status": r["status"],
420
- "created_at": r["created_at"],
421
- "read_at": r["read_at"]
422
- })
423
-
424
- if mark_read and msg_ids:
425
- now = _now_iso()
426
- placeholders = ",".join("?" for _ in msg_ids)
427
- cur.execute(
428
- f"UPDATE actor_mailbox SET status = 'PROCESSED', read_at = ? WHERE message_id IN ({placeholders});",
429
- [now] + msg_ids
430
- )
431
- cur.close()
432
- return messages
394
+ # Multi-process atomic claim: acquire transaction if marking read and not in caller transaction
395
+ import contextlib
396
+ cm = self.transaction() if (mark_read and not self._in_transaction) else contextlib.nullcontext()
397
+ with cm:
398
+ cur = self._conn.cursor()
399
+ query = "SELECT * FROM actor_mailbox WHERE recipient = ? AND status = ?"
400
+ params: List[Any] = [recipient, status]
401
+ if stage:
402
+ query += " AND stage = ?"
403
+ params.append(stage)
404
+ if session_id:
405
+ query += " AND (session_id = ? OR session_id IS NULL)"
406
+ params.append(session_id)
407
+ query += " ORDER BY created_at ASC;"
408
+
409
+ cur.execute(query, params)
410
+ rows = cur.fetchall()
411
+
412
+ messages = []
413
+ msg_ids = []
414
+ for r in rows:
415
+ msg_ids.append(r["message_id"])
416
+ messages.append({
417
+ "message_id": r["message_id"],
418
+ "session_id": r["session_id"] if "session_id" in r.keys() else None,
419
+ "sender": r["sender"],
420
+ "recipient": r["recipient"],
421
+ "stage": r["stage"],
422
+ "payload": _json_loads(r["payload"]),
423
+ "status": r["status"],
424
+ "created_at": r["created_at"],
425
+ "read_at": r["read_at"]
426
+ })
427
+
428
+ if mark_read and msg_ids:
429
+ now = _now_iso()
430
+ placeholders = ",".join("?" for _ in msg_ids)
431
+ cur.execute(
432
+ f"UPDATE actor_mailbox SET status = 'PROCESSED', read_at = ? WHERE message_id IN ({placeholders});",
433
+ [now] + msg_ids
434
+ )
435
+ cur.close()
436
+ return messages
433
437
 
434
438
  def peek_messages(
435
439
  self,
@@ -228,14 +228,22 @@ def reap_orphan_processes(
228
228
  continue
229
229
 
230
230
  is_tracked = bool(tracked_pids and pid in tracked_pids)
231
- is_orphan = False
231
+ is_dead_parent = False
232
232
  if ppid is not None:
233
233
  if sys.platform == "win32":
234
- is_orphan = not psutil.pid_exists(ppid)
234
+ is_dead_parent = not psutil.pid_exists(ppid)
235
235
  else:
236
- is_orphan = (ppid == 1) or (not psutil.pid_exists(ppid))
236
+ is_dead_parent = (ppid != 1 and not psutil.pid_exists(ppid))
237
237
 
238
- if is_tracked or is_orphan or allow_system_wide:
238
+ # Guard: Never kill untracked adopted processes (PPID=1) or orphans without explicit allow_system_wide=True
239
+ should_reap = False
240
+ if is_tracked:
241
+ should_reap = True
242
+ elif allow_system_wide:
243
+ is_orphan = is_dead_parent or (ppid == 1 if sys.platform != "win32" else False)
244
+ should_reap = is_orphan or allow_system_wide
245
+
246
+ if should_reap:
239
247
  proc.kill()
240
248
  reaped += 1
241
249
  except (psutil.NoSuchProcess, psutil.AccessDenied):
@@ -417,21 +417,46 @@ def record_session_telemetry(
417
417
  record: SessionTelemetryRecord,
418
418
  ledger_file: Optional[str] = None,
419
419
  ) -> None:
420
- """Appends a closed-loop session telemetry record to the JSON ledger with file locking."""
420
+ """Appends a closed-loop session telemetry record to the JSON ledger with file locking and atomic replace."""
421
421
  target_path = ledger_file or DEFAULT_SESSION_LEDGER
422
422
  os.makedirs(os.path.dirname(os.path.abspath(target_path)), exist_ok=True)
423
+ lock_path = target_path + ".lock"
423
424
 
424
- records: List[Dict[str, Any]] = []
425
- if os.path.exists(target_path):
426
- try:
427
- with open(target_path, "r", encoding="utf-8") as f:
428
- records = json.load(f)
429
- except (OSError, json.JSONDecodeError):
430
- records = []
431
-
432
- records.append(record.to_dict())
433
- with open(target_path, "w", encoding="utf-8") as f:
434
- json.dump(records, f, indent=2, ensure_ascii=False)
425
+ try:
426
+ from tools.core.file_lock import file_lock
427
+ ctx = file_lock(lock_path, timeout=10.0)
428
+ except ImportError:
429
+ import contextlib
430
+ ctx = contextlib.nullcontext()
431
+
432
+ with ctx:
433
+ records: List[Dict[str, Any]] = []
434
+ if os.path.exists(target_path):
435
+ try:
436
+ with open(target_path, "r", encoding="utf-8") as f:
437
+ content = f.read().strip()
438
+ if content:
439
+ loaded = json.loads(content)
440
+ records = loaded if isinstance(loaded, list) else []
441
+ except (OSError, json.JSONDecodeError) as err:
442
+ backup_path = f"{target_path}.corrupted.{int(time.time())}"
443
+ try:
444
+ import shutil
445
+ shutil.copy2(target_path, backup_path)
446
+ sys.stderr.write(f"Warning: Corrupted telemetry ledger detected. Quarantined to {backup_path}: {err}\n")
447
+ except OSError as copy_err:
448
+ sys.stderr.write(f"Notice: Failed to quarantine corrupted ledger: {copy_err}\n")
449
+ records = []
450
+
451
+ records.append(record.to_dict())
452
+
453
+ # Atomic write to avoid partial writes or corrupted json on interruption
454
+ tmp_target = f"{target_path}.tmp.{os.getpid()}.{time.time()}"
455
+ with open(tmp_target, "w", encoding="utf-8") as f:
456
+ json.dump(records, f, indent=2, ensure_ascii=False)
457
+ f.flush()
458
+ os.fsync(f.fileno())
459
+ os.replace(tmp_target, target_path)
435
460
 
436
461
 
437
462
  def get_telemetry_summary(ledger_file: Optional[str] = None) -> Dict[str, Any]:
@@ -449,10 +474,23 @@ def get_telemetry_summary(ledger_file: Optional[str] = None) -> Dict[str, Any]:
449
474
  }
450
475
 
451
476
  try:
452
- with open(target_path, "r", encoding="utf-8") as f:
453
- records: List[Dict[str, Any]] = json.load(f)
454
- except (OSError, json.JSONDecodeError):
455
- records = []
477
+ from tools.core.file_lock import file_lock
478
+ ctx = file_lock(target_path + ".lock", timeout=5.0, shared=True)
479
+ except ImportError:
480
+ import contextlib
481
+ ctx = contextlib.nullcontext()
482
+
483
+ records: List[Dict[str, Any]] = []
484
+ with ctx:
485
+ if os.path.exists(target_path):
486
+ try:
487
+ with open(target_path, "r", encoding="utf-8") as f:
488
+ content = f.read().strip()
489
+ if content:
490
+ loaded = json.loads(content)
491
+ records = loaded if isinstance(loaded, list) else []
492
+ except (OSError, json.JSONDecodeError):
493
+ records = []
456
494
 
457
495
  if not records:
458
496
  return {
@@ -1350,7 +1350,7 @@ def _build_target_translations(
1350
1350
  "th_step_status": "Trạng Thái",
1351
1351
  "th_step_details": "Chi Tiết Kỹ Thuật (OTel & AST)",
1352
1352
 
1353
- "footer_text": "Báo cáo được khởi tạo tự động bởi Synapse-Hub v4.2.3 • Bản quyền © Thế Vị (@TeeVee98) • Chuẩn Clean POM & Kiểm Thử Tự Chủ",
1353
+ "footer_text": "Báo cáo được khởi tạo tự động bởi Synapse-Hub v4.2.4 • Bản quyền © Thế Vị (@TeeVee98) • Chuẩn Clean POM & Kiểm Thử Tự Chủ",
1354
1354
  }
1355
1355
 
1356
1356
  translations_en = {
@@ -1428,7 +1428,7 @@ def _build_target_translations(
1428
1428
  "th_step_status": "Status",
1429
1429
  "th_step_details": "Technical Details (OTel & AST)",
1430
1430
 
1431
- "footer_text": "Generated automatically by Synapse-Hub v4.2.3 • Copyright © Thế Vị (@TeeVee98) • Clean POM & Autonomous Testing",
1431
+ "footer_text": "Generated automatically by Synapse-Hub v4.2.4 • Copyright © Thế Vị (@TeeVee98) • Clean POM & Autonomous Testing",
1432
1432
  }
1433
1433
 
1434
1434
  _inject_gate_translations(translations_vi, translations_en, gates)
@@ -1917,7 +1917,7 @@ def _build_hub_translations(
1917
1917
  """Builds bilingual dictionaries for Hub Dashboard."""
1918
1918
  translations_vi = {
1919
1919
  "header_title": "Bảng Điều Hành Chất Lượng Doanh Nghiệp",
1920
- "header_subtitle": "Synapse-Hub v4.2.3 • Hệ Sinh Thái Kiểm Thử AI Agent Tự Chủ",
1920
+ "header_subtitle": "Synapse-Hub v4.2.4 • Hệ Sinh Thái Kiểm Thử AI Agent Tự Chủ",
1921
1921
  "nav_welcome": "Giới Thiệu",
1922
1922
  "meta_mode": "🏷️ Chế độ: <strong>HỆ SINH THÁI QA HUB</strong>",
1923
1923
  "meta_gen": f"🕒 Khởi tạo: <strong>{now_str}</strong>",
@@ -1987,12 +1987,12 @@ def _build_hub_translations(
1987
1987
  "th_sk_ver": "Phiên Bản",
1988
1988
  "th_sk_cap": "Khả Năng Nghiệp Vụ Cốt Lõi",
1989
1989
 
1990
- "footer_text": "Bảng Điều Hành Chất Lượng Doanh Nghiệp &bull; Synapse-Hub v4.2.3 &bull; Bản quyền &copy; Thế Vị (@TeeVee98) &bull; Hệ Thống Kiểm Thử AI Agent Tự Chủ",
1990
+ "footer_text": "Bảng Điều Hành Chất Lượng Doanh Nghiệp &bull; Synapse-Hub v4.2.4 &bull; Bản quyền &copy; Thế Vị (@TeeVee98) &bull; Hệ Thống Kiểm Thử AI Agent Tự Chủ",
1991
1991
  }
1992
1992
 
1993
1993
  translations_en = {
1994
1994
  "header_title": "Enterprise QA Executive Dashboard",
1995
- "header_subtitle": "Synapse-Hub v4.2.3 &bull; Autonomous AI Agent Testing Ecosystem",
1995
+ "header_subtitle": "Synapse-Hub v4.2.4 &bull; Autonomous AI Agent Testing Ecosystem",
1996
1996
  "nav_welcome": "Welcome",
1997
1997
  "meta_mode": "🏷️ Mode: <strong>QA HUB ECOSYSTEM</strong>",
1998
1998
  "meta_gen": f"🕒 Generated: <strong>{now_str}</strong>",
@@ -2062,7 +2062,7 @@ def _build_hub_translations(
2062
2062
  "th_sk_ver": "Version",
2063
2063
  "th_sk_cap": "Core Capabilities",
2064
2064
 
2065
- "footer_text": "Enterprise QA Executive Dashboard &bull; Synapse-Hub v4.2.3 &bull; Copyright &copy; Thế Vị (@TeeVee98) &bull; Autonomous AI Agent Testing Ecosystem",
2065
+ "footer_text": "Enterprise QA Executive Dashboard &bull; Synapse-Hub v4.2.4 &bull; Copyright &copy; Thế Vị (@TeeVee98) &bull; Autonomous AI Agent Testing Ecosystem",
2066
2066
  }
2067
2067
 
2068
2068
  _inject_gate_translations(translations_vi, translations_en, gates)