Step 4A-6-C-R3.2.2 Executor Relay Integration

#12
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ core/__pycache__/pipeline_agent.cpython-313.pyc filter=lfs diff=lfs merge=lfs -text
__pycache__/app.cpython-313.pyc ADDED
Binary file (42.4 kB). View file
 
__pycache__/config.cpython-313.pyc ADDED
Binary file (23.2 kB). View file
 
__pycache__/desktop.ini ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [.ShellClassInfo]
2
+ IconResource=C:\Program Files\Google\Drive File Stream\129.0.1.0\GoogleDriveFS.exe,27
__pycache__/i18n.cpython-313.pyc ADDED
Binary file (70.5 kB). View file
 
__pycache__/managed_auth.cpython-313.pyc ADDED
Binary file (31 kB). View file
 
__pycache__/task_executor.cpython-313.pyc ADDED
Binary file (30.9 kB). View file
 
core/__pycache__/checkpoint_store.cpython-313.pyc ADDED
Binary file (4.63 kB). View file
 
core/__pycache__/desktop.ini ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [.ShellClassInfo]
2
+ IconResource=C:\Program Files\Google\Drive File Stream\129.0.1.0\GoogleDriveFS.exe,27
core/__pycache__/generation_runner.cpython-313.pyc ADDED
Binary file (34.2 kB). View file
 
core/__pycache__/meta_extractor.cpython-313.pyc ADDED
Binary file (3.43 kB). View file
 
core/__pycache__/pipeline_agent.cpython-313.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:185a6cfe4441c00b83aab3c8b7990c30043a17525472b3d01b78350d99d8e2b7
3
+ size 158928
core/__pycache__/production_guard.cpython-313.pyc ADDED
Binary file (11 kB). View file
 
core/__pycache__/qualitative_engine.cpython-313.pyc ADDED
Binary file (9.81 kB). View file
 
core/__pycache__/quantitative_engine.cpython-313.pyc ADDED
Binary file (10.1 kB). View file
 
core/__pycache__/rag_engine.cpython-313.pyc ADDED
Binary file (4.36 kB). View file
 
smartpaper_restore_bridge/__pycache__/__init__.cpython-313.pyc ADDED
Binary file (3.13 kB). View file
 
smartpaper_restore_bridge/__pycache__/desktop.ini ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [.ShellClassInfo]
2
+ IconResource=C:\Program Files\Google\Drive File Stream\129.0.1.0\GoogleDriveFS.exe,27
task_executor.py CHANGED
@@ -1,5 +1,5 @@
1
  # -*- coding: utf-8 -*-
2
- """SmartPaper R3.2.1 independent task executor.
3
 
4
  Bootstrap is intentionally lightweight: the child process validates the local
5
  request, claims the D1 task, writes a local claim handshake, and only then
@@ -43,6 +43,7 @@ logging.basicConfig(
43
 
44
 
45
  CLAIM_HANDSHAKE_FILENAME = "executor_claim.json"
 
46
 
47
 
48
  def _bounded_env_float(name: str, default: float, minimum: float, maximum: float) -> float:
@@ -82,10 +83,12 @@ def _safe(value, limit=500):
82
 
83
 
84
  def _api_origin() -> str:
85
- value = str(os.environ.get("SMARTPAPER_AUTH_API") or "").strip().rstrip("/")
 
 
86
  parsed = urlsplit(value)
87
  if parsed.scheme != "https" or not parsed.netloc or parsed.path not in ("", "/") or parsed.query or parsed.fragment:
88
- raise RuntimeError("SMARTPAPER_AUTH_API_invalid")
89
  return f"https://{parsed.netloc}"
90
 
91
 
@@ -147,12 +150,11 @@ class ExecutorApi:
147
  "Authorization": f"Bearer {_service_key()}",
148
  "Accept": "application/json",
149
  "Content-Type": "application/json",
150
- "User-Agent": "SmartPaper-R3.2.1-Executor/1.0",
151
  }
152
- # HF Spaces can expose environment proxy settings that are less reliable
153
- # for direct TLS handshakes to workers.dev. Reuse the proven SmartPaper
154
- # transport policy: direct networking first, environment-aware networking
155
- # only as a transport fallback. Business/HTTP errors never trigger fallback.
156
  self._direct_session = requests.Session()
157
  self._direct_session.trust_env = False
158
  self._environment_session = requests.Session()
 
1
  # -*- coding: utf-8 -*-
2
+ """SmartPaper R3.2.2 independent task executor.
3
 
4
  Bootstrap is intentionally lightweight: the child process validates the local
5
  request, claims the D1 task, writes a local claim handshake, and only then
 
43
 
44
 
45
  CLAIM_HANDSHAKE_FILENAME = "executor_claim.json"
46
+ EXECUTOR_API_DEFAULT = "https://smartpaper-auth-relay-pages.pages.dev"
47
 
48
 
49
  def _bounded_env_float(name: str, default: float, minimum: float, maximum: float) -> float:
 
83
 
84
 
85
  def _api_origin() -> str:
86
+ # Executor traffic intentionally uses the Pages Service-Binding relay.
87
+ # Browser/auth traffic continues to use SMARTPAPER_AUTH_API elsewhere.
88
+ value = str(os.environ.get("SMARTPAPER_EXECUTOR_API") or EXECUTOR_API_DEFAULT).strip().rstrip("/")
89
  parsed = urlsplit(value)
90
  if parsed.scheme != "https" or not parsed.netloc or parsed.path not in ("", "/") or parsed.query or parsed.fragment:
91
+ raise RuntimeError("SMARTPAPER_EXECUTOR_API_invalid")
92
  return f"https://{parsed.netloc}"
93
 
94
 
 
150
  "Authorization": f"Bearer {_service_key()}",
151
  "Accept": "application/json",
152
  "Content-Type": "application/json",
153
+ "User-Agent": "SmartPaper-R3.2.2-Executor/1.0",
154
  }
155
+ # Keep direct networking first for the relay endpoint, with the ordinary
156
+ # environment-aware session only as a transport fallback. Business/HTTP
157
+ # errors never trigger fallback.
 
158
  self._direct_session = requests.Session()
159
  self._direct_session.trust_env = False
160
  self._environment_session = requests.Session()
utils/__pycache__/desktop.ini ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [.ShellClassInfo]
2
+ IconResource=C:\Program Files\Google\Drive File Stream\129.0.1.0\GoogleDriveFS.exe,27
utils/__pycache__/docx_builder.cpython-313.pyc ADDED
Binary file (9.39 kB). View file
 
utils/__pycache__/file_parser.cpython-313.pyc ADDED
Binary file (8.02 kB). View file