dellweb3 commited on
Commit
5fd201e
·
verified ·
1 Parent(s): caf8059

Deploy verified conversational workbench and isolated Java application previews

Browse files

Source baseline: cafd304fccf076e7bf04a2f18bb5b60df4713c91. Credentials are runtime Secrets only.

AGENTS.md CHANGED
@@ -10,6 +10,8 @@ HF令牌仅从用户明确指定文件读取,在`.local/huggingface/token.dpap
10
 
11
  2026-10-24用户随后明确回复“允许将百炼密钥写入”,并要求先验证、再上传。允许仅把已授权百炼密钥写入指定`dellweb3/VibeCoding`空间的`DASHSCOPE_API_KEY`服务端Secret;不扩展至其他空间,不写源码/镜像/本地明文,不改变原WorkOS文件。模型端点沿用同一已批准配置。本次Space数据实例配置最多60次物理模型请求,单任务既有预算不变;测试调用也计入,临时磁盘重建会重置实例计数,不能宣称持久账单上限。发布前完成本地门禁,发布后再验真实云端生成和网站操作,不能把容器启动当成完成。
12
 
 
 
13
  ## 生成应用的用户界面约束(2026-10-24最新)
14
 
15
  用户要求点击预览后由平台内部完成准备与发布,8791只展示可操作的完成应用,不展示沙箱启动步骤、控制通道、原始接口JSON、源码摘要、验证回执或制品下载等调试信息。这些内容保留在8789工作台的源码、差异和运行记录中,不删除真实证据。正常预览按钮不再弹出技术侧栏或启动诊断页面;在原按钮提供简短等待反馈,准备完成后显示业务应用。旧保存链接兼容简短打开提示,不再展示技术信息。
 
10
 
11
  2026-10-24用户随后明确回复“允许将百炼密钥写入”,并要求先验证、再上传。允许仅把已授权百炼密钥写入指定`dellweb3/VibeCoding`空间的`DASHSCOPE_API_KEY`服务端Secret;不扩展至其他空间,不写源码/镜像/本地明文,不改变原WorkOS文件。模型端点沿用同一已批准配置。本次Space数据实例配置最多60次物理模型请求,单任务既有预算不变;测试调用也计入,临时磁盘重建会重置实例计数,不能宣称持久账单上限。发布前完成本地门禁,发布后再验真实云端生成和网站操作,不能把容器启动当成完成。
12
 
13
+ HF嵌入页到新窗口的Cookie分区必须单独验证。云端预览传输可使用经会话/CSRF授权、实际弹窗随机证明、一次消费且60秒有效的交接;令牌只经HttpOnly Cookie设置,不进入JS/URL/日志。不得改本机原runtime文件或主布局来绕过这一问题;不得取消身份、制品ACL或CSRF检查。模型生成的已知失败可通过显式关联的新任务继续修复并记录全部调用;未知结果不能自动重放。
14
+
15
  ## 生成应用的用户界面约束(2026-10-24最新)
16
 
17
  用户要求点击预览后由平台内部完成准备与发布,8791只展示可操作的完成应用,不展示沙箱启动步骤、控制通道、原始接口JSON、源码摘要、验证回执或制品下载等调试信息。这些内容保留在8789工作台的源码、差异和运行记录中,不删除真实证据。正常预览按钮不再弹出技术侧栏或启动诊断页面;在原按钮提供简短等待反馈,准备完成后显示业务应用。旧保存链接兼容简短打开提示,不再展示技术信息。
deploy/hf/adapter.py CHANGED
@@ -4,12 +4,13 @@ from urllib.parse import urlsplit
4
 
5
 
6
  class SpaceIngress:
7
- def __init__(self,app,origin,internal_port=7860):
8
  parsed=urlsplit(origin)
9
  if parsed.scheme!='https' or not parsed.hostname or parsed.path not in ('','/') or parsed.query or parsed.fragment or parsed.username or parsed.password:
10
  raise ValueError('INVALID_SPACE_ORIGIN')
11
  self.app,self.origin,self.host=app,origin.rstrip('/'),parsed.netloc
12
  self.internal=f'http://127.0.0.1:{internal_port}';self.internal_host=f'127.0.0.1:{internal_port}'
 
13
 
14
  async def __call__(self,scope,receive,send):
15
  if scope['type']!='http':return await self.app(scope,receive,send)
@@ -17,6 +18,8 @@ class SpaceIngress:
17
  health=method in {'GET','HEAD'} and path in {'/','/health/live'} and host.split(':')[0] in {'127.0.0.1','localhost','0.0.0.0'}
18
  if host!=self.host and not health:return await self.reject(send,400)
19
  if method not in {'GET','HEAD','OPTIONS'} and headers.get(b'origin',b'').decode()!=self.origin:return await self.reject(send,403)
 
 
20
  forwarded=[]
21
  for key,value in scope['headers']:
22
  if key==b'host':value=self.internal_host.encode()
@@ -24,6 +27,7 @@ class SpaceIngress:
24
  forwarded.append((key,value))
25
  inner={**scope,'headers':forwarded,'scheme':'http','server':('127.0.0.1',int(self.internal_host.split(':')[-1]))}
26
  start=None;body=bytearray();rewrite_session=path=='/api/session' and method=='GET'
 
27
  def response_headers(values):
28
  result=[]
29
  for key,value in values:
@@ -36,12 +40,14 @@ class SpaceIngress:
36
  nonlocal start
37
  if message['type']=='http.response.start':
38
  message={**message,'headers':response_headers(message['headers'])}
39
- if rewrite_session and message['status']==200:start=message;return
40
  if start is not None and message['type']=='http.response.body':
41
  body.extend(message.get('body',b''))
42
  if message.get('more_body'):return
43
- value=json.loads(body);value.update(preview_origin=self.origin,workbench_origin=self.origin)
44
- payload=json.dumps(value,ensure_ascii=False).encode()
 
 
45
  start['headers']=[(k,v) for k,v in start['headers'] if k.lower()!=b'content-length']+[(b'content-length',str(len(payload)).encode())]
46
  await send(start);start=None;await send({'type':'http.response.body','body':payload});return
47
  await send(message)
 
4
 
5
 
6
  class SpaceIngress:
7
+ def __init__(self,app,origin,internal_port=7860,*,bridge=None):
8
  parsed=urlsplit(origin)
9
  if parsed.scheme!='https' or not parsed.hostname or parsed.path not in ('','/') or parsed.query or parsed.fragment or parsed.username or parsed.password:
10
  raise ValueError('INVALID_SPACE_ORIGIN')
11
  self.app,self.origin,self.host=app,origin.rstrip('/'),parsed.netloc
12
  self.internal=f'http://127.0.0.1:{internal_port}';self.internal_host=f'127.0.0.1:{internal_port}'
13
+ self.bridge=bridge
14
 
15
  async def __call__(self,scope,receive,send):
16
  if scope['type']!='http':return await self.app(scope,receive,send)
 
18
  health=method in {'GET','HEAD'} and path in {'/','/health/live'} and host.split(':')[0] in {'127.0.0.1','localhost','0.0.0.0'}
19
  if host!=self.host and not health:return await self.reject(send,400)
20
  if method not in {'GET','HEAD','OPTIONS'} and headers.get(b'origin',b'').decode()!=self.origin:return await self.reject(send,403)
21
+ if any(key in headers for key in (b'x-user-id',b'x-tenant-id',b'x-internal-authorization',b'authorization')):return await self.reject(send,400)
22
+ if self.bridge and await self.bridge.handle(scope,receive,send):return
23
  forwarded=[]
24
  for key,value in scope['headers']:
25
  if key==b'host':value=self.internal_host.encode()
 
27
  forwarded.append((key,value))
28
  inner={**scope,'headers':forwarded,'scheme':'http','server':('127.0.0.1',int(self.internal_host.split(':')[-1]))}
29
  start=None;body=bytearray();rewrite_session=path=='/api/session' and method=='GET'
30
+ rewrite_runtime=bool(self.bridge and path=='/runtime.js' and method=='GET')
31
  def response_headers(values):
32
  result=[]
33
  for key,value in values:
 
40
  nonlocal start
41
  if message['type']=='http.response.start':
42
  message={**message,'headers':response_headers(message['headers'])}
43
+ if (rewrite_session or rewrite_runtime) and message['status']==200:start=message;return
44
  if start is not None and message['type']=='http.response.body':
45
  body.extend(message.get('body',b''))
46
  if message.get('more_body'):return
47
+ if rewrite_session:
48
+ value=json.loads(body);value.update(preview_origin=self.origin,workbench_origin=self.origin)
49
+ payload=json.dumps(value,ensure_ascii=False).encode()
50
+ else:payload=self.bridge.patch_runtime(body)
51
  start['headers']=[(k,v) for k,v in start['headers'] if k.lower()!=b'content-length']+[(b'content-length',str(len(payload)).encode())]
52
  await send(start);start=None;await send({'type':'http.response.body','body':payload});return
53
  await send(message)
deploy/hf/app.py CHANGED
@@ -10,6 +10,7 @@ from src.modules.llm_gateway.routing import PROFILES,VERSION
10
  from src.apps.workbench.engine import LocalWorkbench
11
  from src.apps.workbench.web import create_web
12
  from deploy.hf.adapter import SpaceIngress
 
13
 
14
  ROOT=Path(__file__).resolve().parents[2]
15
  ORIGIN='https://dellweb3-vibecoding.hf.space'
@@ -62,4 +63,4 @@ def create_app():
62
  data=ROOT/'.local/hf-runtime';data.mkdir(parents=True,exist_ok=True)
63
  engine=LocalWorkbench(data,providers_from_environment(data),sandbox_capacity=int(os.environ.get('ZKCODING_SANDBOX_CAPACITY','3')))
64
  engine.identity.seed_demo_users();engine.preview_origin=ORIGIN
65
- return SpaceIngress(create_web(engine,7860),ORIGIN)
 
10
  from src.apps.workbench.engine import LocalWorkbench
11
  from src.apps.workbench.web import create_web
12
  from deploy.hf.adapter import SpaceIngress
13
+ from deploy.hf.preview_bridge import PreviewBridge
14
 
15
  ROOT=Path(__file__).resolve().parents[2]
16
  ORIGIN='https://dellweb3-vibecoding.hf.space'
 
63
  data=ROOT/'.local/hf-runtime';data.mkdir(parents=True,exist_ok=True)
64
  engine=LocalWorkbench(data,providers_from_environment(data),sandbox_capacity=int(os.environ.get('ZKCODING_SANDBOX_CAPACITY','3')))
65
  engine.identity.seed_demo_users();engine.preview_origin=ORIGIN
66
+ return SpaceIngress(create_web(engine,7860),ORIGIN,bridge=PreviewBridge(engine))
deploy/hf/package-manifest.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "git_commit": "a11c87282ca17a9d750a7ad5b94317bfb581b78e",
3
  "files": {
4
  ".local/dependencies/pdfbox/3.0.8/pdfbox-app-3.0.8.jar": {
5
  "sha256": "f6b3a80c39747ff0ef5d06708bc03882152403de58dbef4a1fbffbee568eceb1",
@@ -18,16 +18,16 @@
18
  "bytes": 94203974
19
  },
20
  "AGENTS.md": {
21
- "sha256": "412697081abffcec9b59c100c3abc76062ce2bb0eb2094b0bd00ab9afe6f04dc",
22
- "bytes": 19907
23
  },
24
  "deploy/hf/adapter.py": {
25
- "sha256": "09122155052800157b3c45e479b90b9c2a52881052b538b1edf53d7001aa7450",
26
- "bytes": 3649
27
  },
28
  "deploy/hf/app.py": {
29
- "sha256": "d6363ca65d6044d15368eb3d58709b74aa0d072efc7c2a5856c2e81da2c078f3",
30
- "bytes": 3633
31
  },
32
  "deploy/hf/base-vm-manifest.json": {
33
  "sha256": "d3caa63f01a5a0587edf2c514769110023b764005b4c79edc0d21a502dd776ee",
@@ -53,6 +53,22 @@
53
  "sha256": "428c3d895c7af4f5588e0f4ff6b26f2afc2498a670a7059ffe35000301bc4c56",
54
  "bytes": 1226
55
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  "deploy/hf/README.md": {
57
  "sha256": "cdecfa54078b01e20b9763455960a8c5c2326a552ef2195ac5e28038481d77bb",
58
  "bytes": 1187
@@ -158,8 +174,8 @@
158
  "bytes": 777
159
  },
160
  "docs/demo-briefs/calculator.md": {
161
- "sha256": "a29e16392cde8e4612864049716d61e508c9f7294a63b2ac58e4c301862f06c2",
162
- "bytes": 3095
163
  },
164
  "docs/demo-briefs/erp.md": {
165
  "sha256": "3f831ffb4aa94a5235aa8b3c36494115ee74ed8d9ec8f14452e99daedea46beb",
@@ -241,9 +257,13 @@
241
  "sha256": "c9d3987cdd378c614c81aa10de33893a133f7ce5a07b9c96e40711fa54d250a3",
242
  "bytes": 87158
243
  },
 
 
 
 
244
  "examples/hf-ingress-validation.json": {
245
- "sha256": "65142638efb4cea760b1664e01dd3c774fbf2fbcb654b3721fc45ca9cff83544",
246
- "bytes": 2661
247
  },
248
  "examples/multi-sandbox-validation.json": {
249
  "sha256": "a74fba8e0bc5090b4e16ce0493eca0dbe8ba652e07b3c0907a0c3bdda74fa2fb",
 
1
  {
2
+ "git_commit": "cafd304fccf076e7bf04a2f18bb5b60df4713c91",
3
  "files": {
4
  ".local/dependencies/pdfbox/3.0.8/pdfbox-app-3.0.8.jar": {
5
  "sha256": "f6b3a80c39747ff0ef5d06708bc03882152403de58dbef4a1fbffbee568eceb1",
 
18
  "bytes": 94203974
19
  },
20
  "AGENTS.md": {
21
+ "sha256": "82e1acdb86f68dcdf1b7ebd612985be7cb5421acfafb42bd556b97362af9ba40",
22
+ "bytes": 20386
23
  },
24
  "deploy/hf/adapter.py": {
25
+ "sha256": "a3b1b8a4c6e0b0f0c075b9c9bcf453f3c0f6803ac8f69fffe0ae11a625c7e549",
26
+ "bytes": 4131
27
  },
28
  "deploy/hf/app.py": {
29
+ "sha256": "0e8a5729b5e99aae88c277d718e0afa6de21350515f92452996d10deac7612f3",
30
+ "bytes": 3713
31
  },
32
  "deploy/hf/base-vm-manifest.json": {
33
  "sha256": "d3caa63f01a5a0587edf2c514769110023b764005b4c79edc0d21a502dd776ee",
 
53
  "sha256": "428c3d895c7af4f5588e0f4ff6b26f2afc2498a670a7059ffe35000301bc4c56",
54
  "bytes": 1226
55
  },
56
+ "deploy/hf/preview-bridge.html": {
57
+ "sha256": "0f709ec2027d6f623cfa5c4b6aad4f104355895fdc768907b8c6dd31a52b06cc",
58
+ "bytes": 343
59
+ },
60
+ "deploy/hf/preview-bridge.js": {
61
+ "sha256": "4611a08d39699fc9268a01bb25a59c9ad63f21769fcd1e8115949f5a5625512f",
62
+ "bytes": 2040
63
+ },
64
+ "deploy/hf/preview-parent.js": {
65
+ "sha256": "9026145e4394cfb82cb8e59800ef5d70ff09da7d039aa15e92fc158409ea039e",
66
+ "bytes": 2012
67
+ },
68
+ "deploy/hf/preview_bridge.py": {
69
+ "sha256": "d36b827c0e089ca56e19c4c34849a31dfb15128e5b6443c3193da04e99af836d",
70
+ "bytes": 7956
71
+ },
72
  "deploy/hf/README.md": {
73
  "sha256": "cdecfa54078b01e20b9763455960a8c5c2326a552ef2195ac5e28038481d77bb",
74
  "bytes": 1187
 
174
  "bytes": 777
175
  },
176
  "docs/demo-briefs/calculator.md": {
177
+ "sha256": "f6dddab8262f190371f37c2e1a0da5fd4efe9feaff1d823a257a372c00ab5a6e",
178
+ "bytes": 4082
179
  },
180
  "docs/demo-briefs/erp.md": {
181
  "sha256": "3f831ffb4aa94a5235aa8b3c36494115ee74ed8d9ec8f14452e99daedea46beb",
 
257
  "sha256": "c9d3987cdd378c614c81aa10de33893a133f7ce5a07b9c96e40711fa54d250a3",
258
  "bytes": 87158
259
  },
260
+ "examples/hf-cloud-first-candidate.json": {
261
+ "sha256": "09875990f95708d4bf53a243a38fdd2635bb6adf48ad1d468e8ce7fda1e1c14b",
262
+ "bytes": 13493
263
+ },
264
  "examples/hf-ingress-validation.json": {
265
+ "sha256": "c30b484ede7e2b13aef5f2f93e97aa529cbba56e8dffb1a28989aa16c6882da9",
266
+ "bytes": 2441
267
  },
268
  "examples/multi-sandbox-validation.json": {
269
  "sha256": "a74fba8e0bc5090b4e16ce0493eca0dbe8ba652e07b3c0907a0c3bdda74fa2fb",
deploy/hf/preview-bridge.html ADDED
@@ -0,0 +1 @@
 
 
1
+ <!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>打开应用</title><link rel="stylesheet" href="/runtime.css"></head><body><p id="status" role="status">正在打开应用…</p><script type="module" src="/space/preview-bridge.js"></script></body></html>
deploy/hf/preview-bridge.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const status=document.getElementById('status'),query=new URLSearchParams(location.search),fragment=new URLSearchParams(location.hash.slice(1)),nonce=fragment.get('bridge');
2
+ const proof=Array.from(crypto.getRandomValues(new Uint8Array(32)),b=>b.toString(16).padStart(2,'0')).join('');
3
+ globalThis.zkPopupProof={nonce,proof};
4
+ history.replaceState(null,'',location.pathname+location.search);
5
+ const pause=ms=>new Promise(resolve=>setTimeout(resolve,ms));
6
+ async function start(){
7
+ let kind=query.get('kind'),reference=query.get('reference');
8
+ if(nonce){
9
+ let login;const deadline=Date.now()+30000;
10
+ do{
11
+ const r=await fetch('/space/preview-login',{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json'},body:JSON.stringify({nonce,proof})});
12
+ if(r.status===202){await pause(250);continue;}
13
+ if(!r.ok)throw Error();login=await r.json();break;
14
+ }while(Date.now()<deadline);
15
+ if(!login)throw Error();kind=login.kind;reference=login.reference;
16
+ }
17
+ const s=await(await fetch('/api/session',{credentials:'same-origin'})).json();if(!s.authenticated)throw Error();
18
+ if(!nonce&&query.has('lease')){location.replace('/preview-site/?lease='+encodeURIComponent(query.get('lease')));return;}
19
+ if(!['run','example','skill'].includes(kind)||!reference)throw Error();
20
+ const opened=await fetch('/api/preview',{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json','X-CSRF-Token':s.csrf},body:JSON.stringify({kind,reference})});if(!opened.ok)throw Error();
21
+ let state=await opened.json();const lease=state.id,deadline=Date.now()+300000;
22
+ while(state.status==='starting'&&Date.now()<deadline){await pause(1500);const r=await fetch('/api/preview?preview_id='+encodeURIComponent(lease),{credentials:'same-origin'});if(!r.ok)throw Error();state=await r.json();}
23
+ if(state.status!=='ready'||state.id!==lease)throw Error();location.replace('/preview-site/?lease='+encodeURIComponent(lease));
24
+ }
25
+ start().catch(()=>{status.textContent='应用打开未完成,请从当前工作台的工程重试。';});
deploy/hf/preview-parent.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // The fragment never reaches HTTP access logs. Session credentials never enter JS.
2
+ export function openPreview(url,descriptor){
3
+ const nonce=Array.from(crypto.getRandomValues(new Uint8Array(32)),b=>b.toString(16).padStart(2,'0')).join('');
4
+ const target=new URL(url,location.origin);target.hash='bridge='+nonce;
5
+ if(target.searchParams.has('lease'))target.pathname='/preview-launch/';
6
+ const child=window.open(target.href,'_blank');if(child)child.opener=null;
7
+ const ready=(async()=>{
8
+ // Bind the approval to this actual popup, not to a link another site could send.
9
+ let proof;const deadline=Date.now()+30000;
10
+ while(child&&!child.closed&&Date.now()<deadline){
11
+ try{const candidate=child.zkPopupProof;if(candidate?.nonce===nonce){proof=candidate.proof;break;}}catch{}
12
+ await new Promise(resolve=>setTimeout(resolve,100));
13
+ }
14
+ if(!proof)throw Error('应用窗口未能打开,请允许新窗口后重试。');
15
+ const s=await(await fetch('/api/session',{credentials:'same-origin'})).json();
16
+ if(!s.authenticated)throw Error('请先登录工作台。');
17
+ const r=await fetch('/space/preview-authorize',{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/json','X-CSRF-Token':s.csrf},body:JSON.stringify({...descriptor,nonce,proof})});
18
+ if(!r.ok)throw Error('应用打开未完成,请从当前工程重试。');
19
+ })();
20
+ return {window:child,ready};
21
+ }
22
+ document.addEventListener('click',event=>{
23
+ const link=event.target.closest('a[href]');if(!link||event.button!==0||event.ctrlKey||event.metaKey||event.shiftKey||event.altKey)return;
24
+ const url=new URL(link.href,location.origin);
25
+ if(url.origin!==location.origin||!['/preview-site/','/preview-launch/'].includes(url.pathname))return;
26
+ const query=url.searchParams,descriptor=query.has('lease')?{lease:query.get('lease')}:{kind:query.get('kind'),reference:query.get('reference')};
27
+ event.preventDefault();const opened=openPreview(url.href,descriptor);opened.ready.catch(()=>{if(opened.window)opened.window.close();});
28
+ });
deploy/hf/preview_bridge.py ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """One-use, CSRF-authorized transfer between HF iframe and popup cookie partitions."""
2
+ import hashlib
3
+ import hmac
4
+ import json
5
+ import re
6
+ import threading
7
+ import time
8
+ from http.cookies import SimpleCookie
9
+ from pathlib import Path
10
+ from urllib.parse import parse_qs
11
+ from starlette.responses import JSONResponse, Response
12
+ from src.modules.skill.domain.models import SkillError
13
+
14
+ ASSETS = Path(__file__).parent
15
+ NONCE = re.compile(r'[a-f0-9]{64}')
16
+
17
+
18
+ class PreviewBridge:
19
+ def __init__(self, engine, *, clock=time.monotonic, capacity=128):
20
+ self.engine, self.clock, self.capacity = engine, clock, capacity
21
+ self.lock = threading.Lock()
22
+ self.tickets, self.used = {}, {}
23
+
24
+ def session(self, scope):
25
+ headers = dict(scope['headers'])
26
+ cookies = SimpleCookie()
27
+ cookies.load(headers.get(b'cookie', b'').decode())
28
+ token = cookies.get('zk_session')
29
+ if token is None:
30
+ raise SkillError('TOKEN_INVALID', '请从工作台打开应用。', 401)
31
+ actor, csrf, _ = self.engine.identity.session(token.value)
32
+ return actor, csrf, token.value
33
+
34
+ @staticmethod
35
+ def patch_runtime(data):
36
+ text = data.decode('utf-8')
37
+ old = "const previewWindow=window.open(url,'_blank');"
38
+ stage = "let state=await api('/api/preview',{kind,reference});"
39
+ if text.count(old) != 1 or text.count(stage) != 1:
40
+ raise RuntimeError('SPACE_PREVIEW_ADAPTER_MISMATCH')
41
+ text = "import {openPreview} from '/space/preview-parent.js';\n" + text.replace(old,
42
+ 'const bridge=openPreview(url,{kind,reference});const previewWindow=bridge.window;')
43
+ return text.replace(stage, 'await bridge.ready;' + stage).encode('utf-8')
44
+
45
+ def prune(self):
46
+ now = self.clock()
47
+ self.tickets = {k:v for k,v in self.tickets.items() if v['expires'] > now}
48
+ self.used = {k:v for k,v in self.used.items() if v > now}
49
+
50
+ def authorize(self, scope, data):
51
+ actor, csrf, token = self.session(scope)
52
+ if not hmac.compare_digest(dict(scope['headers']).get(b'x-csrf-token', b'').decode(), csrf):
53
+ raise SkillError('CSRF_DENIED', '请刷新工作台后重试。', 403)
54
+ nonce = data.get('nonce')
55
+ proof = data.get('proof')
56
+ if (not isinstance(nonce, str) or not NONCE.fullmatch(nonce)
57
+ or not isinstance(proof, str) or not NONCE.fullmatch(proof)):
58
+ raise SkillError('INVALID_INPUT', '打开应用请求不完整。', 422)
59
+ if data.get('lease'):
60
+ state = self.engine.preview_state(actor, data['lease'])
61
+ kind, reference = state['kind'], state['reference']
62
+ else:
63
+ kind, reference = data.get('kind'), data.get('reference')
64
+ if (kind not in {'run','example','skill'} or not isinstance(reference, str)
65
+ or not re.fullmatch(r'[A-Za-z0-9_-]{1,128}', reference)):
66
+ raise SkillError('INVALID_INPUT', '打开应用请求不完整。', 422)
67
+ self.engine.evidence(actor, kind, reference)
68
+ key = hashlib.sha256(nonce.encode()).hexdigest()
69
+ with self.lock:
70
+ self.prune()
71
+ if key in self.used:
72
+ raise SkillError('PREVIEW_HANDOFF_USED', '本次打开请求已使用。', 409)
73
+ old = self.tickets.get(key)
74
+ proof_hash = hashlib.sha256(proof.encode()).hexdigest()
75
+ if old and (old['token'], old['kind'], old['reference'], old['proof_hash']) != (token, kind, reference, proof_hash):
76
+ raise SkillError('PREVIEW_HANDOFF_CONFLICT', '打开应用请求不符。', 409)
77
+ if not old:
78
+ if len(self.tickets) + len(self.used) >= self.capacity:
79
+ raise SkillError('PREVIEW_HANDOFF_CAPACITY', '打开请求较多,请稍后重试。', 429)
80
+ self.tickets[key] = {'token':token, 'kind':kind, 'reference':reference, 'proof_hash':proof_hash, 'expires':self.clock()+60}
81
+ return JSONResponse({'authorized':True})
82
+
83
+ def consume(self, data):
84
+ nonce = data.get('nonce')
85
+ proof = data.get('proof')
86
+ if (not isinstance(nonce, str) or not NONCE.fullmatch(nonce)
87
+ or not isinstance(proof, str) or not NONCE.fullmatch(proof)):
88
+ raise SkillError('INVALID_INPUT', '打开应用请求不完整。', 422)
89
+ key = hashlib.sha256(nonce.encode()).hexdigest()
90
+ with self.lock:
91
+ self.prune()
92
+ if key in self.used:
93
+ raise SkillError('PREVIEW_HANDOFF_USED', '本次打开请求已使用。', 409)
94
+ item = self.tickets.get(key)
95
+ if not item:
96
+ return JSONResponse({'pending':True}, status_code=202)
97
+ if not hmac.compare_digest(item['proof_hash'], hashlib.sha256(proof.encode()).hexdigest()):
98
+ raise SkillError('PREVIEW_HANDOFF_PROOF', '请从原工作台窗口打开应用。', 403)
99
+ actor, _, _ = self.engine.identity.session(item['token'])
100
+ self.engine.evidence(actor, item['kind'], item['reference'])
101
+ self.tickets.pop(key)
102
+ self.used[key] = self.clock() + 60
103
+ response = JSONResponse({'authenticated':True, 'kind':item['kind'], 'reference':item['reference']})
104
+ response.set_cookie('zk_session', item['token'], max_age=28800, httponly=True, secure=True, samesite='none')
105
+ # Set-Cookie's new partition belongs to the popup's top-level site.
106
+ response.headers['set-cookie'] += '; Partitioned'
107
+ return response
108
+
109
+ async def handle(self, scope, receive, send):
110
+ path, method = scope['path'], scope['method']
111
+ response = None
112
+ if method == 'GET' and path in {'/space/preview-parent.js', '/space/preview-bridge.js'}:
113
+ response = Response((ASSETS / path.rsplit('/',1)[1]).read_bytes(), media_type='text/javascript')
114
+ elif method == 'GET' and path in {'/preview-launch/', '/preview-site/'}:
115
+ query = parse_qs(scope['query_string'].decode(), keep_blank_values=True)
116
+ if path == '/preview-site/' and 'lease' in query:
117
+ try:
118
+ self.session(scope)
119
+ return False
120
+ except SkillError:
121
+ pass
122
+ response = Response((ASSETS / 'preview-bridge.html').read_bytes(), media_type='text/html')
123
+ elif method == 'POST' and path in {'/space/preview-authorize', '/space/preview-login'}:
124
+ raw = bytearray()
125
+ try:
126
+ while True:
127
+ message = await receive()
128
+ if message['type'] != 'http.request':
129
+ raise SkillError('INVALID_INPUT', '打开应用请求中断。', 400)
130
+ raw.extend(message.get('body', b''))
131
+ if len(raw) > 2048:
132
+ raise SkillError('PAYLOAD_TOO_LARGE', '打开应用请求过大。', 413)
133
+ if not message.get('more_body'):
134
+ break
135
+ data = json.loads(raw)
136
+ if not isinstance(data, dict):
137
+ raise ValueError()
138
+ response = self.authorize(scope, data) if path.endswith('authorize') else self.consume(data)
139
+ except (ValueError, UnicodeError):
140
+ response = JSONResponse({'code':'INVALID_INPUT'}, status_code=422)
141
+ except SkillError as error:
142
+ response = JSONResponse({'code':error.code, 'message':error.message}, status_code=error.status)
143
+ if response is None:
144
+ return False
145
+ response.headers.update({'Cache-Control':'no-store', 'Referrer-Policy':'no-referrer', 'X-Content-Type-Options':'nosniff',
146
+ 'Content-Security-Policy':"default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'self'; frame-ancestors 'self' https://huggingface.co; base-uri 'none'; form-action 'self'"})
147
+ await response(scope, receive, send)
148
+ return True
docs/demo-briefs/calculator.md CHANGED
@@ -16,5 +16,11 @@
16
  - CALC-05:表达式最多128字符、括号16层、64次运算;单个数字字面量最多24位(不含小数点),数值绝对值≤1e24;超限422 LIMIT_EXCEEDED。编码参数最多256字符,超限400 INVALID_INPUT。无身份401、非GET405、未知路径404,线程与输入有界。
17
  - CALC-06:独立HTTP系统测试覆盖算术、精度、结合顺序、负号、边界和错误;网页测试点击键盘与Enter、历史回填、连续运算、除零展示、窄屏布局。
18
 
 
 
 
 
 
 
19
  ## 交付与完成条件
20
  交付Java源码、配套HTML/CSS/JS页面、需求与技术说明、差异、测试对应表、实际沙箱编译和测试证据、可下载ZIP及本地网站。生成源码限定src/main/java/demo/App.java及可选docs,不引入框架或修改保护测试;受控网页模板作为独立交付文件明确来源。失败必须留存诊断并修复复测,不以静态数字冒充Java执行结果。
 
16
  - CALC-05:表达式最多128字符、括号16层、64次运算;单个数字字面量最多24位(不含小数点),数值绝对值≤1e24;超限422 LIMIT_EXCEEDED。编码参数最多256字符,超限400 INVALID_INPUT。无身份401、非GET405、未知路径404,线程与输入有界。
17
  - CALC-06:独立HTTP系统测试覆盖算术、精度、结合顺序、负号、边界和错误;网页测试点击键盘与Enter、历史回填、连续运算、除零展示、窄屏布局。
18
 
19
+ ### 接口与Java实现补充约束
20
+
21
+ 成功和失败都必须返回UTF-8 JSON对象,不能直接返回错误码文本或HttpServer默认HTML。成功包络为`{"expression":"原始表达式(保留空格)","result":"结果字符串"}`,错误包络统一为`{"error":"对应错误码"}`;未知路径也返回404 `{"error":"NOT_FOUND"}`。可注册统一根处理器,再精确匹配路径和方法,避免默认路由漏出HTML。
22
+
23
+ 数字语法为`digits ('.' digits+)?`或`'.' digits+`;`.5`合法,`1.`非法。允许标记之间的ASCII空格,保留原输入;` 12 + ( 3 * 2 ) `等于18,`1 2`仍非法,不能简单删除全部空白。严格UTF-8解码须使用CharsetDecoder的REPORT模式,不能用会替换非法字节的默认字符串构造。需要ByteBuffer/CharBuffer时应显式导入`java.nio.ByteBuffer`和`java.nio.CharBuffer`,或使用完整类名,确保Java17实际编译。此处是公开接口和编程约束,不允许修改保护测试。
24
+
25
  ## 交付与完成条件
26
  交付Java源码、配套HTML/CSS/JS页面、需求与技术说明、差异、测试对应表、实际沙箱编译和测试证据、可下载ZIP及本地网站。生成源码限定src/main/java/demo/App.java及可选docs,不引入框架或修改保护测试;受控网页模板作为独立交付文件明确来源。失败必须留存诊断并修复复测,不以静态数字冒充Java执行结果。
examples/hf-cloud-first-candidate.json ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "space": "dellweb3/VibeCoding",
3
+ "space_commit": "caf8059cb14fac03c3fa17e2009de2018475d004",
4
+ "complete": false,
5
+ "reason": "calculator still failed; iframe popup lacked partitioned session",
6
+ "jobs": [
7
+ {
8
+ "scenario": "erp",
9
+ "run_id": "run-f35638c64a7b42d2b4c61b543881c899",
10
+ "status": "verified",
11
+ "error": null,
12
+ "repairs": 0,
13
+ "source_digest": "4b781dd92bf5e63717b5943a10cdd5f70d6a0fb4916a4c23b3e1d5fabd65a8af",
14
+ "model_calls": [
15
+ {
16
+ "id": 1,
17
+ "run_id": "run-f35638c64a7b42d2b4c61b543881c899",
18
+ "reservation": 19216,
19
+ "charged": 5215,
20
+ "state": "settled",
21
+ "provider": "bailian-qwen3.8-flash",
22
+ "prompt_digest": "90f3c2cf88ab843202162ec1af9a0bafe1961b3414f17eb3cadedb4b0a807d6f",
23
+ "metadata": {
24
+ "finish_reason": "stop",
25
+ "model": "qwen3.8-flash",
26
+ "policy_version": "bailian-task-routing-v2",
27
+ "request_id": "chatcmpl-e9d3b446-c31b-993b-b343-37f55f44592f",
28
+ "requested_output_tokens": 2048,
29
+ "retry_of": null,
30
+ "route_reason": "technical-design",
31
+ "stage": "design"
32
+ }
33
+ },
34
+ {
35
+ "id": 2,
36
+ "run_id": "run-f35638c64a7b42d2b4c61b543881c899",
37
+ "reservation": 16458,
38
+ "charged": 6080,
39
+ "state": "settled",
40
+ "provider": "bailian-qwen3.8-max",
41
+ "prompt_digest": "c2792b96b5106b588f1afd046150efbc0667493cbebe95fa8bcad4adccd17106",
42
+ "metadata": {
43
+ "finish_reason": "stop",
44
+ "model": "qwen3.8-max",
45
+ "policy_version": "bailian-task-routing-v2",
46
+ "request_id": "chatcmpl-e351056a-5192-9e54-afd2-d56bd75de39d",
47
+ "requested_output_tokens": 8192,
48
+ "retry_of": null,
49
+ "route_reason": "business-code",
50
+ "stage": "code"
51
+ }
52
+ }
53
+ ],
54
+ "diagnostics": null
55
+ },
56
+ {
57
+ "scenario": "calculator",
58
+ "run_id": "run-4cf09e70e862457dbeb06aca1dfd5e58",
59
+ "status": "failed",
60
+ "error": "JAVA_TEST_FAILED",
61
+ "repairs": 2,
62
+ "source_digest": "524cadf952160e062ec774da01e0a13657a41d21924733895b598f082bef7871",
63
+ "model_calls": [
64
+ {
65
+ "id": 3,
66
+ "run_id": "run-4cf09e70e862457dbeb06aca1dfd5e58",
67
+ "reservation": 20000,
68
+ "charged": 5605,
69
+ "state": "settled",
70
+ "provider": "bailian-qwen3.8-flash",
71
+ "prompt_digest": "6601055d26e44c2a07faeb048d1bcb3df71440dcc2c08b750d5df8875300945a",
72
+ "metadata": {
73
+ "finish_reason": "stop",
74
+ "model": "qwen3.8-flash",
75
+ "policy_version": "bailian-task-routing-v2",
76
+ "request_id": "chatcmpl-d8338f17-4999-92bc-b985-759a20000941",
77
+ "requested_output_tokens": 1151,
78
+ "retry_of": null,
79
+ "route_reason": "technical-design",
80
+ "stage": "design"
81
+ }
82
+ },
83
+ {
84
+ "id": 4,
85
+ "run_id": "run-4cf09e70e862457dbeb06aca1dfd5e58",
86
+ "reservation": 16966,
87
+ "charged": 3500,
88
+ "state": "settled",
89
+ "provider": "bailian-qwen3.8-max",
90
+ "prompt_digest": "8e9c0824fc9eb316dc13fb841d0b5d0c0b23ac455bd7943c4ed71b1a4d129366",
91
+ "metadata": {
92
+ "finish_reason": "stop",
93
+ "model": "qwen3.8-max",
94
+ "policy_version": "bailian-task-routing-v2",
95
+ "request_id": "chatcmpl-0a23d3ab-85cf-9103-8116-923de7d8fc1d",
96
+ "requested_output_tokens": 8192,
97
+ "retry_of": null,
98
+ "route_reason": "java-code",
99
+ "stage": "code"
100
+ }
101
+ },
102
+ {
103
+ "id": 5,
104
+ "run_id": "run-4cf09e70e862457dbeb06aca1dfd5e58",
105
+ "reservation": 26358,
106
+ "charged": 5730,
107
+ "state": "settled",
108
+ "provider": "bailian-qwen3.8-max",
109
+ "prompt_digest": "f87a694028417addb113ace4acf880b46888bda62cb3a6a08300d8854e9e1132",
110
+ "metadata": {
111
+ "finish_reason": "stop",
112
+ "model": "qwen3.8-max",
113
+ "policy_version": "bailian-task-routing-v2",
114
+ "request_id": "chatcmpl-fbf28bae-1cef-989e-b7c1-6275160f6f8e",
115
+ "requested_output_tokens": 12288,
116
+ "retry_of": null,
117
+ "route_reason": "diagnostic-repair",
118
+ "stage": "repair"
119
+ }
120
+ },
121
+ {
122
+ "id": 6,
123
+ "run_id": "run-4cf09e70e862457dbeb06aca1dfd5e58",
124
+ "reservation": 23930,
125
+ "charged": 4888,
126
+ "state": "settled",
127
+ "provider": "bailian-qwen3.8-max",
128
+ "prompt_digest": "e88f679e89e45109232c9c6b578c526fac4813182834975916b5202b7ecee4ac",
129
+ "metadata": {
130
+ "finish_reason": "stop",
131
+ "model": "qwen3.8-max",
132
+ "policy_version": "bailian-task-routing-v2",
133
+ "request_id": "chatcmpl-184a947e-da09-9c3c-8b9a-27646c1b284a",
134
+ "requested_output_tokens": 12288,
135
+ "retry_of": null,
136
+ "route_reason": "diagnostic-repair",
137
+ "stage": "repair"
138
+ }
139
+ }
140
+ ],
141
+ "diagnostics": {
142
+ "failures": [
143
+ {
144
+ "actual_body": "INVALID_EXPRESSION",
145
+ "actual_status": 400,
146
+ "case_index": 13,
147
+ "expected_status": 200,
148
+ "path": "/api/calculate?expression64=IDEyICsgKCAzICogMiApIA",
149
+ "reason": "response_did_not_match_public_contract"
150
+ },
151
+ {
152
+ "actual_body": "INVALID_EXPRESSION",
153
+ "actual_status": 400,
154
+ "case_index": 16,
155
+ "expected_status": 400,
156
+ "path": "/api/calculate?expression64=MSs",
157
+ "reason": "response_did_not_match_public_contract"
158
+ },
159
+ {
160
+ "actual_body": "INVALID_EXPRESSION",
161
+ "actual_status": 400,
162
+ "case_index": 17,
163
+ "expected_status": 400,
164
+ "path": "/api/calculate?expression64=KDErMg",
165
+ "reason": "response_did_not_match_public_contract"
166
+ },
167
+ {
168
+ "actual_body": "INVALID_EXPRESSION",
169
+ "actual_status": 400,
170
+ "case_index": 18,
171
+ "expected_status": 400,
172
+ "path": "/api/calculate?expression64=MSAy",
173
+ "reason": "response_did_not_match_public_contract"
174
+ },
175
+ {
176
+ "actual_body": "INVALID_EXPRESSION",
177
+ "actual_status": 400,
178
+ "case_index": 19,
179
+ "expected_status": 400,
180
+ "path": "/api/calculate?expression64=MigzKQ",
181
+ "reason": "response_did_not_match_public_contract"
182
+ },
183
+ {
184
+ "actual_body": "INVALID_EXPRESSION",
185
+ "actual_status": 400,
186
+ "case_index": 20,
187
+ "expected_status": 400,
188
+ "path": "/api/calculate?expression64=MSth",
189
+ "reason": "response_did_not_match_public_contract"
190
+ },
191
+ {
192
+ "actual_body": "INVALID_EXPRESSION",
193
+ "actual_status": 400,
194
+ "case_index": 21,
195
+ "expected_status": 400,
196
+ "path": "/api/calculate?expression64=MWUz",
197
+ "reason": "response_did_not_match_public_contract"
198
+ },
199
+ {
200
+ "actual_body": "INVALID_EXPRESSION",
201
+ "actual_status": 400,
202
+ "case_index": 22,
203
+ "expected_status": 400,
204
+ "path": "/api/calculate?expression64=IA",
205
+ "reason": "response_did_not_match_public_contract"
206
+ },
207
+ {
208
+ "actual_body": "{\"expression\":\"1.\",\"result\":\"1\"}",
209
+ "actual_status": 200,
210
+ "case_index": 23,
211
+ "expected_status": 400,
212
+ "path": "/api/calculate?expression64=MS4",
213
+ "reason": "response_did_not_match_public_contract"
214
+ },
215
+ {
216
+ "actual_body": "DIVISION_BY_ZERO",
217
+ "actual_status": 400,
218
+ "case_index": 24,
219
+ "expected_status": 400,
220
+ "path": "/api/calculate?expression64=MS8oMi0yKQ",
221
+ "reason": "response_did_not_match_public_contract"
222
+ },
223
+ {
224
+ "actual_body": "LIMIT_EXCEEDED",
225
+ "actual_status": 422,
226
+ "case_index": 25,
227
+ "expected_status": 422,
228
+ "path": "/api/calculate?expression64=MSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsx",
229
+ "reason": "response_did_not_match_public_contract"
230
+ },
231
+ {
232
+ "actual_body": "LIMIT_EXCEEDED",
233
+ "actual_status": 422,
234
+ "case_index": 26,
235
+ "expected_status": 422,
236
+ "path": "/api/calculate?expression64=KCgoKCgoKCgoKCgoKCgoKCgxKSkpKSkpKSkpKSkpKSkpKSk",
237
+ "reason": "response_did_not_match_public_contract"
238
+ },
239
+ {
240
+ "actual_body": "LIMIT_EXCEEDED",
241
+ "actual_status": 422,
242
+ "case_index": 27,
243
+ "expected_status": 422,
244
+ "path": "/api/calculate?expression64=LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0x",
245
+ "reason": "response_did_not_match_public_contract"
246
+ },
247
+ {
248
+ "actual_body": "LIMIT_EXCEEDED",
249
+ "actual_status": 422,
250
+ "case_index": 28,
251
+ "expected_status": 422,
252
+ "path": "/api/calculate?expression64=MTExMTExMTExMTExMTExMTExMTExMTExMQ",
253
+ "reason": "response_did_not_match_public_contract"
254
+ },
255
+ {
256
+ "actual_body": "LIMIT_EXCEEDED",
257
+ "actual_status": 422,
258
+ "case_index": 29,
259
+ "expected_status": 422,
260
+ "path": "/api/calculate?expression64=OTk5OTk5OTk5OTk5OTk5OTk5OTk5OTk5KjI",
261
+ "reason": "response_did_not_match_public_contract"
262
+ },
263
+ {
264
+ "actual_body": "INVALID_INPUT",
265
+ "actual_status": 400,
266
+ "case_index": 30,
267
+ "expected_status": 400,
268
+ "path": "/api/calculate",
269
+ "reason": "response_did_not_match_public_contract"
270
+ },
271
+ {
272
+ "actual_body": "INVALID_INPUT",
273
+ "actual_status": 400,
274
+ "case_index": 31,
275
+ "expected_status": 400,
276
+ "path": "/api/calculate?expression64=MQ&expression64=Mg",
277
+ "reason": "response_did_not_match_public_contract"
278
+ },
279
+ {
280
+ "actual_body": "INVALID_INPUT",
281
+ "actual_status": 400,
282
+ "case_index": 32,
283
+ "expected_status": 400,
284
+ "path": "/api/calculate?expression64=MQ&other=Mg",
285
+ "reason": "response_did_not_match_public_contract"
286
+ },
287
+ {
288
+ "actual_body": "INVALID_INPUT",
289
+ "actual_status": 400,
290
+ "case_index": 33,
291
+ "expected_status": 400,
292
+ "path": "/api/calculate?expression64=A",
293
+ "reason": "response_did_not_match_public_contract"
294
+ },
295
+ {
296
+ "actual_body": "INVALID_INPUT",
297
+ "actual_status": 400,
298
+ "case_index": 34,
299
+ "expected_status": 400,
300
+ "path": "/api/calculate?expression64=MQ==",
301
+ "reason": "response_did_not_match_public_contract"
302
+ },
303
+ {
304
+ "actual_body": "INVALID_INPUT",
305
+ "actual_status": 400,
306
+ "case_index": 35,
307
+ "expected_status": 400,
308
+ "path": "/api/calculate?expression64=_w",
309
+ "reason": "response_did_not_match_public_contract"
310
+ },
311
+ {
312
+ "actual_body": "UNAUTHORIZED",
313
+ "actual_status": 401,
314
+ "case_index": 36,
315
+ "expected_status": 401,
316
+ "path": "/api/calculate?expression64=MSsx",
317
+ "reason": "response_did_not_match_public_contract"
318
+ },
319
+ {
320
+ "actual_body": "METHOD_NOT_ALLOWED",
321
+ "actual_status": 405,
322
+ "case_index": 37,
323
+ "expected_status": 405,
324
+ "path": "/api/calculate?expression64=MSsx",
325
+ "reason": "response_did_not_match_public_contract"
326
+ },
327
+ {
328
+ "actual_body": "<h1>404 Not Found</h1>No context found for request",
329
+ "actual_status": 404,
330
+ "case_index": 38,
331
+ "expected_status": 404,
332
+ "path": "/unknown",
333
+ "reason": "response_did_not_match_public_contract"
334
+ }
335
+ ]
336
+ }
337
+ }
338
+ ],
339
+ "model_calls": 6,
340
+ "charged_tokens": 31018,
341
+ "hub_failure": {
342
+ "scope": "fresh Hub iframe session with no prior direct-app login",
343
+ "passed": false,
344
+ "failure": "TimeoutError: Timeout 330000ms exceeded.\n=========================== logs ===========================\nwaiting for navigation to \"https://dellweb3-vibecoding.hf.space/preview-site/?lease=*\" until 'load'\n============================================================",
345
+ "cleanup": {
346
+ "owned_leases": 1
347
+ }
348
+ },
349
+ "protected_tests_weakened": false
350
+ }
examples/hf-ingress-validation.json CHANGED
@@ -3,10 +3,22 @@
3
  "original conversation shell and all three real sessions work over HTTPS with secure cookies",
4
  "foreign-origin mutation is rejected before entering the local app",
5
  "workbench preview click opens the actual Java calculator on the same public HTTPS origin; decimal and error paths operate",
6
- "application refresh is usable and original workbench remains at root"
 
 
7
  ],
8
  "errors": [],
9
  "platform_code_digest": "12c0b17aa96615c4d0cfc079396bb75fb462caa5438452ba81ba6419b0353696",
 
 
 
 
 
 
 
 
 
 
10
  "scope": "local HTTPS ingress, not HF runtime",
11
  "receipt": {
12
  "source_digest": "b80e5c95d1153f8e664d4b7bac3701d52fecab2a41de12e5a49ea0fd795cd7a4",
@@ -17,33 +29,16 @@
17
  "network": "none",
18
  "host_mounts": []
19
  },
20
- "passed": 4,
21
- "tested_at_utc": "2026-10-24T03:23:46.696199+00:00",
22
  "unit_tests": {
23
- "passed": 14,
24
  "skipped": 0
25
  },
26
  "cloud_publication": {
27
- "state": "prepared_not_published",
28
  "space": "dellweb3/VibeCoding",
29
- "reason": "model_secret_missing; migration_requires_explicit_approval"
30
- },
31
- "first_attempt": {
32
- "checks": [
33
- "original conversation shell and all three real sessions work over HTTPS with secure cookies",
34
- "foreign-origin mutation is rejected before entering the local app"
35
- ],
36
- "errors": [],
37
- "platform_code_digest": "12c0b17aa96615c4d0cfc079396bb75fb462caa5438452ba81ba6419b0353696",
38
- "scope": "local HTTPS ingress, not HF runtime",
39
- "failure": "TimeoutError: Timeout 30000ms exceeded while waiting for event \"page\""
40
- },
41
- "cloud_runtime_files": {
42
- "deploy/hf/adapter.py": "09122155052800157b3c45e479b90b9c2a52881052b538b1edf53d7001aa7450",
43
- "deploy/hf/app.py": "d6363ca65d6044d15368eb3d58709b74aa0d072efc7c2a5856c2e81da2c078f3",
44
- "deploy/hf/prepare_image.py": "8c548bf8881ee0510fd65e5d2de6b464df3d4212bcc5f736363bbdaac32ff0c7",
45
- "deploy/hf/Dockerfile": "e18a9d956fec5943436409223be6ec5df6f85be46980a58458e02c9ce3439f31"
46
- },
47
- "cloud_hash_record_note": "Recorded after the successful browser check; these runtime files were unchanged between that check and this record. Docker Linux build remains unverified.",
48
- "package_check_repair": "Final package verification found the verified Dockerfile copy omitted from the nested source path. Allowlist fixed and regression test added; no runtime or protected Java test changed."
49
  }
 
3
  "original conversation shell and all three real sessions work over HTTPS with secure cookies",
4
  "foreign-origin mutation is rejected before entering the local app",
5
  "workbench preview click opens the actual Java calculator on the same public HTTPS origin; decimal and error paths operate",
6
+ "application refresh is usable and original workbench remains at root",
7
+ "fresh third-party iframe and standalone popup with separate cookie partitions transfer the authorized manager session once and run real Java",
8
+ "popup receives the exact parent identity; an independent programmer remains denied"
9
  ],
10
  "errors": [],
11
  "platform_code_digest": "12c0b17aa96615c4d0cfc079396bb75fb462caa5438452ba81ba6419b0353696",
12
+ "cloud_runtime_files": {
13
+ "deploy/hf/adapter.py": "a3b1b8a4c6e0b0f0c075b9c9bcf453f3c0f6803ac8f69fffe0ae11a625c7e549",
14
+ "deploy/hf/app.py": "0e8a5729b5e99aae88c277d718e0afa6de21350515f92452996d10deac7612f3",
15
+ "deploy/hf/prepare_image.py": "8c548bf8881ee0510fd65e5d2de6b464df3d4212bcc5f736363bbdaac32ff0c7",
16
+ "deploy/hf/Dockerfile": "e18a9d956fec5943436409223be6ec5df6f85be46980a58458e02c9ce3439f31",
17
+ "deploy/hf/preview_bridge.py": "d36b827c0e089ca56e19c4c34849a31dfb15128e5b6443c3193da04e99af836d",
18
+ "deploy/hf/preview-parent.js": "9026145e4394cfb82cb8e59800ef5d70ff09da7d039aa15e92fc158409ea039e",
19
+ "deploy/hf/preview-bridge.js": "4611a08d39699fc9268a01bb25a59c9ad63f21769fcd1e8115949f5a5625512f",
20
+ "deploy/hf/preview-bridge.html": "0f709ec2027d6f623cfa5c4b6aad4f104355895fdc768907b8c6dd31a52b06cc"
21
+ },
22
  "scope": "local HTTPS ingress, not HF runtime",
23
  "receipt": {
24
  "source_digest": "b80e5c95d1153f8e664d4b7bac3701d52fecab2a41de12e5a49ea0fd795cd7a4",
 
29
  "network": "none",
30
  "host_mounts": []
31
  },
32
+ "passed": 6,
33
+ "tested_at_utc": "2026-10-24T04:00:27.882498+00:00",
34
  "unit_tests": {
35
+ "passed": 22,
36
  "skipped": 0
37
  },
38
  "cloud_publication": {
 
39
  "space": "dellweb3/VibeCoding",
40
+ "state": "repaired_candidate_ready_for_upload",
41
+ "model_secret_configured": true,
42
+ "cloud_acceptance_pending": true
43
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }