@teevee98/synapse-hub 3.9.0 โ†’ 3.10.0

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 (44) hide show
  1. package/.agents/rules/git-push-protocol.md +1 -1
  2. package/.agents/rules/mandatory-playwright-live.md +4 -2
  3. package/.agents/rules/mobile_appium_rules.md +14 -39
  4. package/.agents/rules/security_testing_rules.md +24 -0
  5. package/.agents/rules/stack-auto-router.md +17 -0
  6. package/.agents/rules/systematic-debugging.md +9 -8
  7. package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +9 -4
  8. package/.agents/skills/playwright-webapp-testing/SKILL.md +6 -4
  9. package/.agents/skills/token-and-context-optimizer/SKILL.md +1 -1
  10. package/.cursor/rules/agents.mdc +1 -1
  11. package/AGENTS.md +2 -1
  12. package/README.en.md +2 -2
  13. package/README.md +2 -2
  14. package/agentskills.json +1 -1
  15. package/docs/ARCHITECTURE.en.md +1 -1
  16. package/docs/ARCHITECTURE.md +1 -1
  17. package/docs/CLI_REFERENCE.en.md +7 -11
  18. package/docs/CLI_REFERENCE.md +7 -11
  19. package/docs/QUALITY_GATES.en.md +5 -5
  20. package/docs/QUALITY_GATES.md +5 -5
  21. package/package.json +1 -1
  22. package/plugin.json +1 -1
  23. package/scripts/install.ps1 +1 -1
  24. package/scripts/install_global_plugin.ps1 +19 -2
  25. package/scripts/install_global_plugin.sh +21 -2
  26. package/skills_manifest.json +1 -1
  27. package/synapse.config.json +1 -1
  28. package/tools/TOOL_CATALOG.json +1 -1
  29. package/tools/__init__.py +1 -1
  30. package/tools/browser_helpers.js +2 -2
  31. package/tools/cli.py +3 -3
  32. package/tools/core/memory_bus.py +25 -24
  33. package/tools/core/process_supervisor.py +55 -16
  34. package/tools/core/telemetry.py +32 -3
  35. package/tools/dashboard_generator.py +6 -6
  36. package/tools/db_sandbox.py +53 -10
  37. package/tools/mcp_docx_server.py +1 -1
  38. package/tools/mcp_excel_server.py +1 -1
  39. package/tools/mcp_server.py +1 -1
  40. package/tools/package_release.py +29 -5
  41. package/tools/reversible_sandbox.py +85 -7
  42. package/tools/ui_server.py +1 -1
  43. package/tools/update_sentinel.py +3 -3
  44. package/tools/welcome_page.py +1 -1
package/tools/cli.py CHANGED
@@ -99,7 +99,7 @@ def cmd_set_lang(args):
99
99
  def cmd_version(args):
100
100
  """Displays the current hub version, skill catalog count, and license information."""
101
101
  manifest_path = os.path.join(REPO_ROOT, "skills_manifest.json")
102
- version = "3.9.0"
102
+ version = "3.10.0"
103
103
  if os.path.exists(manifest_path):
104
104
  try:
105
105
  import json
@@ -680,14 +680,14 @@ def cmd_trend(args):
680
680
 
681
681
  def _hub_version():
682
682
  manifest_path = os.path.join(REPO_ROOT, "skills_manifest.json")
683
- version = "3.9.0"
683
+ version = "3.10.0"
684
684
  if os.path.exists(manifest_path):
685
685
  try:
686
686
  import json
687
687
  with open(manifest_path, "r", encoding="utf-8") as f:
688
688
  version = json.load(f).get("version", version)
689
689
  except (OSError, json.JSONDecodeError):
690
- version = "3.9.0"
690
+ version = "3.10.0"
691
691
  return version
692
692
 
693
693
 
@@ -821,32 +821,33 @@ class UnifiedMemoryBus:
821
821
  Removes succeeding events and appends a ROLLBACK_EXECUTED audit event.
822
822
  """
823
823
  with self._lock:
824
- cur = self._conn.cursor()
825
- cur.execute(
826
- "SELECT sequence FROM event_stream WHERE session_id = ? AND checkpoint_name = ? ORDER BY sequence DESC LIMIT 1;",
827
- (session_id, checkpoint_name)
828
- )
829
- row = cur.fetchone()
830
- if not row:
831
- cur.close()
832
- raise ValueError(f"Checkpoint '{checkpoint_name}' not found for session '{session_id}'.")
824
+ with self.transaction():
825
+ cur = self._conn.cursor()
826
+ cur.execute(
827
+ "SELECT sequence FROM event_stream WHERE session_id = ? AND checkpoint_name = ? ORDER BY sequence DESC LIMIT 1;",
828
+ (session_id, checkpoint_name)
829
+ )
830
+ row = cur.fetchone()
831
+ if not row:
832
+ cur.close()
833
+ raise ValueError(f"Checkpoint '{checkpoint_name}' not found for session '{session_id}'.")
833
834
 
834
- cp_seq = row["sequence"]
835
- # Delete events after this checkpoint sequence
836
- cur.execute(
837
- "DELETE FROM event_stream WHERE session_id = ? AND sequence > ?;",
838
- (session_id, cp_seq)
839
- )
840
- cur.close()
835
+ cp_seq = row["sequence"]
836
+ # Atomically delete events after this checkpoint sequence
837
+ cur.execute(
838
+ "DELETE FROM event_stream WHERE session_id = ? AND sequence > ?;",
839
+ (session_id, cp_seq)
840
+ )
841
+ cur.close()
841
842
 
842
- # Record rollback event
843
- return self.record_event(
844
- session_id=session_id,
845
- event_type="ROLLBACK_EXECUTED",
846
- actor="system",
847
- stage="ROLLBACK_CONTROLLER",
848
- payload={"target_checkpoint": checkpoint_name, "reverted_to_sequence": cp_seq}
849
- )
843
+ # Record rollback audit event within the exact same atomic transaction
844
+ return self.record_event(
845
+ session_id=session_id,
846
+ event_type="ROLLBACK_EXECUTED",
847
+ actor="system",
848
+ stage="ROLLBACK_CONTROLLER",
849
+ payload={"target_checkpoint": checkpoint_name, "reverted_to_sequence": cp_seq}
850
+ )
850
851
 
851
852
  # ---------------------------------------------------------------------------
852
853
  # Diagnostics & Lifecycle
@@ -119,20 +119,30 @@ def kill_process_tree(pid: int, timeout: float = 2.0) -> bool:
119
119
  _ = err
120
120
 
121
121
  try:
122
- pgid = os.getpgid(pid)
122
+ caller_pgrp = os.getpgrp() if hasattr(os, "getpgrp") else None
123
+ candidate_pgid = os.getpgid(pid)
124
+ # Only signal process group if target process is its own group leader
125
+ # AND it is not the supervisor/caller's own process group
126
+ if candidate_pgid == pid and (caller_pgrp is None or candidate_pgid != caller_pgrp):
127
+ pgid = candidate_pgid
128
+ else:
129
+ pgid = None
123
130
  except OSError as err:
124
131
  _ = err
125
132
  pgid = None
126
133
 
134
+ sig_term = getattr(signal, "SIGTERM", 15)
135
+ sig_kill = getattr(signal, "SIGKILL", 9)
136
+
127
137
  # Stage 1: Graceful SIGTERM to process group and individual descendants
128
138
  if pgid is not None:
129
139
  try:
130
- os.killpg(pgid, signal.SIGTERM)
140
+ os.killpg(pgid, sig_term)
131
141
  except OSError as err:
132
142
  _ = err
133
143
  for p in [pid] + descendant_pids:
134
144
  try:
135
- os.kill(p, signal.SIGTERM)
145
+ os.kill(p, sig_term)
136
146
  except OSError as err:
137
147
  _ = err
138
148
 
@@ -159,12 +169,12 @@ def kill_process_tree(pid: int, timeout: float = 2.0) -> bool:
159
169
  # Stage 2: Forceful SIGKILL to eradicate all remaining processes
160
170
  for p in descendant_pids + [pid]:
161
171
  try:
162
- os.kill(p, signal.SIGKILL)
172
+ os.kill(p, sig_kill)
163
173
  except OSError as err:
164
174
  _ = err
165
175
  if pgid is not None:
166
176
  try:
167
- os.killpg(pgid, signal.SIGKILL)
177
+ os.killpg(pgid, sig_kill)
168
178
  except OSError as err:
169
179
  _ = err
170
180
  try:
@@ -174,11 +184,22 @@ def kill_process_tree(pid: int, timeout: float = 2.0) -> bool:
174
184
  return True
175
185
 
176
186
 
177
- def reap_orphan_processes(target_names: Optional[Tuple[str, ...]] = None) -> int:
187
+ def reap_orphan_processes(
188
+ target_names: Optional[Tuple[str, ...]] = None,
189
+ allow_system_wide: bool = False,
190
+ tracked_pids: Optional[List[int]] = None
191
+ ) -> int:
178
192
  """
179
193
  Safeguard reaper for orphaned runner and browser processes.
180
194
  Defaults to known test drivers: chromedriver, chromium, node, java.
181
- Returns the count of reaped processes.
195
+
196
+ Safety Invariants:
197
+ 1. Only reaps genuine orphaned processes whose parent process has died (on Windows:
198
+ not psutil.pid_exists(ppid); on POSIX: ppid == 1 or not psutil.pid_exists(ppid)),
199
+ or processes explicitly matching tracked_pids.
200
+ 2. Blind OS-wide 'taskkill /IM' and 'pkill -f' are eliminated by default to prevent
201
+ killing the developer's active desktop browsers. System-wide fallback requires
202
+ explicit allow_system_wide=True opt-in.
182
203
  """
183
204
  targets = target_names or ("chromedriver", "geckodriver", "chromium", "playwright")
184
205
  reaped = 0
@@ -186,20 +207,38 @@ def reap_orphan_processes(target_names: Optional[Tuple[str, ...]] = None) -> int
186
207
  try:
187
208
  import psutil # type: ignore
188
209
  current_pid = os.getpid()
189
- for proc in psutil.process_iter(attrs=["pid", "name"]):
210
+ for proc in psutil.process_iter(attrs=["pid", "name", "ppid"]):
190
211
  try:
191
212
  pname = (proc.info.get("name") or "").lower()
192
213
  pid = proc.info.get("pid")
193
- if pid and pid != current_pid and any(t in pname for t in targets):
214
+ ppid = proc.info.get("ppid")
215
+ if not pid or pid == current_pid:
216
+ continue
217
+
218
+ if not any(t in pname for t in targets):
219
+ continue
220
+
221
+ is_tracked = bool(tracked_pids and pid in tracked_pids)
222
+ is_orphan = False
223
+ if ppid is not None:
224
+ if sys.platform == "win32":
225
+ is_orphan = not psutil.pid_exists(ppid)
226
+ else:
227
+ is_orphan = (ppid == 1) or (not psutil.pid_exists(ppid))
228
+
229
+ if is_tracked or is_orphan or allow_system_wide:
194
230
  proc.kill()
195
231
  reaped += 1
196
232
  except (psutil.NoSuchProcess, psutil.AccessDenied):
197
233
  continue
198
234
  return reaped
199
- except ImportError as err:
200
- _ = err
235
+ except ImportError:
236
+ _psutil_available = False
237
+
238
+ # Native CLI fallbacks ONLY if explicitly requested via allow_system_wide
239
+ if not allow_system_wide:
240
+ return 0
201
241
 
202
- # Native CLI fallbacks when psutil is not available
203
242
  if sys.platform == "win32":
204
243
  for target in targets:
205
244
  im_name = target if target.endswith(".exe") else f"{target}.exe"
@@ -212,8 +251,8 @@ def reap_orphan_processes(target_names: Optional[Tuple[str, ...]] = None) -> int
212
251
  )
213
252
  if res.returncode == 0:
214
253
  reaped += 1
215
- except Exception as err:
216
- _ = err
254
+ except Exception:
255
+ continue
217
256
  else:
218
257
  for target in targets:
219
258
  try:
@@ -225,8 +264,8 @@ def reap_orphan_processes(target_names: Optional[Tuple[str, ...]] = None) -> int
225
264
  )
226
265
  if res.returncode == 0:
227
266
  reaped += 1
228
- except Exception as err:
229
- _ = err
267
+ except Exception:
268
+ continue
230
269
  return reaped
231
270
 
232
271
 
@@ -202,6 +202,19 @@ def create_trace_context(
202
202
  )
203
203
 
204
204
 
205
+ RESERVED_KEYS = {
206
+ "timestamp",
207
+ "level",
208
+ "trace_id",
209
+ "span_id",
210
+ "parent_span_id",
211
+ "module",
212
+ "event",
213
+ "duration_ms",
214
+ "exception",
215
+ }
216
+
217
+
205
218
  class StructuredJsonFormatter(logging.Formatter):
206
219
  """
207
220
  Formats log records into structured JSON conforming to enterprise schema:
@@ -221,9 +234,17 @@ class StructuredJsonFormatter(logging.Formatter):
221
234
  "duration_ms": getattr(record, "duration_ms", None),
222
235
  }
223
236
 
224
- # Include custom extra fields
237
+ # Include custom extra fields safely without overwriting reserved system schema
225
238
  if hasattr(record, "extra_payload") and isinstance(record.extra_payload, dict):
226
- record_dict.update(record.extra_payload)
239
+ attrs = {}
240
+ for k, v in record.extra_payload.items():
241
+ if k in RESERVED_KEYS:
242
+ attrs[k] = v
243
+ else:
244
+ record_dict[k] = v
245
+ attrs[k] = v
246
+ if attrs:
247
+ record_dict["attributes"] = attrs
227
248
 
228
249
  # Include exception if present
229
250
  if record.exc_info:
@@ -267,7 +288,15 @@ def log_event(
267
288
  "duration_ms": duration_ms,
268
289
  }
269
290
  if extra_payload:
270
- payload.update(extra_payload)
291
+ attrs = {}
292
+ for k, v in extra_payload.items():
293
+ if k in RESERVED_KEYS:
294
+ attrs[k] = v
295
+ else:
296
+ payload[k] = v
297
+ attrs[k] = v
298
+ if attrs:
299
+ payload["attributes"] = attrs
271
300
 
272
301
  lvl_num = getattr(logging, level.upper(), logging.INFO)
273
302
  logger = get_logger(logger_name)
@@ -1348,7 +1348,7 @@ def _build_target_translations(
1348
1348
  "th_step_status": "Trแบกng Thรกi",
1349
1349
  "th_step_details": "Chi Tiแบฟt Kแปน Thuแบญt (OTel & AST)",
1350
1350
 
1351
- "footer_text": "Bรกo cรกo ฤ‘ฦฐแปฃc khแปŸi tแบกo tแปฑ ฤ‘แป™ng bแปŸi Synapse-Hub v3.9.0 • Bแบฃn quyแปn © Thแบฟ Vแป‹ (@TeeVee98) • Chuแบฉn Clean POM & Kiแปƒm Thแปญ Tแปฑ Chแปง",
1351
+ "footer_text": "Bรกo cรกo ฤ‘ฦฐแปฃc khแปŸi tแบกo tแปฑ ฤ‘แป™ng bแปŸi Synapse-Hub v3.10.0 • Bแบฃn quyแปn © Thแบฟ Vแป‹ (@TeeVee98) • Chuแบฉn Clean POM & Kiแปƒm Thแปญ Tแปฑ Chแปง",
1352
1352
  }
1353
1353
 
1354
1354
  translations_en = {
@@ -1426,7 +1426,7 @@ def _build_target_translations(
1426
1426
  "th_step_status": "Status",
1427
1427
  "th_step_details": "Technical Details (OTel & AST)",
1428
1428
 
1429
- "footer_text": "Generated automatically by Synapse-Hub v3.9.0 • Copyright © Thแบฟ Vแป‹ (@TeeVee98) • Clean POM & Autonomous Testing",
1429
+ "footer_text": "Generated automatically by Synapse-Hub v3.10.0 • Copyright © Thแบฟ Vแป‹ (@TeeVee98) • Clean POM & Autonomous Testing",
1430
1430
  }
1431
1431
 
1432
1432
  _inject_gate_translations(translations_vi, translations_en, gates)
@@ -1915,7 +1915,7 @@ def _build_hub_translations(
1915
1915
  """Builds bilingual dictionaries for Hub Dashboard."""
1916
1916
  translations_vi = {
1917
1917
  "header_title": "Bแบฃng ฤiแปu Hร nh Chแบฅt Lฦฐแปฃng Doanh Nghiแป‡p",
1918
- "header_subtitle": "Synapse-Hub v3.9.0 • Hแป‡ Sinh Thรกi Kiแปƒm Thแปญ AI Agent Tแปฑ Chแปง",
1918
+ "header_subtitle": "Synapse-Hub v3.10.0 • Hแป‡ Sinh Thรกi Kiแปƒm Thแปญ AI Agent Tแปฑ Chแปง",
1919
1919
  "nav_welcome": "Giแป›i Thiแป‡u",
1920
1920
  "meta_mode": "๐Ÿท๏ธ Chแบฟ ฤ‘แป™: <strong>Hแป† SINH THรI QA HUB</strong>",
1921
1921
  "meta_gen": f"๐Ÿ•’ KhแปŸi tแบกo: <strong>{now_str}</strong>",
@@ -1985,12 +1985,12 @@ def _build_hub_translations(
1985
1985
  "th_sk_ver": "Phiรชn Bแบฃn",
1986
1986
  "th_sk_cap": "Khแบฃ Nฤƒng Nghiแป‡p Vแปฅ Cแป‘t Lรตi",
1987
1987
 
1988
- "footer_text": "Bแบฃng ฤiแปu Hร nh Chแบฅt Lฦฐแปฃng Doanh Nghiแป‡p &bull; Synapse-Hub v3.9.0 &bull; Bแบฃn quyแปn &copy; Thแบฟ Vแป‹ (@TeeVee98) &bull; Hแป‡ Thแป‘ng Kiแปƒm Thแปญ AI Agent Tแปฑ Chแปง",
1988
+ "footer_text": "Bแบฃng ฤiแปu Hร nh Chแบฅt Lฦฐแปฃng Doanh Nghiแป‡p &bull; Synapse-Hub v3.10.0 &bull; Bแบฃn quyแปn &copy; Thแบฟ Vแป‹ (@TeeVee98) &bull; Hแป‡ Thแป‘ng Kiแปƒm Thแปญ AI Agent Tแปฑ Chแปง",
1989
1989
  }
1990
1990
 
1991
1991
  translations_en = {
1992
1992
  "header_title": "Enterprise QA Executive Dashboard",
1993
- "header_subtitle": "Synapse-Hub v3.9.0 &bull; Autonomous AI Agent Testing Ecosystem",
1993
+ "header_subtitle": "Synapse-Hub v3.10.0 &bull; Autonomous AI Agent Testing Ecosystem",
1994
1994
  "nav_welcome": "Welcome",
1995
1995
  "meta_mode": "๐Ÿท๏ธ Mode: <strong>QA HUB ECOSYSTEM</strong>",
1996
1996
  "meta_gen": f"๐Ÿ•’ Generated: <strong>{now_str}</strong>",
@@ -2060,7 +2060,7 @@ def _build_hub_translations(
2060
2060
  "th_sk_ver": "Version",
2061
2061
  "th_sk_cap": "Core Capabilities",
2062
2062
 
2063
- "footer_text": "Enterprise QA Executive Dashboard &bull; Synapse-Hub v3.9.0 &bull; Copyright &copy; Thแบฟ Vแป‹ (@TeeVee98) &bull; Autonomous AI Agent Testing Ecosystem",
2063
+ "footer_text": "Enterprise QA Executive Dashboard &bull; Synapse-Hub v3.10.0 &bull; Copyright &copy; Thแบฟ Vแป‹ (@TeeVee98) &bull; Autonomous AI Agent Testing Ecosystem",
2064
2064
  }
2065
2065
 
2066
2066
  _inject_gate_translations(translations_vi, translations_en, gates)
@@ -345,15 +345,32 @@ class DBSandbox:
345
345
  "zero_pollution_verified": count_after_rollback == 0
346
346
  }
347
347
  except Exception as e:
348
+ rollback_err_msg = None
349
+ count_after_rollback = None
348
350
  try:
349
351
  cursor.execute(f"ROLLBACK TO SAVEPOINT {safe_sp};")
350
- except sqlite3.Error as rollback_err:
352
+ if target_table:
353
+ safe_tbl = target_table.replace('"', '""')
354
+ cursor.execute(f'SELECT COUNT(*) FROM "{safe_tbl}"')
355
+ count_after_rollback = cursor.fetchone()[0]
356
+ except Exception as rollback_err:
357
+ rollback_err_msg = str(rollback_err)
351
358
  sys.stderr.write(f"Notice: Savepoint rollback notice: {rollback_err}\n")
352
- return {
359
+
360
+ zero_verified = (rollback_err_msg is None)
361
+ if count_after_rollback is not None and count_after_rollback > 0:
362
+ zero_verified = False
363
+
364
+ res = {
353
365
  "status": "ERROR",
354
366
  "error": str(e),
355
- "zero_pollution_verified": True
367
+ "zero_pollution_verified": zero_verified
356
368
  }
369
+ if rollback_err_msg:
370
+ res["rollback_error"] = rollback_err_msg
371
+ if count_after_rollback is not None:
372
+ res["count_after_rollback"] = count_after_rollback
373
+ return res
357
374
  finally:
358
375
  conn.close()
359
376
 
@@ -368,7 +385,7 @@ class DBSandbox:
368
385
  def audit_and_purge_pollution(
369
386
  self,
370
387
  known_test_prefixes: Tuple[str, ...] = ("AUTO_", "TEST_", "TEMP_"),
371
- dry_run: bool = False
388
+ dry_run: bool = True
372
389
  ) -> Dict[str, Any]:
373
390
  """
374
391
  Scans all tables for orphan records carrying test prefixes and purges them.
@@ -558,10 +575,12 @@ def main():
558
575
  snap_p.add_argument("--json", action="store_true", help="Output JSON format")
559
576
 
560
577
  # Command: restore
561
- rest_p = subparsers.add_parser("restore", help="Restore pristine snapshot")
578
+ rest_p = subparsers.add_parser("restore", help="Restore pristine snapshot (DESTRUCTIVE)")
562
579
  rest_p.add_argument("--db-path", default="", help="Path to database file or network URI")
563
580
  rest_p.add_argument("--db-type", default="", help="Database engine type (sqlite, postgres, mysql, oracle)")
564
581
  rest_p.add_argument("--id", default="pristine_baseline", help="Snapshot identifier")
582
+ rest_p.add_argument("--confirm", action="store_true", default=False,
583
+ help="Explicit confirmation for destructive restore operation")
565
584
  rest_p.add_argument("--json", action="store_true", help="Output JSON format")
566
585
 
567
586
  # Command: rollback-test
@@ -572,10 +591,13 @@ def main():
572
591
  roll_p.add_argument("--json", action="store_true", help="Output JSON format")
573
592
 
574
593
  # Command: audit
575
- aud_p = subparsers.add_parser("audit", help="Audit orphan test junk and purge")
594
+ aud_p = subparsers.add_parser("audit", help="Audit orphan test junk and purge (Safe dry-run by default)")
576
595
  aud_p.add_argument("--db-path", default="", help="Path to database file")
577
596
  aud_p.add_argument("--db-type", default="", help="Database engine type (sqlite, postgres, mysql)")
578
- aud_p.add_argument("--dry-run", action="store_true", help="Preview test records to purge without deleting")
597
+ aud_p.add_argument("--dry-run", action="store_true", default=None,
598
+ help="Preview test records to purge without deleting (default: True)")
599
+ aud_p.add_argument("--apply", "--force", dest="apply", action="store_true", default=False,
600
+ help="Explicitly apply destructive purge to delete matching test records")
579
601
  aud_p.add_argument("--json", action="store_true", help="Output JSON format")
580
602
 
581
603
  # Command: wait-ready (Testcontainers-style readiness gate)
@@ -625,6 +647,24 @@ def main():
625
647
  return 0 if res.get("status") != "ERROR" else 1
626
648
 
627
649
  elif args.command == "restore":
650
+ if not args.confirm and not os.environ.get("SYNAPSE_FORCE_RESTORE"):
651
+ err_msg = (
652
+ "Refusing to execute destructive database restore without explicit confirmation. "
653
+ "Pass --confirm (or set SYNAPSE_FORCE_RESTORE=1) if target is an isolated sandbox."
654
+ )
655
+ res = {
656
+ "status": "ERROR",
657
+ "message": err_msg,
658
+ "snapshot_id": args.id,
659
+ "target_db": sandbox.db_path,
660
+ "zero_pollution_guaranteed": False
661
+ }
662
+ if args.json:
663
+ print(json.dumps(res, indent=2))
664
+ else:
665
+ print(f"โŒ [DB RESTORE BLOCKED] ID: {args.id}")
666
+ print(f" Error: {err_msg}")
667
+ return 1
628
668
  res = sandbox.restore_snapshot(args.id)
629
669
  if args.json:
630
670
  print(json.dumps(res, indent=2))
@@ -654,15 +694,18 @@ def main():
654
694
  return 0
655
695
 
656
696
  elif args.command == "audit":
657
- res = sandbox.audit_and_purge_pollution(dry_run=args.dry_run)
697
+ effective_dry_run = True if args.dry_run is None else args.dry_run
698
+ if args.apply:
699
+ effective_dry_run = False
700
+ res = sandbox.audit_and_purge_pollution(dry_run=effective_dry_run)
658
701
  if args.json:
659
702
  print(json.dumps(res, indent=2))
660
703
  else:
661
- action_label = "Previewed" if args.dry_run else "Purged"
704
+ action_label = "Previewed" if effective_dry_run else "Purged"
662
705
  print(f"๐Ÿงน [TAINT POLLUTION AUDIT] {action_label} {res['total_purged_rows']} orphan test records.")
663
706
  for detail in res.get("purge_details", []):
664
707
  print(f" - {detail}")
665
- if not args.dry_run:
708
+ if not effective_dry_run:
666
709
  print(" โœ… Zero Pollution Achieved.")
667
710
  return 0
668
711
 
@@ -60,7 +60,7 @@ if hasattr(sys.stdout, 'reconfigure'):
60
60
  except Exception:
61
61
  pass
62
62
 
63
- SERVER_VERSION = "3.9.0"
63
+ SERVER_VERSION = "3.10.0"
64
64
  MAX_DOCX_SIZE = 50 * 1024 * 1024 # 50 MB
65
65
  MAX_UNCOMPRESSED_SIZE = 200 * 1024 * 1024 # 200 MB
66
66
  MAX_RATIO = 100 # 100:1 compression ratio limit
@@ -52,7 +52,7 @@ if hasattr(sys.stdout, 'reconfigure'):
52
52
  except Exception:
53
53
  pass
54
54
 
55
- SERVER_VERSION = "3.9.0"
55
+ SERVER_VERSION = "3.10.0"
56
56
  MAX_XLSX_SIZE = 50 * 1024 * 1024 # 50 MB
57
57
  MAX_UNCOMPRESSED_SIZE = 200 * 1024 * 1024 # 200 MB
58
58
  MAX_RATIO = 100 # 100:1 compression ratio limit
@@ -46,7 +46,7 @@ import gherkin_suite
46
46
  import api_fuzzer
47
47
 
48
48
  SERVER_NAME = "enterprise-agent-qa"
49
- SERVER_VERSION = "3.9.0"
49
+ SERVER_VERSION = "3.10.0"
50
50
 
51
51
  MCP_TOOLS = [
52
52
  {
@@ -24,6 +24,7 @@ Usage:
24
24
 
25
25
  import os
26
26
  import sys
27
+ import re
27
28
  import json
28
29
  import zipfile
29
30
  import tarfile
@@ -136,6 +137,16 @@ def collect_package_files(repo_root: str) -> List[Tuple[str, str]]:
136
137
  continue
137
138
 
138
139
  full_path = os.path.join(root, f)
140
+ # Symlink escape guard: verify file does not resolve outside repository root
141
+ real_file = os.path.realpath(full_path)
142
+ real_root_dir = os.path.realpath(repo_root)
143
+ try:
144
+ if os.path.commonpath([real_file, real_root_dir]) != real_root_dir:
145
+ sys.stderr.write(f"Warning: Skipping symlink escaping repo root: {full_path} -> {real_file}\n")
146
+ continue
147
+ except (ValueError, OSError):
148
+ continue
149
+
139
150
  rel_path = os.path.relpath(full_path, repo_root).replace("\\", "/")
140
151
  packaged_files.append((full_path, rel_path))
141
152
 
@@ -217,20 +228,33 @@ def package_synapse_hub(
217
228
  out_dir = os.path.join(repo_root, output_dir)
218
229
  os.makedirs(out_dir, exist_ok=True)
219
230
 
220
- # 1. Clean up old archives in dist and repo_root
231
+ # 1. Clean up old release archives safely (guarded against repo root wildcard deletion)
232
+ is_same_as_root = False
233
+ try:
234
+ is_same_as_root = os.path.samefile(out_dir, repo_root)
235
+ except (FileNotFoundError, OSError, ValueError):
236
+ is_same_as_root = os.path.realpath(out_dir).lower() == os.path.realpath(repo_root).lower()
237
+
221
238
  for f in os.listdir(out_dir):
222
- if f.endswith((".zip", ".tar.gz", ".sha256")):
239
+ if re.match(r"^synapse-hub-v\d+\.\d+\.\d+.*", f, re.IGNORECASE) and f.endswith((".zip", ".tar.gz", ".sha256")):
223
240
  try:
224
241
  os.remove(os.path.join(out_dir, f))
225
242
  except OSError as err:
226
243
  _ = err
227
- for f in os.listdir(repo_root):
228
- if f.lower().startswith("synapse-hub") and f.endswith(".zip"):
244
+ elif not is_same_as_root and f.endswith((".zip", ".tar.gz", ".sha256")) and f.lower().startswith("synapse-hub"):
229
245
  try:
230
- os.remove(os.path.join(repo_root, f))
246
+ os.remove(os.path.join(out_dir, f))
231
247
  except OSError as err:
232
248
  _ = err
233
249
 
250
+ if not is_same_as_root:
251
+ for f in os.listdir(repo_root):
252
+ if re.match(r"^synapse-hub-v\d+\.\d+\.\d+.*", f, re.IGNORECASE) and f.endswith((".zip", ".tar.gz", ".sha256")):
253
+ try:
254
+ os.remove(os.path.join(repo_root, f))
255
+ except OSError as err:
256
+ _ = err
257
+
234
258
  files = collect_package_files(repo_root)
235
259
  base_name = f"synapse-hub-v{version}"
236
260
  created_archives: List[str] = []