@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.
- package/.agents/rules/git-push-protocol.md +1 -1
- package/.agents/rules/mandatory-playwright-live.md +4 -2
- package/.agents/rules/mobile_appium_rules.md +14 -39
- package/.agents/rules/security_testing_rules.md +24 -0
- package/.agents/rules/stack-auto-router.md +17 -0
- package/.agents/rules/systematic-debugging.md +9 -8
- package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +9 -4
- package/.agents/skills/playwright-webapp-testing/SKILL.md +6 -4
- package/.agents/skills/token-and-context-optimizer/SKILL.md +1 -1
- package/.cursor/rules/agents.mdc +1 -1
- package/AGENTS.md +2 -1
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/agentskills.json +1 -1
- package/docs/ARCHITECTURE.en.md +1 -1
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CLI_REFERENCE.en.md +7 -11
- package/docs/CLI_REFERENCE.md +7 -11
- package/docs/QUALITY_GATES.en.md +5 -5
- package/docs/QUALITY_GATES.md +5 -5
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/scripts/install.ps1 +1 -1
- package/scripts/install_global_plugin.ps1 +19 -2
- package/scripts/install_global_plugin.sh +21 -2
- package/skills_manifest.json +1 -1
- package/synapse.config.json +1 -1
- package/tools/TOOL_CATALOG.json +1 -1
- package/tools/__init__.py +1 -1
- package/tools/browser_helpers.js +2 -2
- package/tools/cli.py +3 -3
- package/tools/core/memory_bus.py +25 -24
- package/tools/core/process_supervisor.py +55 -16
- package/tools/core/telemetry.py +32 -3
- package/tools/dashboard_generator.py +6 -6
- package/tools/db_sandbox.py +53 -10
- package/tools/mcp_docx_server.py +1 -1
- package/tools/mcp_excel_server.py +1 -1
- package/tools/mcp_server.py +1 -1
- package/tools/package_release.py +29 -5
- package/tools/reversible_sandbox.py +85 -7
- package/tools/ui_server.py +1 -1
- package/tools/update_sentinel.py +3 -3
- 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.
|
|
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.
|
|
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.
|
|
690
|
+
version = "3.10.0"
|
|
691
691
|
return version
|
|
692
692
|
|
|
693
693
|
|
package/tools/core/memory_bus.py
CHANGED
|
@@ -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
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
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
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
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
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
200
|
-
|
|
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
|
|
216
|
-
|
|
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
|
|
229
|
-
|
|
267
|
+
except Exception:
|
|
268
|
+
continue
|
|
230
269
|
return reaped
|
|
231
270
|
|
|
232
271
|
|
package/tools/core/telemetry.py
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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 • Synapse-Hub v3.
|
|
1988
|
+
"footer_text": "Bแบฃng ฤiแปu Hร nh Chแบฅt Lฦฐแปฃng Doanh Nghiแปp • Synapse-Hub v3.10.0 • Bแบฃn quyแปn © Thแบฟ Vแป (@TeeVee98) • 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.
|
|
1993
|
+
"header_subtitle": "Synapse-Hub v3.10.0 • 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 • Synapse-Hub v3.
|
|
2063
|
+
"footer_text": "Enterprise QA Executive Dashboard • Synapse-Hub v3.10.0 • Copyright © Thแบฟ Vแป (@TeeVee98) • Autonomous AI Agent Testing Ecosystem",
|
|
2064
2064
|
}
|
|
2065
2065
|
|
|
2066
2066
|
_inject_gate_translations(translations_vi, translations_en, gates)
|
package/tools/db_sandbox.py
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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":
|
|
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 =
|
|
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",
|
|
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
|
-
|
|
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
|
|
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
|
|
708
|
+
if not effective_dry_run:
|
|
666
709
|
print(" โ
Zero Pollution Achieved.")
|
|
667
710
|
return 0
|
|
668
711
|
|
package/tools/mcp_docx_server.py
CHANGED
|
@@ -60,7 +60,7 @@ if hasattr(sys.stdout, 'reconfigure'):
|
|
|
60
60
|
except Exception:
|
|
61
61
|
pass
|
|
62
62
|
|
|
63
|
-
SERVER_VERSION = "3.
|
|
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.
|
|
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
|
package/tools/mcp_server.py
CHANGED
package/tools/package_release.py
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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(
|
|
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] = []
|