dellweb3 commited on
Commit
253a5d4
·
verified ·
1 Parent(s): fc92530

Deploy verified conversational workbench and isolated Java application previews

Browse files

Source baseline: d9f38c51afab6b76db8cd42679961d03b4cc7d80. Credentials are runtime Secrets only.

AGENTS.md CHANGED
@@ -12,6 +12,10 @@ HF令牌仅从用户明确指定文件读取,在`.local/huggingface/token.dpap
12
 
13
  HF嵌入页到新窗口的Cookie分区和宿主转发弹窗不返回WindowProxy的行为必须单独测试,不得绕过宿主隔离。一次性授权只生成绑定单一租约/源码的短期预览Cookie,按租约路径隔离;不得把工作台账号会话复制到弹窗。受限API只允许该应用状态、固定Java接口和PDF样例,不准调用模型/管理/工程接口,继续校验原会话、项目ACL、来源与CSRF。不得改本机原runtime文件或主布局规避问题。模型已知失败可显式关联新任务修复,未知结果不得重放。设计上下文中完全相同的需求只保留一份,不截断原文或知识引用,不默默提高预算。
14
 
 
 
 
 
15
  ## 生成应用的用户界面约束(2026-10-24最新)
16
 
17
  用户要求点击预览后由平台内部完成准备与发布,8791只展示可操作的完成应用,不展示沙箱启动步骤、控制通道、原始接口JSON、源码摘要、验证回执或制品下载等调试信息。这些内容保留在8789工作台的源码、差异和运行记录中,不删除真实证据。正常预览按钮不再弹出技术侧栏或启动诊断页面;在原按钮提供简短等待反馈,准备完成后显示业务应用。旧保存链接兼容简短打开提示,不再展示技术信息。
 
12
 
13
  HF嵌入页到新窗口的Cookie分区和宿主转发弹窗不返回WindowProxy的行为必须单独测试,不得绕过宿主隔离。一次性授权只生成绑定单一租约/源码的短期预览Cookie,按租约路径隔离;不得把工作台账号会话复制到弹窗。受限API只允许该应用状态、固定Java接口和PDF样例,不准调用模型/管理/工程接口,继续校验原会话、项目ACL、来源与CSRF。不得改本机原runtime文件或主布局规避问题。模型已知失败可显式关联新任务修复,未知结果不得重放。设计上下文中完全相同的需求只保留一份,不截断原文或知识引用,不默默提高预算。
14
 
15
+ ## 等待提示与有界自动恢复追加授权(2026-10-24)
16
+
17
+ 用户指出长时间只有三个点、HF开发失败不能自行恢复。允许仅改对话执行反馈和后端恢复模块:使用实际阶段、等待时间、读取/心跳时间,不伪造思考或成功。新编程请求显式启用一次自动关联续修,原任务两次诊断修复及单任务预算不变,续修最多一轮、不递归;原失败、源码、诊断、费用和授权必须保留。未知/未结算/取消/无权限/预算错误不得重放。详见`docs/waiting-and-recovery.md`。本轮仍保持原三用户、主布局、8789工作台与8791独立应用入口。
18
+
19
  ## 生成应用的用户界面约束(2026-10-24最新)
20
 
21
  用户要求点击预览后由平台内部完成准备与发布,8791只展示可操作的完成应用,不展示沙箱启动步骤、控制通道、原始接口JSON、源码摘要、验证回执或制品下载等调试信息。这些内容保留在8789工作台的源码、差异和运行记录中,不删除真实证据。正常预览按钮不再弹出技术侧栏或启动诊断页面;在原按钮提供简短等待反馈,准备完成后显示业务应用。旧保存链接兼容简短打开提示,不再展示技术信息。
deploy/hf/package-manifest.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "git_commit": "ad1ba98125ba06875890ad3659b182e87b89f061",
3
  "files": {
4
  ".local/dependencies/pdfbox/3.0.8/pdfbox-app-3.0.8.jar": {
5
  "sha256": "f6b3a80c39747ff0ef5d06708bc03882152403de58dbef4a1fbffbee568eceb1",
@@ -18,8 +18,8 @@
18
  "bytes": 94203974
19
  },
20
  "AGENTS.md": {
21
- "sha256": "2c66972e0aef3b9f96cdfe879ed97fac98fd2dc3d5e4faa124cca37450158152",
22
- "bytes": 20672
23
  },
24
  "deploy/hf/adapter.py": {
25
  "sha256": "0088b19648ab9661bb6eb6bdf4fa34de368f5fe5d6c347a58504c60331f42e95",
@@ -269,9 +269,61 @@
269
  "sha256": "6b5a73f3e45c68af96f65f7b47295650bef04e99dc085cb4c53484befbed4fda",
270
  "bytes": 3529
271
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
  "examples/hf-ingress-validation.json": {
273
- "sha256": "98cf48a220928fac95c274b9569eeb3690602e6aa05eb85269e4c350a95b3b3c",
274
- "bytes": 2682
275
  },
276
  "examples/multi-sandbox-validation.json": {
277
  "sha256": "a74fba8e0bc5090b4e16ce0493eca0dbe8ba652e07b3c0907a0c3bdda74fa2fb",
@@ -301,6 +353,10 @@
301
  "sha256": "36ad6315f40b9171ff5238e64f7ff91c09948c45bb2b0eda324197ed51c46869",
302
  "bytes": 150319
303
  },
 
 
 
 
304
  "examples/wms-inventory/README.md": {
305
  "sha256": "f4f787d06f1b835e3c595b105d30bc50ccfe97a84f327eb8800b3a5ea3e39593",
306
  "bytes": 839
@@ -346,8 +402,8 @@
346
  "bytes": 20438
347
  },
348
  "sites/zkcoding-workbench/dist/app.js": {
349
- "sha256": "470342b9b16aa5f5b9feed2b547faba7122c5fcae3e7512c4f6fd832c77fee3b",
350
- "bytes": 52045
351
  },
352
  "sites/zkcoding-workbench/dist/favicon.svg": {
353
  "sha256": "4dd7d491fa1e42d6c7ab2ce2c92ee04bda3cf04bcd49c41fe1f4e2959651a58a",
@@ -366,12 +422,12 @@
366
  "bytes": 4363
367
  },
368
  "sites/zkcoding-workbench/dist/runtime.css": {
369
- "sha256": "b3004f69c7e0c3c47d56d73cba15db5ac8d958c79b3c2f91fb09a1c6e99c40aa",
370
- "bytes": 8254
371
  },
372
  "sites/zkcoding-workbench/dist/runtime.js": {
373
- "sha256": "1c5370aece41491a491b42f5d17525eaac754e7b321c9d21cd7d5ed81ab909c1",
374
- "bytes": 34875
375
  },
376
  "sites/zkcoding-workbench/dist/workos-base.css": {
377
  "sha256": "2df5773982c004d4f1ed6cf14ed166409be21b05b49164ba6e77e13ab2f8f5e7",
@@ -458,8 +514,8 @@
458
  "bytes": 8903
459
  },
460
  "src/adapters/sandbox/preview.py": {
461
- "sha256": "6ec9d71c04ef856178c124b4eaf745c5a1928b6170fe85b0fc6a9ca4c04b1b3d",
462
- "bytes": 12079
463
  },
464
  "src/adapters/sandbox/qemu.py": {
465
  "sha256": "2c7e1f4f1ef02d9d982327844f37c827d84814c465d7a24e80a368fcb450480e",
@@ -510,8 +566,8 @@
510
  "bytes": 0
511
  },
512
  "src/apps/workbench/agent_sandboxes.py": {
513
- "sha256": "0011a1c488c51a5679dfdcea84697413ccfc4b724da405251c7a81f639c1b8d0",
514
- "bytes": 5214
515
  },
516
  "src/apps/workbench/conversation.py": {
517
  "sha256": "2ea8e14d96e07314760069a2ae4bcb3ede1202d854c7f24fe4efd92506f79cb6",
@@ -522,12 +578,12 @@
522
  "bytes": 8477
523
  },
524
  "src/apps/workbench/development.py": {
525
- "sha256": "031ee301d2d3ba6d172828312a8cecff8e067ad5c6019e9995eb6a246a304a62",
526
- "bytes": 4149
527
  },
528
  "src/apps/workbench/engine.py": {
529
- "sha256": "2d1b0d3f9e8a4066c5ab23f377e56903f09a7ee112161165e2c28922c6be293d",
530
- "bytes": 27364
531
  },
532
  "src/apps/workbench/erp_flow.py": {
533
  "sha256": "fb2034555165b8c2b28f6a8ac88ec6d239f8eaf5a0b4828e9b9c649f284b0844",
@@ -562,8 +618,8 @@
562
  "bytes": 4763
563
  },
564
  "src/apps/workbench/web.py": {
565
- "sha256": "08900a652dd8c86a69a36ba1501cfbf8def248d0201be1b296395d7344ba0c3f",
566
- "bytes": 22366
567
  },
568
  "src/contracts/api/.gitkeep": {
569
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -718,8 +774,8 @@
718
  "bytes": 1062
719
  },
720
  "src/modules/execution/scenarios/calculator.py": {
721
- "sha256": "f0b4d0768957a9818ab54099a40d5d75cfbdee6046fec858a6ac7ce7fd106fa7",
722
- "bytes": 8425
723
  },
724
  "src/modules/execution/scenarios/equipment.py": {
725
  "sha256": "e8a8cc0d1e5b2e5cdc27e0617e945430cd44ba3cb70cfe8edde845fad9d7425a",
@@ -902,8 +958,8 @@
902
  "bytes": 1200
903
  },
904
  "src/modules/orchestrator/service.py": {
905
- "sha256": "136495d5dbce53cd58a5e35a50a59dfe3677c4e86e9201b934d5772809525980",
906
- "bytes": 25898
907
  },
908
  "src/modules/orchestrator/skill_runner/.gitkeep": {
909
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -1086,8 +1142,8 @@
1086
  "bytes": 3831
1087
  },
1088
  "src/tests/runtime/test_bailian_gateway.py": {
1089
- "sha256": "1849a289ad3d6d6deec771ccbc21f39d66fd87403b97f85238f1c33298796dc4",
1090
- "bytes": 14925
1091
  },
1092
  "src/tests/runtime/test_business_mcp.py": {
1093
  "sha256": "37462aa367c4ad12ccf7f394b889f1e8aa3eec36b32dda054ada2432e9c4183f",
@@ -1134,8 +1190,8 @@
1134
  "bytes": 8157
1135
  },
1136
  "src/tests/runtime/test_local_web.py": {
1137
- "sha256": "6461b2c6d97179621df56518a46e1477a72261477f3f7f836ccdea4f6766a967",
1138
- "bytes": 17850
1139
  },
1140
  "src/tests/runtime/test_pdf_contract.py": {
1141
  "sha256": "5e63f636c9028b28f696e8e272324848918a230b68bdfe2e34d55d870694c2e8",
 
1
  {
2
+ "git_commit": "d9f38c51afab6b76db8cd42679961d03b4cc7d80",
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": "0558bea7a0b928553961086897c325cc61f774aabf1ed67ee65dc87fe891dc86",
22
+ "bytes": 21341
23
  },
24
  "deploy/hf/adapter.py": {
25
  "sha256": "0088b19648ab9661bb6eb6bdf4fa34de368f5fe5d6c347a58504c60331f42e95",
 
269
  "sha256": "6b5a73f3e45c68af96f65f7b47295650bef04e99dc085cb4c53484befbed4fda",
270
  "bytes": 3529
271
  },
272
+ "examples/hf-cloud-third-candidate.json": {
273
+ "sha256": "734cc2b92c7a82da74e2d82c9d60809903133be11aa2c37313a4be259a45488b",
274
+ "bytes": 16581
275
+ },
276
+ "examples/hf-generated/calculator/design.md": {
277
+ "sha256": "e97b48a3c6972e25a82e3a4d849f061bb7b56c3ef861282f29efdbd172a18818",
278
+ "bytes": 1044
279
+ },
280
+ "examples/hf-generated/calculator/requirement.md": {
281
+ "sha256": "50226e4521929bb017922c30bca798897b6580b17a3a684095b926f933746ece",
282
+ "bytes": 4244
283
+ },
284
+ "examples/hf-generated/calculator/src/main/java/demo/App.java": {
285
+ "sha256": "aa81ce7ccb6e8512710de69c6473198f9801d208feb3fe4b325807bb3e2657a7",
286
+ "bytes": 8210
287
+ },
288
+ "examples/hf-generated/calculator/validation-evidence.json": {
289
+ "sha256": "0e080ed529236008293339349d515ba8a72db9ae8d09065070c5a91d3be1d340",
290
+ "bytes": 28586
291
+ },
292
+ "examples/hf-generated/erp/design.md": {
293
+ "sha256": "f5d8c0a60e4cc751eaa2439d95497ca20763cfde78cd2116376959ed4b1226dd",
294
+ "bytes": 737
295
+ },
296
+ "examples/hf-generated/erp/requirement.md": {
297
+ "sha256": "8d8bf9aa7d2742bc444756d7a2df29a53829b356308e868359a2f3cd7ce68580",
298
+ "bytes": 3112
299
+ },
300
+ "examples/hf-generated/erp/src/main/java/demo/App.java": {
301
+ "sha256": "fa561d1ca503b62be243ab8879ead95f864f8121c54fc6c258a5ed82d5122423",
302
+ "bytes": 5643
303
+ },
304
+ "examples/hf-generated/erp/validation-evidence.json": {
305
+ "sha256": "14c33620091c86afdea2d6a73c121f6a84f962136772a9f1fdec61a014576c0a",
306
+ "bytes": 24852
307
+ },
308
+ "examples/hf-generated/pdf/design.md": {
309
+ "sha256": "1ebb897db09f9787e1a023315d7767c34b19c17a530f42761fc5174fd74eb6a8",
310
+ "bytes": 1144
311
+ },
312
+ "examples/hf-generated/pdf/requirement.md": {
313
+ "sha256": "d25de976970dbf853e4847e5f6b454176261d9d1faa29e656a3153282be96e86",
314
+ "bytes": 3293
315
+ },
316
+ "examples/hf-generated/pdf/src/main/java/demo/App.java": {
317
+ "sha256": "8e349909e99ab8a7f672b78e36100c8d97529a7b83166bb8977b72cc3bdeac92",
318
+ "bytes": 9452
319
+ },
320
+ "examples/hf-generated/pdf/validation-evidence.json": {
321
+ "sha256": "4f715c3dcccfd9269357c7fe327307974c81393c1c693d7e5050e4edc4b6e299",
322
+ "bytes": 29132
323
+ },
324
  "examples/hf-ingress-validation.json": {
325
+ "sha256": "e70502ab97c0eac9eca2393becda36fce6ffed69f20ed2e807c01e5cce513c1f",
326
+ "bytes": 2410
327
  },
328
  "examples/multi-sandbox-validation.json": {
329
  "sha256": "a74fba8e0bc5090b4e16ce0493eca0dbe8ba652e07b3c0907a0c3bdda74fa2fb",
 
353
  "sha256": "36ad6315f40b9171ff5238e64f7ff91c09948c45bb2b0eda324197ed51c46869",
354
  "bytes": 150319
355
  },
356
+ "examples/waiting-recovery-validation.json": {
357
+ "sha256": "39a108f0bd1c76fffa27f43cfbff466c7c7b50dbc8baa1439ba7ab45384949f1",
358
+ "bytes": 19869
359
+ },
360
  "examples/wms-inventory/README.md": {
361
  "sha256": "f4f787d06f1b835e3c595b105d30bc50ccfe97a84f327eb8800b3a5ea3e39593",
362
  "bytes": 839
 
402
  "bytes": 20438
403
  },
404
  "sites/zkcoding-workbench/dist/app.js": {
405
+ "sha256": "9378788f05c6c818a0d85c84b0660e96c2a041f8549c535689bc7c534f41a1f9",
406
+ "bytes": 53630
407
  },
408
  "sites/zkcoding-workbench/dist/favicon.svg": {
409
  "sha256": "4dd7d491fa1e42d6c7ab2ce2c92ee04bda3cf04bcd49c41fe1f4e2959651a58a",
 
422
  "bytes": 4363
423
  },
424
  "sites/zkcoding-workbench/dist/runtime.css": {
425
+ "sha256": "1bf6281cbf1a05e5c0a625b98c5b20284b931208efc4d3eafac2242ac3e0b29b",
426
+ "bytes": 8560
427
  },
428
  "sites/zkcoding-workbench/dist/runtime.js": {
429
+ "sha256": "537ed5a50032695e7561a0e4f603d69e338ebd2ccd784c282df9cf052b00dfa2",
430
+ "bytes": 37325
431
  },
432
  "sites/zkcoding-workbench/dist/workos-base.css": {
433
  "sha256": "2df5773982c004d4f1ed6cf14ed166409be21b05b49164ba6e77e13ab2f8f5e7",
 
514
  "bytes": 8903
515
  },
516
  "src/adapters/sandbox/preview.py": {
517
+ "sha256": "44a07268180eb59e74a8eb6a97650080e4dbb0ed67f225a02ace28d02b2c7f9e",
518
+ "bytes": 12297
519
  },
520
  "src/adapters/sandbox/qemu.py": {
521
  "sha256": "2c7e1f4f1ef02d9d982327844f37c827d84814c465d7a24e80a368fcb450480e",
 
566
  "bytes": 0
567
  },
568
  "src/apps/workbench/agent_sandboxes.py": {
569
+ "sha256": "3cdfd5e113fe0a408550b847fb96f0bafc5db4228771e1109bb0aa83bb13c0b9",
570
+ "bytes": 5283
571
  },
572
  "src/apps/workbench/conversation.py": {
573
  "sha256": "2ea8e14d96e07314760069a2ae4bcb3ede1202d854c7f24fe4efd92506f79cb6",
 
578
  "bytes": 8477
579
  },
580
  "src/apps/workbench/development.py": {
581
+ "sha256": "4383601a8df21fbc3d1b56d79280102eb4b3f5250fb5518507bb962d26523d72",
582
+ "bytes": 4189
583
  },
584
  "src/apps/workbench/engine.py": {
585
+ "sha256": "78ac072e787d5855341c599038d510c207d62c427235e196c1754cd939bda4e2",
586
+ "bytes": 30280
587
  },
588
  "src/apps/workbench/erp_flow.py": {
589
  "sha256": "fb2034555165b8c2b28f6a8ac88ec6d239f8eaf5a0b4828e9b9c649f284b0844",
 
618
  "bytes": 4763
619
  },
620
  "src/apps/workbench/web.py": {
621
+ "sha256": "91034b34fbc6ac1c441805c8ba756b73027a6d4c2e430ad05478177566bdf4e2",
622
+ "bytes": 22564
623
  },
624
  "src/contracts/api/.gitkeep": {
625
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
 
774
  "bytes": 1062
775
  },
776
  "src/modules/execution/scenarios/calculator.py": {
777
+ "sha256": "e9619e2b707484e4771889f07680547ad971da0fe1cbc325860144b27c59053b",
778
+ "bytes": 8634
779
  },
780
  "src/modules/execution/scenarios/equipment.py": {
781
  "sha256": "e8a8cc0d1e5b2e5cdc27e0617e945430cd44ba3cb70cfe8edde845fad9d7425a",
 
958
  "bytes": 1200
959
  },
960
  "src/modules/orchestrator/service.py": {
961
+ "sha256": "f59fdfdc13291f2149e1ac60a215f63f9c8a74eadf1f28ac31c5b6eda4aa3c12",
962
+ "bytes": 26692
963
  },
964
  "src/modules/orchestrator/skill_runner/.gitkeep": {
965
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
 
1142
  "bytes": 3831
1143
  },
1144
  "src/tests/runtime/test_bailian_gateway.py": {
1145
+ "sha256": "54c80de035441269749886315d1fbe105027963a388c17005de63c1a0757349d",
1146
+ "bytes": 15751
1147
  },
1148
  "src/tests/runtime/test_business_mcp.py": {
1149
  "sha256": "37462aa367c4ad12ccf7f394b889f1e8aa3eec36b32dda054ada2432e9c4183f",
 
1190
  "bytes": 8157
1191
  },
1192
  "src/tests/runtime/test_local_web.py": {
1193
+ "sha256": "71aca4806864f0744b51df7b89ded52bb449e09a7debd3f4cdf1ff096cf4aac3",
1194
+ "bytes": 20742
1195
  },
1196
  "src/tests/runtime/test_pdf_contract.py": {
1197
  "sha256": "5e63f636c9028b28f696e8e272324848918a230b68bdfe2e34d55d870694c2e8",
examples/hf-cloud-third-candidate.json ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "space_commit": "fc92530518e5a3f80e650b6bc92a9cd3b8696cd1",
3
+ "all_three_generation_tasks_verified": true,
4
+ "cloud_end_to_end_verified": false,
5
+ "failure": "Error: Target page, context or browser has been closed\n=========================== logs ===========================\nwaiting for navigation to \"https://dellweb3-vibecoding.hf.space/preview-site/?lease=*\" until 'load'\n navigated to \"https://dellweb3-vibecoding.hf.space/preview-site/?kind=run&reference=run-415025244a2a42f09cb63bc4e17902ca\"\n============================================================",
6
+ "checks": [
7
+ "HF root retains the original conversation workbench; all three real users sign in and automatic model routing is provider-neutral",
8
+ "erp: wizard-injected full brief completed real routed model calls, protected compilation/tests and durable execution events",
9
+ "erp: exact Java source and documents, real diff, materialized project and public preview link are reviewable in the original workbench",
10
+ "erp: actual isolated Java website operates, errors are business-readable, refresh works, prior apps stay alive, and root remains the workbench",
11
+ "calculator: wizard-injected full brief completed real routed model calls, protected compilation/tests and durable execution events",
12
+ "calculator: exact Java source and documents, real diff, materialized project and public preview link are reviewable in the original workbench",
13
+ "calculator: actual isolated Java website operates, errors are business-readable, refresh works, prior apps stay alive, and root remains the workbench",
14
+ "pdf: wizard-injected full brief completed real routed model calls, protected compilation/tests and durable execution events",
15
+ "pdf: exact Java source and documents, real diff, materialized project and public preview link are reviewable in the original workbench"
16
+ ],
17
+ "scenarios": {
18
+ "erp": {
19
+ "id": "run-8f523ff16b6b4c95832e46b4b6110a8d",
20
+ "status": "verified",
21
+ "error": null,
22
+ "model_calls": [
23
+ {
24
+ "id": 1,
25
+ "run_id": "run-8f523ff16b6b4c95832e46b4b6110a8d",
26
+ "reservation": 16087,
27
+ "charged": 4086,
28
+ "state": "settled",
29
+ "provider": "bailian-qwen3.8-flash",
30
+ "prompt_digest": "000db0eae0ba1c5ba2e3fe30a3effedc72b74910294bb3128b3a7bf3c208a2ec",
31
+ "metadata": {
32
+ "finish_reason": "stop",
33
+ "model": "qwen3.8-flash",
34
+ "policy_version": "bailian-task-routing-v2",
35
+ "request_id": "chatcmpl-e0a927f6-ec19-9010-b52d-08edc4361673",
36
+ "requested_output_tokens": 2048,
37
+ "retry_of": null,
38
+ "route_reason": "technical-design",
39
+ "stage": "design"
40
+ }
41
+ },
42
+ {
43
+ "id": 2,
44
+ "run_id": "run-8f523ff16b6b4c95832e46b4b6110a8d",
45
+ "reservation": 15627,
46
+ "charged": 5533,
47
+ "state": "settled",
48
+ "provider": "bailian-qwen3.8-max",
49
+ "prompt_digest": "4b488c9662257135d667d65af153280bb1837642bb0e9c9eb79ad2bd3541ab71",
50
+ "metadata": {
51
+ "finish_reason": "stop",
52
+ "model": "qwen3.8-max",
53
+ "policy_version": "bailian-task-routing-v2",
54
+ "request_id": "chatcmpl-5210c519-e295-932c-9baf-8d689177d3c3",
55
+ "requested_output_tokens": 8192,
56
+ "retry_of": null,
57
+ "route_reason": "business-code",
58
+ "stage": "code"
59
+ }
60
+ },
61
+ {
62
+ "id": 3,
63
+ "run_id": "run-8f523ff16b6b4c95832e46b4b6110a8d",
64
+ "reservation": 28818,
65
+ "charged": 6526,
66
+ "state": "settled",
67
+ "provider": "bailian-qwen3.8-max",
68
+ "prompt_digest": "93f9190dd32cf5bda3fa4debb71e644240a811e147e9480b9618426f37e9b4ac",
69
+ "metadata": {
70
+ "finish_reason": "stop",
71
+ "model": "qwen3.8-max",
72
+ "policy_version": "bailian-task-routing-v2",
73
+ "request_id": "chatcmpl-4c5fac7c-eced-9232-8974-4ae54865a978",
74
+ "requested_output_tokens": 12288,
75
+ "retry_of": null,
76
+ "route_reason": "diagnostic-repair",
77
+ "stage": "repair"
78
+ }
79
+ }
80
+ ],
81
+ "repairs": 1
82
+ },
83
+ "calculator": {
84
+ "id": "run-4e2329b555864957bc5b477ae1432717",
85
+ "status": "verified",
86
+ "error": null,
87
+ "model_calls": [
88
+ {
89
+ "id": 4,
90
+ "run_id": "run-4e2329b555864957bc5b477ae1432717",
91
+ "reservation": 18638,
92
+ "charged": 5039,
93
+ "state": "settled",
94
+ "provider": "bailian-qwen3.8-flash",
95
+ "prompt_digest": "f850c544aa2dbee7d723a05f19fc7af1aa1ca9c7b09a679bd1bb6a3ff24ae74a",
96
+ "metadata": {
97
+ "finish_reason": "stop",
98
+ "model": "qwen3.8-flash",
99
+ "policy_version": "bailian-task-routing-v2",
100
+ "request_id": "chatcmpl-c7b411d6-6d06-9c14-ad89-5ac8aed95611",
101
+ "requested_output_tokens": 2048,
102
+ "retry_of": null,
103
+ "route_reason": "technical-design",
104
+ "stage": "design"
105
+ }
106
+ },
107
+ {
108
+ "id": 5,
109
+ "run_id": "run-4e2329b555864957bc5b477ae1432717",
110
+ "reservation": 18111,
111
+ "charged": 4570,
112
+ "state": "settled",
113
+ "provider": "bailian-qwen3.8-max",
114
+ "prompt_digest": "ab6c2a18422f46dda202f1cc58889f3936a8f0c587dd88d6a5f009ea182245f4",
115
+ "metadata": {
116
+ "finish_reason": "stop",
117
+ "model": "qwen3.8-max",
118
+ "policy_version": "bailian-task-routing-v2",
119
+ "request_id": "chatcmpl-1dbf5d69-b11a-9c84-b24e-c4c36e18b516",
120
+ "requested_output_tokens": 8192,
121
+ "retry_of": null,
122
+ "route_reason": "java-code",
123
+ "stage": "code"
124
+ }
125
+ },
126
+ {
127
+ "id": 6,
128
+ "run_id": "run-4e2329b555864957bc5b477ae1432717",
129
+ "reservation": 32000,
130
+ "charged": 8183,
131
+ "state": "settled",
132
+ "provider": "bailian-qwen3.8-max",
133
+ "prompt_digest": "ce8167361acb92254e3de1a1a1b6a1d64976042c3f2a12deed177c18f7294bca",
134
+ "metadata": {
135
+ "finish_reason": "stop",
136
+ "model": "qwen3.8-max",
137
+ "policy_version": "bailian-task-routing-v2",
138
+ "request_id": "chatcmpl-f2995fff-4705-9edf-9072-766d3dcfb34c",
139
+ "requested_output_tokens": 11849,
140
+ "retry_of": null,
141
+ "route_reason": "diagnostic-repair",
142
+ "stage": "repair"
143
+ }
144
+ }
145
+ ],
146
+ "repairs": 1
147
+ },
148
+ "pdf": {
149
+ "id": "run-415025244a2a42f09cb63bc4e17902ca",
150
+ "status": "verified",
151
+ "error": null,
152
+ "model_calls": [
153
+ {
154
+ "id": 11,
155
+ "run_id": "run-415025244a2a42f09cb63bc4e17902ca",
156
+ "reservation": 17625,
157
+ "charged": 4747,
158
+ "state": "settled",
159
+ "provider": "bailian-qwen3.8-flash",
160
+ "prompt_digest": "1883f3a2c0f255c592dddef1559993e05cf7eb47499d603d82982493e8ea63c2",
161
+ "metadata": {
162
+ "finish_reason": "stop",
163
+ "model": "qwen3.8-flash",
164
+ "policy_version": "bailian-task-routing-v2",
165
+ "request_id": "chatcmpl-df9c9b8a-441c-9a3b-a7b6-30b34a91302b",
166
+ "requested_output_tokens": 2048,
167
+ "retry_of": null,
168
+ "route_reason": "technical-design",
169
+ "stage": "design"
170
+ }
171
+ },
172
+ {
173
+ "id": 12,
174
+ "run_id": "run-415025244a2a42f09cb63bc4e17902ca",
175
+ "reservation": 21598,
176
+ "charged": 5126,
177
+ "state": "settled",
178
+ "provider": "bailian-qwen3.8-max",
179
+ "prompt_digest": "71bbb2934c2e069cb8638b383a568cda6d0f40baf000d0ef6f1196a268be9676",
180
+ "metadata": {
181
+ "finish_reason": "stop",
182
+ "model": "qwen3.8-max",
183
+ "policy_version": "bailian-task-routing-v2",
184
+ "request_id": "chatcmpl-91d41343-d438-9ae0-981f-2a8a6c41fdee",
185
+ "requested_output_tokens": 12288,
186
+ "retry_of": null,
187
+ "route_reason": "dependency-code",
188
+ "stage": "code"
189
+ }
190
+ },
191
+ {
192
+ "id": 13,
193
+ "run_id": "run-415025244a2a42f09cb63bc4e17902ca",
194
+ "reservation": 27804,
195
+ "charged": 7267,
196
+ "state": "settled",
197
+ "provider": "bailian-qwen3.8-max",
198
+ "prompt_digest": "7b04c1c06dd33d0632ea85c7ea1c4aa23a72dbb25ddc6d9203e49d69911356cc",
199
+ "metadata": {
200
+ "finish_reason": "stop",
201
+ "model": "qwen3.8-max",
202
+ "policy_version": "bailian-task-routing-v2",
203
+ "request_id": "chatcmpl-aef13472-7cab-953b-9f71-13de021222ce",
204
+ "requested_output_tokens": 12288,
205
+ "retry_of": null,
206
+ "route_reason": "diagnostic-repair",
207
+ "stage": "repair"
208
+ }
209
+ }
210
+ ],
211
+ "repairs": 1
212
+ }
213
+ },
214
+ "user_reported_failures": [
215
+ {
216
+ "id": "run-2412663dc99d48ea8e7f742e3e8ddf4a",
217
+ "status": "failed",
218
+ "error": "JAVA_TEST_FAILED",
219
+ "model_calls": [
220
+ {
221
+ "id": 7,
222
+ "run_id": "run-2412663dc99d48ea8e7f742e3e8ddf4a",
223
+ "reservation": 18500,
224
+ "charged": 5053,
225
+ "state": "settled",
226
+ "provider": "bailian-qwen3.8-flash",
227
+ "prompt_digest": "7c70979245d24ec3e5bcf18b9b65ff261b4a0f70842683dca78337e99a3b90ed",
228
+ "metadata": {
229
+ "finish_reason": "stop",
230
+ "model": "qwen3.8-flash",
231
+ "policy_version": "bailian-task-routing-v2",
232
+ "request_id": "chatcmpl-9d60404d-f005-93ee-b09c-19149415977c",
233
+ "requested_output_tokens": 2048,
234
+ "retry_of": null,
235
+ "route_reason": "technical-design",
236
+ "stage": "design"
237
+ }
238
+ },
239
+ {
240
+ "id": 8,
241
+ "run_id": "run-2412663dc99d48ea8e7f742e3e8ddf4a",
242
+ "reservation": 18279,
243
+ "charged": 4351,
244
+ "state": "settled",
245
+ "provider": "bailian-qwen3.8-max",
246
+ "prompt_digest": "5cbcb6df8bf5a82c7eb6085980507fab390f4b72fd6e32332f844d94f240aae8",
247
+ "metadata": {
248
+ "finish_reason": "stop",
249
+ "model": "qwen3.8-max",
250
+ "policy_version": "bailian-task-routing-v2",
251
+ "request_id": "chatcmpl-5258181e-e8eb-95f0-b2b0-1255f4ecf824",
252
+ "requested_output_tokens": 8192,
253
+ "retry_of": null,
254
+ "route_reason": "java-code",
255
+ "stage": "code"
256
+ }
257
+ },
258
+ {
259
+ "id": 9,
260
+ "run_id": "run-2412663dc99d48ea8e7f742e3e8ddf4a",
261
+ "reservation": 25703,
262
+ "charged": 5584,
263
+ "state": "settled",
264
+ "provider": "bailian-qwen3.8-max",
265
+ "prompt_digest": "abb2ea19ec4576e5d234335e9295e7004f818bb088ee42f1961c8defc96a2cd7",
266
+ "metadata": {
267
+ "finish_reason": "stop",
268
+ "model": "qwen3.8-max",
269
+ "policy_version": "bailian-task-routing-v2",
270
+ "request_id": "chatcmpl-743a8174-c405-9e10-a500-8651846be70c",
271
+ "requested_output_tokens": 12288,
272
+ "retry_of": null,
273
+ "route_reason": "diagnostic-repair",
274
+ "stage": "repair"
275
+ }
276
+ },
277
+ {
278
+ "id": 10,
279
+ "run_id": "run-2412663dc99d48ea8e7f742e3e8ddf4a",
280
+ "reservation": 25466,
281
+ "charged": 5495,
282
+ "state": "settled",
283
+ "provider": "bailian-qwen3.8-max",
284
+ "prompt_digest": "04fbf6c8bbb6a33c4f0cf7c62c606e65cdc2c574edc99c47826d4c5c0bad8868",
285
+ "metadata": {
286
+ "finish_reason": "stop",
287
+ "model": "qwen3.8-max",
288
+ "policy_version": "bailian-task-routing-v2",
289
+ "request_id": "chatcmpl-8adb4633-994d-9d33-a93d-d36dc4be087a",
290
+ "requested_output_tokens": 12288,
291
+ "retry_of": null,
292
+ "route_reason": "diagnostic-repair",
293
+ "stage": "repair"
294
+ }
295
+ }
296
+ ],
297
+ "repairs": 2,
298
+ "diagnostics": {
299
+ "failures": [
300
+ {
301
+ "actual_body": "{\"error\":\"INVALID_INPUT\"}",
302
+ "actual_status": 400,
303
+ "case_index": 25,
304
+ "expected_status": 422,
305
+ "path": "/api/calculate?expression64=MSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsx",
306
+ "reason": "response_did_not_match_public_contract"
307
+ }
308
+ ]
309
+ }
310
+ },
311
+ {
312
+ "id": "run-9be8f3949f9d49e79687b137b51f6bb3",
313
+ "status": "failed",
314
+ "error": "JAVA_TEST_FAILED",
315
+ "model_calls": [
316
+ {
317
+ "id": 14,
318
+ "run_id": "run-9be8f3949f9d49e79687b137b51f6bb3",
319
+ "reservation": 18686,
320
+ "charged": 5285,
321
+ "state": "settled",
322
+ "provider": "bailian-qwen3.8-flash",
323
+ "prompt_digest": "87d86e78a1a48085002ff18fa3b9a96ce5f4d70323fae2455327203f5e98ab76",
324
+ "metadata": {
325
+ "finish_reason": "stop",
326
+ "model": "qwen3.8-flash",
327
+ "policy_version": "bailian-task-routing-v2",
328
+ "request_id": "chatcmpl-c2457e9f-abf3-9e1f-b94a-372e15964314",
329
+ "requested_output_tokens": 2048,
330
+ "retry_of": null,
331
+ "route_reason": "technical-design",
332
+ "stage": "design"
333
+ }
334
+ },
335
+ {
336
+ "id": 15,
337
+ "run_id": "run-9be8f3949f9d49e79687b137b51f6bb3",
338
+ "reservation": 30865,
339
+ "charged": 6910,
340
+ "state": "settled",
341
+ "provider": "bailian-qwen3.8-max",
342
+ "prompt_digest": "8290bb1638b8b2e099472b8bc7e8ff8122fdded446641ad54bb3a3a0d36be398",
343
+ "metadata": {
344
+ "finish_reason": "stop",
345
+ "model": "qwen3.8-max",
346
+ "policy_version": "bailian-task-routing-v2",
347
+ "request_id": "chatcmpl-f3aaadc0-ee6d-93d3-abb0-ab678109a6f1",
348
+ "requested_output_tokens": 12288,
349
+ "retry_of": null,
350
+ "route_reason": "diagnostic-repair",
351
+ "stage": "code"
352
+ }
353
+ },
354
+ {
355
+ "id": 16,
356
+ "run_id": "run-9be8f3949f9d49e79687b137b51f6bb3",
357
+ "reservation": 25489,
358
+ "charged": 5516,
359
+ "state": "settled",
360
+ "provider": "bailian-qwen3.8-max",
361
+ "prompt_digest": "7e5f008d5cb72e4eb837c379cf3b3401f09140674c3e3837fa86c73bc8a47e4c",
362
+ "metadata": {
363
+ "finish_reason": "stop",
364
+ "model": "qwen3.8-max",
365
+ "policy_version": "bailian-task-routing-v2",
366
+ "request_id": "chatcmpl-74ae7d52-b129-9de0-b0f4-69cc65b2363b",
367
+ "requested_output_tokens": 12288,
368
+ "retry_of": null,
369
+ "route_reason": "diagnostic-repair",
370
+ "stage": "repair"
371
+ }
372
+ },
373
+ {
374
+ "id": 17,
375
+ "run_id": "run-9be8f3949f9d49e79687b137b51f6bb3",
376
+ "reservation": 25489,
377
+ "charged": 5516,
378
+ "state": "settled",
379
+ "provider": "bailian-qwen3.8-max",
380
+ "prompt_digest": "7e5f008d5cb72e4eb837c379cf3b3401f09140674c3e3837fa86c73bc8a47e4c",
381
+ "metadata": {
382
+ "finish_reason": "stop",
383
+ "model": "qwen3.8-max",
384
+ "policy_version": "bailian-task-routing-v2",
385
+ "request_id": "chatcmpl-d57bfdcc-c995-95c2-b278-15b9096de631",
386
+ "requested_output_tokens": 12288,
387
+ "retry_of": null,
388
+ "route_reason": "diagnostic-repair",
389
+ "stage": "repair"
390
+ }
391
+ }
392
+ ],
393
+ "repairs": 2,
394
+ "diagnostics": {
395
+ "failures": [
396
+ {
397
+ "actual_body": "{\"error\":\"INVALID_INPUT\"}",
398
+ "actual_status": 400,
399
+ "case_index": 25,
400
+ "expected_status": 422,
401
+ "path": "/api/calculate?expression64=MSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsxKzErMSsx",
402
+ "reason": "response_did_not_match_public_contract"
403
+ }
404
+ ]
405
+ }
406
+ }
407
+ ]
408
+ }
examples/hf-generated/calculator/design.md ADDED
@@ -0,0 +1 @@
 
 
1
+ Implement demo.App using Java 17 com.sun.net.httpserver.HttpServer on port 8080. Single-threaded bounded executor. Root handler routes: /health (GET->200 {"status":"ok"}), /api/calculate (GET only, else 405). Calculate requires Authorization header 'Bearer demo-calculator' (else 401). Query param expression64 must be exactly one non-empty key; value is unpadded base64url of UTF-8 expression. Validate encoded length <=256 and decoded length <=128. Use CharsetDecoder REPORT for strict UTF-8. Recursive descent parser: sum=product((+|-)product)*, product=unary((*|/)unary)*, unary=(+|-)*atom, atom=number|(sum). Numbers: digits(.digits+)? or .digits+. Allow spaces between tokens. Enforce limits: depth<=16, ops<=64, literal digits<=24, abs(value)<=1e24. Evaluate with BigDecimal DECIMAL128. Division by zero -> 400 DIVISION_BY_ZERO. Parse/Limit errors -> 400 INVALID_EXPRESSION or 422 LIMIT_EXCEEDED. Final result: round HALF_UP scale 12, strip trailing zeros, toPlainString. Return JSON {"expression":"...","result":"..."}. Close exchanges.
examples/hf-generated/calculator/requirement.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DEMO-CALC-01:可操作的网页计算器
2
+
3
+ ## 背景与用户
4
+ 员工需要在内网快速核算公式,现有简单输入框不能解释优先级或处理错误。本场景交付可直接使用的计算器网站,运算由Java服务执行,页面负责输入和结果展示。
5
+
6
+ ## 页面与交互
7
+ 标题“工程计算器”,主卡片包含表达式输入框、结果显示区、数字键盘0–9、小数点、加减乘除、左右括号、退格、清空和等号;旁边显示最近10条成功计算记录,窄屏放到下方。默认示例(12.5+7.5)*3,等于60。历史记录点击后回填输入,不自动重新执行。
8
+ 物理键盘可输入公式,Enter计算,Escape清空;每个按钮有明确标签,焦点可见。计算时按钮显示忙碌且防止重复请求;服务返回后再显示结果,不演示虚假延迟。除零或非法表达式在结果区给可理解错误并保留输入。成功结果可作为下次运算起点;结果字符串可复制。
9
+ 修改输入、历史回填或清空后,旧结果与复制状态立即失效,重新计算后才能复制。应用只展示输入、结果、历史和业务错误,不显示原始接口JSON、源码摘要、沙箱步骤或代码下载;开发证据保留在工作台。预览准备由平台内部完成,成果页面使用独立端口。
10
+
11
+ ## 编程需求与验收
12
+ - CALC-01:Java17标准库HttpServer,GET /health。GET /api/calculate的唯一参数expression64为UTF-8表达式的无填充base64url;公开凭据demo-calculator,不接受任意脚本、eval或脚本引擎。
13
+ - CALC-02:实现真正的表达式解析,支持+-*/、括号、空格、一元正负。乘除优先于加减,括号优先。2+3*4=14,(2+3)*4=20,-3+5=2。
14
+ - CALC-03:用BigDecimal和DECIMAL128处理中间运算,最终最多12位小数,HALF_UP,去除尾零,不用科学记数法。0.1+0.2=0.3;1/3显示0.333333333333;连续运算可使用上次结果。
15
+ - CALC-04:除零400 DIVISION_BY_ZERO;缺括号、连续非法运算、字母等400 INVALID_EXPRESSION;1+-2、--1属于合法一元符号。缺失、重复、未知参数及非法编码400 INVALID_INPUT。
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执行结果。
27
+
28
+
29
+ HF验收批次 20261024T043922Z calculator。完整实现上述需求;模型、框架和权限仍由服务端冻结契约决定。
examples/hf-generated/calculator/src/main/java/demo/App.java ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package demo;
2
+
3
+ import com.sun.net.httpserver.HttpServer;
4
+ import com.sun.net.httpserver.HttpExchange;
5
+ import java.io.*;
6
+ import java.math.*;
7
+ import java.net.InetSocketAddress;
8
+ import java.nio.ByteBuffer;
9
+ import java.nio.CharBuffer;
10
+ import java.nio.charset.*;
11
+ import java.util.Base64;
12
+ import java.util.concurrent.Executors;
13
+
14
+ public class App {
15
+ static final BigDecimal LIM = new BigDecimal("1e24");
16
+ static int ops, depth;
17
+
18
+ public static void main(String[] args) throws Exception {
19
+ HttpServer s = HttpServer.create(new InetSocketAddress(8080), 0);
20
+ s.setExecutor(Executors.newFixedThreadPool(1));
21
+ s.createContext("/", App::handle);
22
+ s.start();
23
+ }
24
+
25
+ static void handle(HttpExchange x) throws IOException {
26
+ try {
27
+ String p = x.getRequestURI().getPath();
28
+ if ("/health".equals(p)) {
29
+ if (!"GET".equals(x.getRequestMethod())) { send(x,405,"{\"error\":\"METHOD_NOT_ALLOWED\"}"); return; }
30
+ send(x,200,"{\"status\":\"ok\"}"); return;
31
+ }
32
+ if ("/api/calculate".equals(p)) {
33
+ if (!"GET".equals(x.getRequestMethod())) { send(x,405,"{\"error\":\"METHOD_NOT_ALLOWED\"}"); return; }
34
+ String auth = x.getRequestHeaders().getFirst("Authorization");
35
+ if (!"Bearer demo-calculator".equals(auth)) { send(x,401,"{\"error\":\"UNAUTHORIZED\"}"); return; }
36
+ calc(x); return;
37
+ }
38
+ send(x,404,"{\"error\":\"NOT_FOUND\"}");
39
+ } finally { x.close(); }
40
+ }
41
+
42
+ static void calc(HttpExchange x) throws IOException {
43
+ String q = x.getRequestURI().getRawQuery();
44
+ if (q == null || q.isEmpty()) { send(x,400,"{\"error\":\"INVALID_INPUT\"}"); return; }
45
+ String[] parts = q.split("&");
46
+ String enc = null;
47
+ for (String part : parts) {
48
+ int eq = part.indexOf('=');
49
+ String key = eq >= 0 ? part.substring(0, eq) : part;
50
+ if (!"expression64".equals(key)) { send(x,400,"{\"error\":\"INVALID_INPUT\"}"); return; }
51
+ if (enc != null) { send(x,400,"{\"error\":\"INVALID_INPUT\"}"); return; }
52
+ enc = eq >= 0 ? part.substring(eq + 1) : "";
53
+ }
54
+ if (enc == null || enc.isEmpty() || enc.length() > 256 || !enc.matches("[A-Za-z0-9_-]+")) { send(x,400,"{\"error\":\"INVALID_INPUT\"}"); return; }
55
+ byte[] b;
56
+ try { b = Base64.getUrlDecoder().decode(enc); } catch (Exception e) { send(x,400,"{\"error\":\"INVALID_INPUT\"}"); return; }
57
+ CharsetDecoder d = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
58
+ CharBuffer cb;
59
+ try { cb = d.decode(ByteBuffer.wrap(b)); } catch (Exception e) { send(x,400,"{\"error\":\"INVALID_INPUT\"}"); return; }
60
+ String expr = cb.toString();
61
+ if (expr.length() > 128) { send(x,422,"{\"error\":\"LIMIT_EXCEEDED\"}"); return; }
62
+ if (expr.isEmpty()) { send(x,400,"{\"error\":\"INVALID_EXPRESSION\"}"); return; }
63
+ for (int i = 0; i < expr.length(); i++) {
64
+ char c = expr.charAt(i);
65
+ if (!((c >= '0' && c <= '9') || c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == ')' || c == '.' || c == ' ')) {
66
+ send(x,400,"{\"error\":\"INVALID_EXPRESSION\"}"); return;
67
+ }
68
+ }
69
+ ops = 0; depth = 0;
70
+ try {
71
+ int[] pos = {0};
72
+ BigDecimal r = parseSum(expr, pos);
73
+ skip(expr, pos);
74
+ if (pos[0] < expr.length()) throw new RuntimeException("X");
75
+ r = r.setScale(12, RoundingMode.HALF_UP).stripTrailingZeros();
76
+ String rs = r.compareTo(BigDecimal.ZERO) == 0 ? "0" : r.toPlainString();
77
+ send(x,200,"{\"expression\":\"" + jesc(expr) + "\",\"result\":\"" + rs + "\"}");
78
+ } catch (RuntimeException e) {
79
+ String m = e.getMessage();
80
+ if ("D".equals(m)) send(x,400,"{\"error\":\"DIVISION_BY_ZERO\"}");
81
+ else if ("L".equals(m)) send(x,422,"{\"error\":\"LIMIT_EXCEEDED\"}");
82
+ else send(x,400,"{\"error\":\"INVALID_EXPRESSION\"}");
83
+ }
84
+ }
85
+
86
+ static void skip(String s, int[] p) { while (p[0] < s.length() && s.charAt(p[0]) == ' ') p[0]++; }
87
+
88
+ static BigDecimal parseSum(String s, int[] p) {
89
+ BigDecimal l = parseProd(s, p);
90
+ while (true) {
91
+ skip(s, p);
92
+ if (p[0] >= s.length()) break;
93
+ char c = s.charAt(p[0]);
94
+ if (c != '+' && c != '-') break;
95
+ p[0]++; if (++ops > 64) throw new RuntimeException("L");
96
+ BigDecimal r = parseProd(s, p);
97
+ l = c == '+' ? l.add(r, MathContext.DECIMAL128) : l.subtract(r, MathContext.DECIMAL128);
98
+ chk(l);
99
+ }
100
+ return l;
101
+ }
102
+
103
+ static BigDecimal parseProd(String s, int[] p) {
104
+ BigDecimal l = parseUnary(s, p);
105
+ while (true) {
106
+ skip(s, p);
107
+ if (p[0] >= s.length()) break;
108
+ char c = s.charAt(p[0]);
109
+ if (c != '*' && c != '/') break;
110
+ p[0]++; if (++ops > 64) throw new RuntimeException("L");
111
+ BigDecimal r = parseUnary(s, p);
112
+ if (c == '*') { l = l.multiply(r, MathContext.DECIMAL128); chk(l); }
113
+ else { if (r.signum() == 0) throw new RuntimeException("D"); l = l.divide(r, MathContext.DECIMAL128); chk(l); }
114
+ }
115
+ return l;
116
+ }
117
+
118
+ static BigDecimal parseUnary(String s, int[] p) {
119
+ skip(s, p); if (p[0] >= s.length()) throw new RuntimeException("X");
120
+ char c = s.charAt(p[0]);
121
+ if (c == '+' || c == '-') {
122
+ p[0]++; if (++ops > 64) throw new RuntimeException("L");
123
+ BigDecimal v = parseUnary(s, p);
124
+ return c == '-' ? v.negate(MathContext.DECIMAL128) : v;
125
+ }
126
+ return parseAtom(s, p);
127
+ }
128
+
129
+ static BigDecimal parseAtom(String s, int[] p) {
130
+ skip(s, p); if (p[0] >= s.length()) throw new RuntimeException("X");
131
+ if (s.charAt(p[0]) == '(') {
132
+ p[0]++; if (++depth > 16) throw new RuntimeException("L");
133
+ BigDecimal v = parseSum(s, p);
134
+ skip(s, p); if (p[0] >= s.length() || s.charAt(p[0]) != ')') throw new RuntimeException("X");
135
+ p[0]++; depth--; return v;
136
+ }
137
+ return parseNum(s, p);
138
+ }
139
+
140
+ static BigDecimal parseNum(String s, int[] p) {
141
+ skip(s, p); int st = p[0], dots = 0, digits = 0;
142
+ if (p[0] >= s.length()) throw new RuntimeException("X");
143
+ char first = s.charAt(p[0]);
144
+ if (first == '.') {
145
+ dots++; p[0]++;
146
+ if (p[0] >= s.length() || s.charAt(p[0]) < '0' || s.charAt(p[0]) > '9') throw new RuntimeException("X");
147
+ while (p[0] < s.length() && s.charAt(p[0]) >= '0' && s.charAt(p[0]) <= '9') { digits++; p[0]++; }
148
+ } else if (first >= '0' && first <= '9') {
149
+ while (p[0] < s.length() && s.charAt(p[0]) >= '0' && s.charAt(p[0]) <= '9') { digits++; p[0]++; }
150
+ if (p[0] < s.length() && s.charAt(p[0]) == '.') {
151
+ dots++; p[0]++;
152
+ if (p[0] >= s.length() || s.charAt(p[0]) < '0' || s.charAt(p[0]) > '9') throw new RuntimeException("X");
153
+ while (p[0] < s.length() && s.charAt(p[0]) >= '0' && s.charAt(p[0]) <= '9') { digits++; p[0]++; }
154
+ }
155
+ } else { throw new RuntimeException("X"); }
156
+ if (digits > 24) throw new RuntimeException("L");
157
+ String ns = s.substring(st, p[0]);
158
+ BigDecimal v = new BigDecimal(ns); chk(v); return v;
159
+ }
160
+
161
+ static void chk(BigDecimal v) { if (v.abs().compareTo(LIM) > 0) throw new RuntimeException("L"); }
162
+ static String jesc(String s) { return s.replace("\\","\\\\").replace("\"","\\\""); }
163
+ static void send(HttpExchange x, int c, String b) throws IOException {
164
+ byte[] d = b.getBytes(StandardCharsets.UTF_8);
165
+ x.getResponseHeaders().set("Content-Type","application/json;charset=utf-8");
166
+ x.sendResponseHeaders(c, d.length);
167
+ x.getResponseBody().write(d);
168
+ }
169
+ }
examples/hf-generated/calculator/validation-evidence.json ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "generation": {
3
+ "digest": "36c265b7880d88aef196b0c79becf66867e7b36635adb870c6d308f5610c2b31",
4
+ "manifest": {
5
+ "approvals": [
6
+ {
7
+ "authorization_ref": "local-web-delegation-v1:user-c3adb31fc78c4d59970af883326ccff5",
8
+ "digest": "2185bc60b2d41acb5bc706360467db1a6a92ca1b6bffa32d3f11dd924c165f01",
9
+ "increment": true,
10
+ "mechanism": "delegated_local_validation",
11
+ "node": "design_confirm",
12
+ "scope": "design",
13
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
14
+ },
15
+ {
16
+ "authorization_ref": "local-web-delegation-v1:user-c3adb31fc78c4d59970af883326ccff5",
17
+ "digest": "38db1a18ea15453d78e47350e8d23fadabbe2966d3b4476d1382dd63b558db82",
18
+ "increment": true,
19
+ "mechanism": "delegated_local_validation",
20
+ "node": "execution_confirm",
21
+ "scope": "execution",
22
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
23
+ },
24
+ {
25
+ "authorization_ref": "local-web-delegation-v1:user-c3adb31fc78c4d59970af883326ccff5",
26
+ "digest": "edf9d2f157a0fc72ca9e42ec5c9f26331ac60b480e8b3f1cde13ccd498f98b40",
27
+ "increment": false,
28
+ "mechanism": "delegated_local_validation",
29
+ "node": "repair-execution",
30
+ "scope": "execution",
31
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
32
+ }
33
+ ],
34
+ "candidate": {
35
+ "classes_digest": "31888e310a086e6807cc096b7bdb06164ae9a556c8f582228d9e9d7b43b0b6cf",
36
+ "config_digest": "af40be185fe8b9dd8ecdd495a0785520aaebb54ebbabe97f18813d611f001e9f",
37
+ "container": "zk-run-4e2329b555864957bc5b477ae1432717",
38
+ "execution_mode": "qemu",
39
+ "image": "zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
40
+ "isolation": {
41
+ "disposable": true,
42
+ "host_mounts": [],
43
+ "memory_mb": 1024,
44
+ "network": "none",
45
+ "vcpu": 1
46
+ },
47
+ "passed": true,
48
+ "receipt_digest": "4dd3a2513810493814d30734778f363391f33f14915fc48ee7b5e694be63ef2d",
49
+ "receipt_ref": "run-4e2329b555864957bc5b477ae1432717-1026975a6b7245aeb6e369a5fc51c7a7",
50
+ "source_digest": "e1c26eeccec092a09b3481bc6f601f6f02b043b0e0e41219ff67a2e295b6a798",
51
+ "stage": "build",
52
+ "suite_digest": "05e353f239f8919946d419e91e63fedccbf62b02386fa12f39ad8795b6a4de4d",
53
+ "tool_receipt": {
54
+ "input_digest": "31692445e2704451320643e524b2f5001058816b7a4ca7fd9eada1444c66e9b4",
55
+ "operation": "AO08",
56
+ "result_digest": "0d207246d95b5b06b3832196f880cba8e0fcdbaa11276f5b8162752cf5188d8d",
57
+ "run_id": "run-4e2329b555864957bc5b477ae1432717"
58
+ }
59
+ },
60
+ "deployment": "not_performed",
61
+ "development": {
62
+ "design": {
63
+ "summary": "Implement demo.App using Java 17 com.sun.net.httpserver.HttpServer on port 8080. Single-threaded bounded executor. Root handler routes: /health (GET->200 {\"status\":\"ok\"}), /api/calculate (GET only, else 405). Calculate requires Authorization header 'Bearer demo-calculator' (else 401). Query param expression64 must be exactly one non-empty key; value is unpadded base64url of UTF-8 expression. Validate encoded length <=256 and decoded length <=128. Use CharsetDecoder REPORT for strict UTF-8. Recursive descent parser: sum=product((+|-)product)*, product=unary((*|/)unary)*, unary=(+|-)*atom, atom=number|(sum). Numbers: digits(.digits+)? or .digits+. Allow spaces between tokens. Enforce limits: depth<=16, ops<=64, literal digits<=24, abs(value)<=1e24. Evaluate with BigDecimal DECIMAL128. Division by zero -> 400 DIVISION_BY_ZERO. Parse/Limit errors -> 400 INVALID_EXPRESSION or 422 LIMIT_EXCEEDED. Final result: round HALF_UP scale 12, strip trailing zeros, toPlainString. Return JSON {\"expression\":\"...\",\"result\":\"...\"}. Close exchanges."
64
+ },
65
+ "requirement": "# DEMO-CALC-01:可操作的网页计算器\n\n## 背景与用户\n员工需要在内网快速核算公式,现有简单输入框不能解释优先级或处理错误。本场景交付可直接使用的计算器网站,运算由Java服务执行,页面负责输入和结果展示。\n\n## 页面与交互\n标题“工程计算器”,主卡片包含表达式输入框、结果显示区、数字键盘0–9、小数点、加减乘除、左右括号、退格、清空和等号;旁边显示最近10条成功计算记录,窄屏放到下方。默认示例(12.5+7.5)*3,等于60。历史记录点击后回填输入,不自动重新执行。\n物理键盘可输入公式,Enter计算,Escape清空;每个按钮有明确标签,焦点可见。计算时按钮显示忙碌且防止重复请求;服务返回后再显示结果,不演示虚假延迟。除零或非法表达式在结果区给可理解错误并保留输入。成功结果可作为下次运算起点;结果字符串可复制。\n修改输入、历史回填或清空后,��结果与复制状态立即失效,重新计算后才能复制。应用只展示输入、结果、历史和业务错误,不显示原始接口JSON、源码摘要、沙箱步骤或代码下载;开发证据保留在工作台。预览准备由平台内部完成,成果页面使用独立端口。\n\n## 编程需求与验收\n- CALC-01:Java17标准库HttpServer,GET /health。GET /api/calculate的唯一参数expression64为UTF-8表达式的无填充base64url;公开凭据demo-calculator,不接受任意脚本、eval或脚本引擎。\n- CALC-02:实现真正的表达式解析,支持+-*/、括号、空格、一元正负。乘除优先于加减,括号优先。2+3*4=14,(2+3)*4=20,-3+5=2。\n- CALC-03:用BigDecimal和DECIMAL128处理中间运算,最终最多12位小数,HALF_UP,去除尾零,不用科学记数法。0.1+0.2=0.3;1/3显示0.333333333333;连续运算可使用上次结果。\n- CALC-04:除零400 DIVISION_BY_ZERO;缺括号、连续非法运算、字母等400 INVALID_EXPRESSION;1+-2、--1属于合法一元符号。缺失、重复、未知参数及非法编码400 INVALID_INPUT。\n- CALC-05:表达式最多128字符、括号16层、64次运算;单个数字字面量最多24位(不含小数点),数值绝对值≤1e24;超限422 LIMIT_EXCEEDED。编码参数最多256字符,超限400 INVALID_INPUT。无身份401、非GET405、未知路径404,线程与输入有界。\n- CALC-06:独立HTTP系统测试覆盖算术、精度、结合顺序、负号、边界和错误;网页测试点击键盘与Enter、历史回填、连续运算、除零展示、窄屏布局。\n\n### 接口与Java实现补充约束\n\n成功和失败都必须返回UTF-8 JSON对象,不能直接返回错误码文本或HttpServer默认HTML。成功包络为`{\"expression\":\"原始表达式(保留空格)\",\"result\":\"结果字符串\"}`,错误包络统一为`{\"error\":\"对应错误码\"}`;未知路径也返回404 `{\"error\":\"NOT_FOUND\"}`。可注册统一根处理器,再精确匹配路径和方法,避免默认路由漏出HTML。\n\n数字语法为`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实际编译。此处是公开接口和编程约束,不允许修改保护测试。\n\n## 交付与完成条件\n交付Java源码、配套HTML/CSS/JS页面、需求与技术说明、差异、测试对应表、实际沙箱编译和测试证据、可下载ZIP及本地网站。生成源码限定src/main/java/demo/App.java及可选docs,不引入框架或修改保护测试;受控网页模板作为独立交付文件明确来源。失败必须留存诊断并修复复测,不以静态数字冒充Java执行结果。\n\n\nHF验收批次 20261024T043922Z calculator。完整实现上述需求;模型、框架和权限仍由服务端冻结契约决定。"
66
+ },
67
+ "human_acceptance": false,
68
+ "model_calls": [
69
+ {
70
+ "charged": 5039,
71
+ "id": 4,
72
+ "metadata": {
73
+ "finish_reason": "stop",
74
+ "model": "qwen3.8-flash",
75
+ "policy_version": "bailian-task-routing-v2",
76
+ "request_id": "chatcmpl-c7b411d6-6d06-9c14-ad89-5ac8aed95611",
77
+ "requested_output_tokens": 2048,
78
+ "retry_of": null,
79
+ "route_reason": "technical-design",
80
+ "stage": "design"
81
+ },
82
+ "prompt_digest": "f850c544aa2dbee7d723a05f19fc7af1aa1ca9c7b09a679bd1bb6a3ff24ae74a",
83
+ "provider": "bailian-qwen3.8-flash",
84
+ "reservation": 18638,
85
+ "run_id": "run-4e2329b555864957bc5b477ae1432717",
86
+ "state": "settled"
87
+ },
88
+ {
89
+ "charged": 4570,
90
+ "id": 5,
91
+ "metadata": {
92
+ "finish_reason": "stop",
93
+ "model": "qwen3.8-max",
94
+ "policy_version": "bailian-task-routing-v2",
95
+ "request_id": "chatcmpl-1dbf5d69-b11a-9c84-b24e-c4c36e18b516",
96
+ "requested_output_tokens": 8192,
97
+ "retry_of": null,
98
+ "route_reason": "java-code",
99
+ "stage": "code"
100
+ },
101
+ "prompt_digest": "ab6c2a18422f46dda202f1cc58889f3936a8f0c587dd88d6a5f009ea182245f4",
102
+ "provider": "bailian-qwen3.8-max",
103
+ "reservation": 18111,
104
+ "run_id": "run-4e2329b555864957bc5b477ae1432717",
105
+ "state": "settled"
106
+ },
107
+ {
108
+ "charged": 8183,
109
+ "id": 6,
110
+ "metadata": {
111
+ "finish_reason": "stop",
112
+ "model": "qwen3.8-max",
113
+ "policy_version": "bailian-task-routing-v2",
114
+ "request_id": "chatcmpl-f2995fff-4705-9edf-9072-766d3dcfb34c",
115
+ "requested_output_tokens": 11849,
116
+ "retry_of": null,
117
+ "route_reason": "diagnostic-repair",
118
+ "stage": "repair"
119
+ },
120
+ "prompt_digest": "ce8167361acb92254e3de1a1a1b6a1d64976042c3f2a12deed177c18f7294bca",
121
+ "provider": "bailian-qwen3.8-max",
122
+ "reservation": 32000,
123
+ "run_id": "run-4e2329b555864957bc5b477ae1432717",
124
+ "state": "settled"
125
+ }
126
+ ],
127
+ "preview": {
128
+ "cases": 1,
129
+ "classes_digest": "31888e310a086e6807cc096b7bdb06164ae9a556c8f582228d9e9d7b43b0b6cf",
130
+ "config_digest": "af40be185fe8b9dd8ecdd495a0785520aaebb54ebbabe97f18813d611f001e9f",
131
+ "container": "zk-run-4e2329b555864957bc5b477ae1432717",
132
+ "execution_mode": "qemu",
133
+ "image": "zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
134
+ "isolation": {
135
+ "disposable": true,
136
+ "host_mounts": [],
137
+ "memory_mb": 1024,
138
+ "network": "none",
139
+ "vcpu": 1
140
+ },
141
+ "passed": true,
142
+ "passed_cases": 1,
143
+ "preview_scope": "disposable-vm-loopback-http",
144
+ "receipt_digest": "4dd3a2513810493814d30734778f363391f33f14915fc48ee7b5e694be63ef2d",
145
+ "receipt_ref": "run-4e2329b555864957bc5b477ae1432717-1026975a6b7245aeb6e369a5fc51c7a7",
146
+ "source_digest": "e1c26eeccec092a09b3481bc6f601f6f02b043b0e0e41219ff67a2e295b6a798",
147
+ "stage": "preview",
148
+ "suite_digest": "05e353f239f8919946d419e91e63fedccbf62b02386fa12f39ad8795b6a4de4d",
149
+ "tool_receipt": {
150
+ "input_digest": "9095d3cf2d02a31d5379192aec8c3b3fce2d66a9998f864076c84b5097d63b9b",
151
+ "operation": "AO10",
152
+ "result_digest": "78ff00ddbdbaa345213f56545909e832b9e410230b0d1936dc0c8168a2de9857",
153
+ "run_id": "run-4e2329b555864957bc5b477ae1432717"
154
+ }
155
+ },
156
+ "repairs": 1,
157
+ "run_id": "run-4e2329b555864957bc5b477ae1432717",
158
+ "sandbox_cleaned": true,
159
+ "snapshot": {
160
+ "budget": {
161
+ "max_model_calls": 6,
162
+ "max_repairs": 2,
163
+ "max_seconds": 1800,
164
+ "max_tokens": 120000
165
+ },
166
+ "execution_order": [
167
+ "start",
168
+ "requirements",
169
+ "knowledge",
170
+ "context",
171
+ "design",
172
+ "design_confirm",
173
+ "execution_confirm",
174
+ "code",
175
+ "patch",
176
+ "policy",
177
+ "build",
178
+ "test",
179
+ "preview",
180
+ "acceptance",
181
+ "evidence",
182
+ "end"
183
+ ],
184
+ "execution_status": "not_started",
185
+ "framework": {
186
+ "allowed_paths": [
187
+ "src/main/",
188
+ "src/test/",
189
+ "docs/"
190
+ ],
191
+ "build_tool": "jdk",
192
+ "dependencies": {},
193
+ "evidence_refs": [
194
+ "local-toolchain:zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
195
+ "user-authorized-local-validation"
196
+ ],
197
+ "frontend": [
198
+ "html",
199
+ "javascript",
200
+ "css"
201
+ ],
202
+ "java_release": 17,
203
+ "language": "java",
204
+ "profile_id": "java17-standard-web",
205
+ "state": "approved",
206
+ "version": "0.1.0"
207
+ },
208
+ "knowledge": [
209
+ {
210
+ "collection_id": "java-basics",
211
+ "digest": "6de6f354ff0e845da78ad210164775f51d9a4c5f01a1e5e355911423bd6a5b5c",
212
+ "enterprise_approved": false,
213
+ "quality_status": "imported_unreviewed",
214
+ "revision": "corpus-6de6f354ff0e845da78ad210",
215
+ "scope": "reference"
216
+ },
217
+ {
218
+ "collection_id": "java-patterns",
219
+ "digest": "803bd1aef5f0764242a56a8c85a3eca81b26cebbe4ec3e6b53d3c4da8864aa2d",
220
+ "enterprise_approved": false,
221
+ "quality_status": "imported_unreviewed",
222
+ "revision": "corpus-803bd1aef5f0764242a56a8c",
223
+ "scope": "reference"
224
+ },
225
+ {
226
+ "collection_id": "web-development",
227
+ "digest": "84c82986259278c89a30d2660f66454f0a5bcb10f871c96c7ec4ea9ebb47e02a",
228
+ "enterprise_approved": false,
229
+ "quality_status": "imported_unreviewed",
230
+ "revision": "corpus-84c82986259278c89a30d266",
231
+ "scope": "reference"
232
+ },
233
+ {
234
+ "collection_id": "java-frameworks",
235
+ "digest": "28b65fe6ced6682555c8b32b676faf14020011ea525eeee57f17562acd17da4c",
236
+ "enterprise_approved": false,
237
+ "quality_status": "imported_unreviewed",
238
+ "revision": "corpus-28b65fe6ced6682555c8b32b",
239
+ "scope": "reference"
240
+ },
241
+ {
242
+ "collection_id": "java-persistence",
243
+ "digest": "972ee7e1f0072e413bec262b67b8af46364ff8aac445a9faeeeb8c041eb07f92",
244
+ "enterprise_approved": false,
245
+ "quality_status": "imported_unreviewed",
246
+ "revision": "corpus-972ee7e1f0072e413bec262b",
247
+ "scope": "reference"
248
+ },
249
+ {
250
+ "collection_id": "java-testing",
251
+ "digest": "8af9017057c130eef9f9a1617a2654859ba80ed4f108b28054aecf14a3d39c45",
252
+ "enterprise_approved": false,
253
+ "quality_status": "imported_unreviewed",
254
+ "revision": "corpus-8af9017057c130eef9f9a161",
255
+ "scope": "reference"
256
+ },
257
+ {
258
+ "collection_id": "java-integration",
259
+ "digest": "befde1177fa13476703d89a8df3902d90ad01cb7d497d0583cfe15620348c7b1",
260
+ "enterprise_approved": false,
261
+ "quality_status": "imported_unreviewed",
262
+ "revision": "corpus-befde1177fa13476703d89a8",
263
+ "scope": "reference"
264
+ }
265
+ ],
266
+ "operations_lock": {
267
+ "AO01@0.1.0": "6f2a89d1624450c6e4afd8f776f23c7df4bf402976a82d0992dfd6cfdc643bf2",
268
+ "AO02@0.1.0": "6a4491053f9a3f55d900f3f907f81a0cfc44f09a1e2f1e770248287bc0b8d7f6",
269
+ "AO03@0.1.0": "8a1387e065674c2987930ad865a2bdb4ab7346cb589505c350c6bb1907a7eb6d",
270
+ "AO04@0.1.0": "3ef3f1be1b0f9240f066fa6d0b3b1430026d55763d15b5fc584a801c64be688b",
271
+ "AO05@0.2.0": "eeac70849a9d8bebd00b1d2111545f9376cc6901f6aa611412b1cb73238e47a7",
272
+ "AO06@0.1.0": "2b369879ba0cd2847c173cfb7cb583c1dc051553d3d3ea80f954c81c21f1f233",
273
+ "AO07@0.1.0": "69e1e824b4c5129f62595ac3df578eec7b083411cd391a72d47303eec3843baa",
274
+ "AO08@0.1.0": "1d75566610ac000990fd15b9fd18a6518de8af12a329b3c56d51ff29c0c30623",
275
+ "AO09@0.1.0": "2e4bf4b3fcdfce184b8dea9ffebd18ffe91af7320b0ef3ce430edb3b5cc15c52",
276
+ "AO10@0.1.0": "d05863bea57e94ad860696bd6ac85e072034f89f6f038f132c65b854dd366e9f",
277
+ "AO11@0.1.0": "43b910a51da7a58810d3890eb2305d80663db6a1c187b51466f8e396a94956f0"
278
+ },
279
+ "project_id": "calculator-demo",
280
+ "release_digest": "cd0772c131d61fe2a56f9905133408aa95fcce60b217d653046d8dde0ac4df77",
281
+ "release_ref": "calculator-java-development@local-cd0772c131d61fe2",
282
+ "snapshot_digest": "782fa08215f6847af85df3ff07d156838854a1bd8a8f5d714c45acfb744eaf91",
283
+ "snapshot_id": "snapshot-495b318d58424852a48358285fd9d075",
284
+ "source_digest": "44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
285
+ "tenant_id": "demo-tenant",
286
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
287
+ },
288
+ "source": {
289
+ "files": {
290
+ "src/main/java/demo/App.java": "package demo;\n\nimport com.sun.net.httpserver.HttpServer;\nimport com.sun.net.httpserver.HttpExchange;\nimport java.io.*;\nimport java.math.*;\nimport java.net.InetSocketAddress;\nimport java.nio.ByteBuffer;\nimport java.nio.CharBuffer;\nimport java.nio.charset.*;\nimport java.util.Base64;\nimport java.util.concurrent.Executors;\n\npublic class App {\n static final BigDecimal LIM = new BigDecimal(\"1e24\");\n static int ops, depth;\n\n public static void main(String[] args) throws Exception {\n HttpServer s = HttpServer.create(new InetSocketAddress(8080), 0);\n s.setExecutor(Executors.newFixedThreadPool(1));\n s.createContext(\"/\", App::handle);\n s.start();\n }\n\n static void handle(HttpExchange x) throws IOException {\n try {\n String p = x.getRequestURI().getPath();\n if (\"/health\".equals(p)) {\n if (!\"GET\".equals(x.getRequestMethod())) { send(x,405,\"{\\\"error\\\":\\\"METHOD_NOT_ALLOWED\\\"}\"); return; }\n send(x,200,\"{\\\"status\\\":\\\"ok\\\"}\"); return;\n }\n if (\"/api/calculate\".equals(p)) {\n if (!\"GET\".equals(x.getRequestMethod())) { send(x,405,\"{\\\"error\\\":\\\"METHOD_NOT_ALLOWED\\\"}\"); return; }\n String auth = x.getRequestHeaders().getFirst(\"Authorization\");\n if (!\"Bearer demo-calculator\".equals(auth)) { send(x,401,\"{\\\"error\\\":\\\"UNAUTHORIZED\\\"}\"); return; }\n calc(x); return;\n }\n send(x,404,\"{\\\"error\\\":\\\"NOT_FOUND\\\"}\");\n } finally { x.close(); }\n }\n\n static void calc(HttpExchange x) throws IOException {\n String q = x.getRequestURI().getRawQuery();\n if (q == null || q.isEmpty()) { send(x,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n String[] parts = q.split(\"&\");\n String enc = null;\n for (String part : parts) {\n int eq = part.indexOf('=');\n String key = eq >= 0 ? part.substring(0, eq) : part;\n if (!\"expression64\".equals(key)) { send(x,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n if (enc != null) { send(x,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n enc = eq >= 0 ? part.substring(eq + 1) : \"\";\n }\n if (enc == null || enc.isEmpty() || enc.length() > 256 || !enc.matches(\"[A-Za-z0-9_-]+\")) { send(x,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n byte[] b;\n try { b = Base64.getUrlDecoder().decode(enc); } catch (Exception e) { send(x,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n CharsetDecoder d = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);\n CharBuffer cb;\n try { cb = d.decode(ByteBuffer.wrap(b)); } catch (Exception e) { send(x,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n String expr = cb.toString();\n if (expr.length() > 128) { send(x,422,\"{\\\"error\\\":\\\"LIMIT_EXCEEDED\\\"}\"); return; }\n if (expr.isEmpty()) { send(x,400,\"{\\\"error\\\":\\\"INVALID_EXPRESSION\\\"}\"); return; }\n for (int i = 0; i < expr.length(); i++) {\n char c = expr.charAt(i);\n if (!((c >= '0' && c <= '9') || c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == ')' || c == '.' || c == ' ')) {\n send(x,400,\"{\\\"error\\\":\\\"INVALID_EXPRESSION\\\"}\"); return;\n }\n }\n ops = 0; depth = 0;\n try {\n int[] pos = {0};\n BigDecimal r = parseSum(expr, pos);\n skip(expr, pos);\n if (pos[0] < expr.length()) throw new RuntimeException(\"X\");\n r = r.setScale(12, RoundingMode.HALF_UP).stripTrailingZeros();\n String rs = r.compareTo(BigDecimal.ZERO) == 0 ? \"0\" : r.toPlainString();\n send(x,200,\"{\\\"expression\\\":\\\"\" + jesc(expr) + \"\\\",\\\"result\\\":\\\"\" + rs + \"\\\"}\");\n } catch (RuntimeException e) {\n String m = e.getMessage();\n if (\"D\".equals(m)) send(x,400,\"{\\\"error\\\":\\\"DIVISION_BY_ZERO\\\"}\");\n else if (\"L\".equals(m)) send(x,422,\"{\\\"error\\\":\\\"LIMIT_EXCEEDED\\\"}\");\n else send(x,400,\"{\\\"error\\\":\\\"INVALID_EXPRESSION\\\"}\");\n }\n }\n\n static void skip(String s, int[] p) { while (p[0] < s.length() && s.charAt(p[0]) == ' ') p[0]++; }\n\n static BigDecimal parseSum(String s, int[] p) {\n BigDecimal l = parseProd(s, p);\n while (true) {\n skip(s, p);\n if (p[0] >= s.length()) break;\n char c = s.charAt(p[0]);\n if (c != '+' && c != '-') break;\n p[0]++; if (++ops > 64) throw new RuntimeException(\"L\");\n BigDecimal r = parseProd(s, p);\n l = c == '+' ? l.add(r, MathContext.DECIMAL128) : l.subtract(r, MathContext.DECIMAL128);\n chk(l);\n }\n return l;\n }\n\n static BigDecimal parseProd(String s, int[] p) {\n BigDecimal l = parseUnary(s, p);\n while (true) {\n skip(s, p);\n if (p[0] >= s.length()) break;\n char c = s.charAt(p[0]);\n if (c != '*' && c != '/') break;\n p[0]++; if (++ops > 64) throw new RuntimeException(\"L\");\n BigDecimal r = parseUnary(s, p);\n if (c == '*') { l = l.multiply(r, MathContext.DECIMAL128); chk(l); }\n else { if (r.signum() == 0) throw new RuntimeException(\"D\"); l = l.divide(r, MathContext.DECIMAL128); chk(l); }\n }\n return l;\n }\n\n static BigDecimal parseUnary(String s, int[] p) {\n skip(s, p); if (p[0] >= s.length()) throw new RuntimeException(\"X\");\n char c = s.charAt(p[0]);\n if (c == '+' || c == '-') {\n p[0]++; if (++ops > 64) throw new RuntimeException(\"L\");\n BigDecimal v = parseUnary(s, p);\n return c == '-' ? v.negate(MathContext.DECIMAL128) : v;\n }\n return parseAtom(s, p);\n }\n\n static BigDecimal parseAtom(String s, int[] p) {\n skip(s, p); if (p[0] >= s.length()) throw new RuntimeException(\"X\");\n if (s.charAt(p[0]) == '(') {\n p[0]++; if (++depth > 16) throw new RuntimeException(\"L\");\n BigDecimal v = parseSum(s, p);\n skip(s, p); if (p[0] >= s.length() || s.charAt(p[0]) != ')') throw new RuntimeException(\"X\");\n p[0]++; depth--; return v;\n }\n return parseNum(s, p);\n }\n\n static BigDecimal parseNum(String s, int[] p) {\n skip(s, p); int st = p[0], dots = 0, digits = 0;\n if (p[0] >= s.length()) throw new RuntimeException(\"X\");\n char first = s.charAt(p[0]);\n if (first == '.') {\n dots++; p[0]++;\n if (p[0] >= s.length() || s.charAt(p[0]) < '0' || s.charAt(p[0]) > '9') throw new RuntimeException(\"X\");\n while (p[0] < s.length() && s.charAt(p[0]) >= '0' && s.charAt(p[0]) <= '9') { digits++; p[0]++; }\n } else if (first >= '0' && first <= '9') {\n while (p[0] < s.length() && s.charAt(p[0]) >= '0' && s.charAt(p[0]) <= '9') { digits++; p[0]++; }\n if (p[0] < s.length() && s.charAt(p[0]) == '.') {\n dots++; p[0]++;\n if (p[0] >= s.length() || s.charAt(p[0]) < '0' || s.charAt(p[0]) > '9') throw new RuntimeException(\"X\");\n while (p[0] < s.length() && s.charAt(p[0]) >= '0' && s.charAt(p[0]) <= '9') { digits++; p[0]++; }\n }\n } else { throw new RuntimeException(\"X\"); }\n if (digits > 24) throw new RuntimeException(\"L\");\n String ns = s.substring(st, p[0]);\n BigDecimal v = new BigDecimal(ns); chk(v); return v;\n }\n\n static void chk(BigDecimal v) { if (v.abs().compareTo(LIM) > 0) throw new RuntimeException(\"L\"); }\n static String jesc(String s) { return s.replace(\"\\\\\",\"\\\\\\\\\").replace(\"\\\"\",\"\\\\\\\"\"); }\n static void send(HttpExchange x, int c, String b) throws IOException {\n byte[] d = b.getBytes(StandardCharsets.UTF_8);\n x.getResponseHeaders().set(\"Content-Type\",\"application/json;charset=utf-8\");\n x.sendResponseHeaders(c, d.length);\n x.getResponseBody().write(d);\n }\n}"
291
+ },
292
+ "source_digest": "e1c26eeccec092a09b3481bc6f601f6f02b043b0e0e41219ff67a2e295b6a798"
293
+ },
294
+ "status": "verified_pending_user_acceptance",
295
+ "test": {
296
+ "cases": 39,
297
+ "classes_digest": "31888e310a086e6807cc096b7bdb06164ae9a556c8f582228d9e9d7b43b0b6cf",
298
+ "config_digest": "af40be185fe8b9dd8ecdd495a0785520aaebb54ebbabe97f18813d611f001e9f",
299
+ "container": "zk-run-4e2329b555864957bc5b477ae1432717",
300
+ "execution_mode": "qemu",
301
+ "image": "zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
302
+ "isolation": {
303
+ "disposable": true,
304
+ "host_mounts": [],
305
+ "memory_mb": 1024,
306
+ "network": "none",
307
+ "vcpu": 1
308
+ },
309
+ "passed": true,
310
+ "passed_cases": 39,
311
+ "preview_scope": "disposable-vm-loopback-http",
312
+ "receipt_digest": "4dd3a2513810493814d30734778f363391f33f14915fc48ee7b5e694be63ef2d",
313
+ "receipt_ref": "run-4e2329b555864957bc5b477ae1432717-1026975a6b7245aeb6e369a5fc51c7a7",
314
+ "source_digest": "e1c26eeccec092a09b3481bc6f601f6f02b043b0e0e41219ff67a2e295b6a798",
315
+ "stage": "test",
316
+ "suite_digest": "05e353f239f8919946d419e91e63fedccbf62b02386fa12f39ad8795b6a4de4d",
317
+ "tool_receipt": {
318
+ "input_digest": "9095d3cf2d02a31d5379192aec8c3b3fce2d66a9998f864076c84b5097d63b9b",
319
+ "operation": "AO09",
320
+ "result_digest": "df2dd27fa2866791431bf5710d250ef934be1726082e2402b0090bc001fd6f6a",
321
+ "run_id": "run-4e2329b555864957bc5b477ae1432717"
322
+ }
323
+ }
324
+ }
325
+ },
326
+ "local_replay": {
327
+ "generation_run": "run-4e2329b555864957bc5b477ae1432717",
328
+ "source_digest": "e1c26eeccec092a09b3481bc6f601f6f02b043b0e0e41219ff67a2e295b6a798",
329
+ "lease": "22cb0f942ecf446c833abff754e1a6cf",
330
+ "receipt": {
331
+ "source_digest": "e1c26eeccec092a09b3481bc6f601f6f02b043b0e0e41219ff67a2e295b6a798",
332
+ "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
333
+ "config_digest": "ec1c941302d1f0bf34512b9b524f7c8dc5bfd523f22fe50093f8cd757cdfc848",
334
+ "classes_digest": "31888e310a086e6807cc096b7bdb06164ae9a556c8f582228d9e9d7b43b0b6cf",
335
+ "tests": 39,
336
+ "network": "none",
337
+ "host_mounts": []
338
+ }
339
+ },
340
+ "human_acceptance": false
341
+ }
examples/hf-generated/erp/design.md ADDED
@@ -0,0 +1 @@
 
 
1
+ Java17 HttpServer on 8080. GET /health returns {"status":"ok"}. GET /api/purchase/quote validates query params (quantity, unitPrice, department) strictly: no duplicates/extras, format checks (int 1-10000, decimal >0 <=1e6 with max 2 decimals, dept regex), returning 400 INVALID_INPUT on failure. Rejects non-GET with 405. Requires 'Authorization: Bearer demo-sales' header; missing/invalid gives 401 UNAUTHORIZED. If authenticated as sales but department param is not 'sales', returns 403 FORBIDDEN. Computes total using BigDecimal, sets scale to 2 HALF_UP. Approval level based on total: <10k SELF, >=10k & <100k MANAGER, >=100k DIRECTOR. Returns JSON {total, approval, department}. Unknown paths return 404 NOT_FOUND. No external deps.
examples/hf-generated/erp/requirement.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DEMO-BIZ-01:采购报价与审批工作台
2
+
3
+ ## 背景与用户
4
+ 某制造企业采购员需要在提交采购申请前核算采购金额,确定审批级别。财务要求金额精确到分;不同部门不能越权计算其他部门业务。当前交付为本地演示网站,演示用户对应sales部门,数据不接客户生产系统。
5
+
6
+ ## 用户流程和界面
7
+ 页面标题“采购报价与审批”,桌面使用左侧输入、右侧结果布局,窄屏改为上下排列。顶部只显示应用名称和可使用状态;说明当前账号所属部门及审批金额区间。
8
+ 输入区含采购数量、含税单价、部门(默认sales)及“计算报价”“恢复示例”按钮,默认数量3、单价125.50。显示金额单位和数量范围。提交时禁用按钮并显示简短处理状态,返回后恢复。支持Enter提交;错误在字段附近或结果区清晰展示,不用弹窗代替结果。
9
+ 结果区显示金额两位小数、部门和审批级别中文;修改输入后清除旧结果,失败时不把旧结果当新成功。应用不显示原始接口JSON、源码摘要、沙箱/测试步骤或制品下载;代码、差异与运行证据在工作台查看。点击预览由平台内部准备,独立端口展示完成应用。样式应简洁、键盘可访问,无横向溢出。
10
+
11
+ ## 编程需求与验收
12
+ - BIZ-01:Java17标准库HttpServer,8080端口,GET /health返回status=ok。前端HTML/CSS/JS使用交付的受控页面,调用同一个沙箱Java服务,不在浏览器重复实现金额业务逻辑。
13
+ - BIZ-02:GET /api/purchase/quote只接受quantity、unitPrice、department,禁止重复或未知参数。quantity为1–10000整数;unitPrice为大于0且不超过1000000、最多两位小数的十进制数字;department符合固定标识格式。错误统一400 INVALID_INPUT。
14
+ - BIZ-03:使用BigDecimal,输出两位小数字符串。3×0.10必须为0.30,3×125.50为376.50。禁止浮点金额计算。
15
+ - BIZ-04:总额<10000为SELF;10000至小于100000为MANAGER;≥100000为DIRECTOR。测试9999.99、10000、99999.99、100000及最大合法输入。
16
+ - BIZ-05:公开演示凭据demo-sales只映射sales。无效身份401;合法请求试图访问finance返回403。不能信任查询参数宣称的身份。已知路径非GET先返回405;未知路径404。
17
+ - BIZ-06:系统测试覆盖上述正常/边界/越权/重复参数,网页测试验证默认376.50、审批阈值、错误输入、键盘提交和窄屏布局。
18
+
19
+ ## 交付与完成条件
20
+ 输出src/main/java/demo/App.java,必要说明放docs;不新增框架或依赖,不修改保护测试。交付包含需求原文、技术设计、源码差异、HTML/CSS/JS网站文件、需求到系统测试对应表、实际编译/测试报告、制品清单与摘要。测试失败时使用真实诊断修复并重新执行;技术通过后给可点击的本地网页,人工验收保持待确认。
21
+
22
+
23
+ HF验收批次 20261024T043443Z erp。完整实现上述需求;模型、框架和权限仍由服务端冻结契约决定。
examples/hf-generated/erp/src/main/java/demo/App.java ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package demo;
2
+
3
+ import com.sun.net.httpserver.HttpServer;
4
+ import com.sun.net.httpserver.HttpExchange;
5
+ import java.io.IOException;
6
+ import java.io.OutputStream;
7
+ import java.math.BigDecimal;
8
+ import java.math.RoundingMode;
9
+ import java.net.InetSocketAddress;
10
+ import java.net.URI;
11
+ import java.nio.charset.StandardCharsets;
12
+ import java.util.LinkedHashMap;
13
+ import java.util.Map;
14
+ import java.util.regex.Pattern;
15
+
16
+ public class App {
17
+ private static final Pattern DEPT_PATTERN = Pattern.compile("[A-Za-z][A-Za-z0-9_-]{0,31}");
18
+ private static final Pattern QTY_PATTERN = Pattern.compile("[0-9]+");
19
+ private static final Pattern PRICE_PATTERN = Pattern.compile("[0-9]+(\\.[0-9]{1,2})?");
20
+
21
+ public static void main(String[] args) throws IOException {
22
+ HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
23
+ server.createContext("/health", App::handleHealth);
24
+ server.createContext("/api/purchase/quote", App::handleQuote);
25
+ server.createContext("/", App::handleNotFound);
26
+ server.setExecutor(null);
27
+ server.start();
28
+ }
29
+
30
+ private static void handleNotFound(HttpExchange exchange) throws IOException {
31
+ sendJson(exchange, 404, "{\"error\":\"NOT_FOUND\"}");
32
+ }
33
+
34
+ private static void handleHealth(HttpExchange exchange) throws IOException {
35
+ if (!"GET".equals(exchange.getRequestMethod())) {
36
+ sendJson(exchange, 405, "{\"error\":\"METHOD_NOT_ALLOWED\"}");
37
+ return;
38
+ }
39
+ sendJson(exchange, 200, "{\"status\":\"ok\"}");
40
+ }
41
+
42
+ private static void handleQuote(HttpExchange exchange) throws IOException {
43
+ if (!"GET".equals(exchange.getRequestMethod())) {
44
+ sendJson(exchange, 405, "{\"error\":\"METHOD_NOT_ALLOWED\"}");
45
+ return;
46
+ }
47
+ String auth = exchange.getRequestHeaders().getFirst("Authorization");
48
+ if (!"Bearer demo-sales".equals(auth)) {
49
+ sendJson(exchange, 401, "{\"error\":\"UNAUTHORIZED\"}");
50
+ return;
51
+ }
52
+ URI uri = exchange.getRequestURI();
53
+ String query = uri.getRawQuery();
54
+ Map<String, String> params = new LinkedHashMap<>();
55
+ if (query != null && !query.isEmpty()) {
56
+ String[] pairs = query.split("&");
57
+ for (String pair : pairs) {
58
+ int eq = pair.indexOf('=');
59
+ String key = eq >= 0 ? pair.substring(0, eq) : pair;
60
+ String val = eq >= 0 ? pair.substring(eq + 1) : "";
61
+ if (params.containsKey(key)) {
62
+ sendJson(exchange, 400, "{\"error\":\"INVALID_INPUT\"}");
63
+ return;
64
+ }
65
+ params.put(key, val);
66
+ }
67
+ }
68
+ if (params.size() != 3 || !params.containsKey("quantity") || !params.containsKey("unitPrice") || !params.containsKey("department")) {
69
+ sendJson(exchange, 400, "{\"error\":\"INVALID_INPUT\"}");
70
+ return;
71
+ }
72
+ String qtyStr = params.get("quantity");
73
+ String priceStr = params.get("unitPrice");
74
+ String deptStr = params.get("department");
75
+ if (!QTY_PATTERN.matcher(qtyStr).matches()) {
76
+ sendJson(exchange, 400, "{\"error\":\"INVALID_INPUT\"}");
77
+ return;
78
+ }
79
+ int quantity;
80
+ try {
81
+ quantity = Integer.parseInt(qtyStr);
82
+ } catch (NumberFormatException e) {
83
+ sendJson(exchange, 400, "{\"error\":\"INVALID_INPUT\"}");
84
+ return;
85
+ }
86
+ if (quantity < 1 || quantity > 10000) {
87
+ sendJson(exchange, 400, "{\"error\":\"INVALID_INPUT\"}");
88
+ return;
89
+ }
90
+ if (!PRICE_PATTERN.matcher(priceStr).matches()) {
91
+ sendJson(exchange, 400, "{\"error\":\"INVALID_INPUT\"}");
92
+ return;
93
+ }
94
+ BigDecimal unitPrice;
95
+ try {
96
+ unitPrice = new BigDecimal(priceStr);
97
+ } catch (NumberFormatException e) {
98
+ sendJson(exchange, 400, "{\"error\":\"INVALID_INPUT\"}");
99
+ return;
100
+ }
101
+ if (unitPrice.compareTo(BigDecimal.ZERO) <= 0 || unitPrice.compareTo(new BigDecimal("1000000")) > 0) {
102
+ sendJson(exchange, 400, "{\"error\":\"INVALID_INPUT\"}");
103
+ return;
104
+ }
105
+ if (!DEPT_PATTERN.matcher(deptStr).matches()) {
106
+ sendJson(exchange, 400, "{\"error\":\"INVALID_INPUT\"}");
107
+ return;
108
+ }
109
+ if (!"sales".equals(deptStr)) {
110
+ sendJson(exchange, 403, "{\"error\":\"FORBIDDEN\"}");
111
+ return;
112
+ }
113
+ BigDecimal total = unitPrice.multiply(new BigDecimal(quantity)).setScale(2, RoundingMode.HALF_UP);
114
+ String approval;
115
+ if (total.compareTo(new BigDecimal("10000")) < 0) {
116
+ approval = "SELF";
117
+ } else if (total.compareTo(new BigDecimal("100000")) < 0) {
118
+ approval = "MANAGER";
119
+ } else {
120
+ approval = "DIRECTOR";
121
+ }
122
+ String json = "{\"total\":\"" + total.toPlainString() + "\",\"approval\":\"" + approval + "\",\"department\":\"sales\"}";
123
+ sendJson(exchange, 200, json);
124
+ }
125
+
126
+ private static void sendJson(HttpExchange exchange, int code, String json) throws IOException {
127
+ byte[] bytes = json.getBytes(StandardCharsets.UTF_8);
128
+ exchange.getResponseHeaders().set("Content-Type", "application/json; charset=UTF-8");
129
+ exchange.sendResponseHeaders(code, bytes.length);
130
+ try (OutputStream os = exchange.getResponseBody()) {
131
+ os.write(bytes);
132
+ }
133
+ }
134
+ }
examples/hf-generated/erp/validation-evidence.json ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "generation": {
3
+ "digest": "b81c9fbcb209faa406c35c41a5ddd5bd6f3293c56a763be8ea74648e104bc18f",
4
+ "manifest": {
5
+ "approvals": [
6
+ {
7
+ "authorization_ref": "local-web-delegation-v1:user-c3adb31fc78c4d59970af883326ccff5",
8
+ "digest": "2baf0375ac3ec23a688c369099efa1daae564d987e188226d2f19b3e3814b678",
9
+ "increment": true,
10
+ "mechanism": "delegated_local_validation",
11
+ "node": "design_confirm",
12
+ "scope": "design",
13
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
14
+ },
15
+ {
16
+ "authorization_ref": "local-web-delegation-v1:user-c3adb31fc78c4d59970af883326ccff5",
17
+ "digest": "964ffd41aee3977258d296edc9d70f84ad8ab0ea8daa32a680a16ddd8c880132",
18
+ "increment": true,
19
+ "mechanism": "delegated_local_validation",
20
+ "node": "execution_confirm",
21
+ "scope": "execution",
22
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
23
+ },
24
+ {
25
+ "authorization_ref": "local-web-delegation-v1:user-c3adb31fc78c4d59970af883326ccff5",
26
+ "digest": "4a51c5cc046f2e3058e257667ad4d11dcabf72a98cfb942bb8f32c463f973daa",
27
+ "increment": false,
28
+ "mechanism": "delegated_local_validation",
29
+ "node": "repair-execution",
30
+ "scope": "execution",
31
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
32
+ }
33
+ ],
34
+ "candidate": {
35
+ "classes_digest": "ba589b760a2583fe523da87f68e84a69e3914972b2cb6417c9a44f768ba604a1",
36
+ "config_digest": "d223365fd05e5fe9d0e74ec5a440e3c878a1dbd0cb9726cf04be2d4575c7f603",
37
+ "container": "zk-run-8f523ff16b6b4c95832e46b4b6110a8d",
38
+ "execution_mode": "qemu",
39
+ "image": "zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
40
+ "isolation": {
41
+ "disposable": true,
42
+ "host_mounts": [],
43
+ "memory_mb": 1024,
44
+ "network": "none",
45
+ "vcpu": 1
46
+ },
47
+ "passed": true,
48
+ "receipt_digest": "a210412abeeba14e1ed2bf41626eb8b8aad3ed81083a18fac6e4ee45fbc8599c",
49
+ "receipt_ref": "run-8f523ff16b6b4c95832e46b4b6110a8d-3c06b2b5d67941f9ab16db94af4f52d4",
50
+ "source_digest": "86f2fd3b99c6f8b21ceb2595171ed841194fcc7c791b60ea1a8cf0d90d6ba1be",
51
+ "stage": "build",
52
+ "suite_digest": "9c6339659e17af7ff3da41e664c930429ee4595b97bc1cd9af26dbbe018131ce",
53
+ "tool_receipt": {
54
+ "input_digest": "76be5f23a16ce24a6dff0c8db7acc50d8d50c07fb72144df41dcecc5ac6c6e8e",
55
+ "operation": "AO08",
56
+ "result_digest": "9201318e0f5248cb55ca32c40149334434a3345477535a39b3dc9d6a697820f6",
57
+ "run_id": "run-8f523ff16b6b4c95832e46b4b6110a8d"
58
+ }
59
+ },
60
+ "deployment": "not_performed",
61
+ "development": {
62
+ "design": {
63
+ "summary": "Java17 HttpServer on 8080. GET /health returns {\"status\":\"ok\"}. GET /api/purchase/quote validates query params (quantity, unitPrice, department) strictly: no duplicates/extras, format checks (int 1-10000, decimal >0 <=1e6 with max 2 decimals, dept regex), returning 400 INVALID_INPUT on failure. Rejects non-GET with 405. Requires 'Authorization: Bearer demo-sales' header; missing/invalid gives 401 UNAUTHORIZED. If authenticated as sales but department param is not 'sales', returns 403 FORBIDDEN. Computes total using BigDecimal, sets scale to 2 HALF_UP. Approval level based on total: <10k SELF, >=10k & <100k MANAGER, >=100k DIRECTOR. Returns JSON {total, approval, department}. Unknown paths return 404 NOT_FOUND. No external deps."
64
+ },
65
+ "requirement": "# DEMO-BIZ-01:采购报价与审批工作台\n\n## 背景与用户\n某制造企业采购员需要在提交采购申请前核算采购金额,确定审批级别。财务要求金额精确到分;不同部门不能越权计算其他部门业务。当前交付为本地演示网站,演示用户对应sales部门,数据不接客户生产系统。\n\n## 用户流程和界面\n页面标题“采购报价与审批”,桌面使用左侧输入、右侧结果布局,窄屏改为上下排列。顶部只显示应用名称和可使用状态;说明当前账号所属部门及审批金额区间。\n输入区含采购数量、含税单价、部门(默认sales)及“计算报价”“恢复示例”按钮,默认数量3、单价125.50。显示金额单位和数量范围。提交时禁用按钮并显示简短处理状态,返回后恢复。支持Enter提交;错误在字段附近或结果区清晰展示,不用弹窗代替结果。\n结果区显示金额两位小数、部门和审批级别中文;修改输入后清除旧结果,失败时不把旧结果当新成功。应用不显示原始接口JSON、源码摘要、沙箱/测试步骤或制品下载;代码、差异与运行证据在工作台查看。点击预览由平台内部准备,独立端口展示完成应用。样式应简洁、键盘可访问,无横向溢出。\n\n## 编程��求与验收\n- BIZ-01:Java17标准库HttpServer,8080端口,GET /health返回status=ok。前端HTML/CSS/JS使用交付的受控页面,调用同一个沙箱Java服务,不在浏览器重复实现金额业务逻辑。\n- BIZ-02:GET /api/purchase/quote只接受quantity、unitPrice、department,禁止重复或未知参数。quantity为1–10000整数;unitPrice为大于0且不超过1000000、最多两位小数的十进制数字;department符合固定标识格式。错误统一400 INVALID_INPUT。\n- BIZ-03:使用BigDecimal,输出两位小数字符串。3×0.10必须为0.30,3×125.50为376.50。禁止浮点金额计算。\n- BIZ-04:总额<10000为SELF;10000至小于100000为MANAGER;≥100000为DIRECTOR。测试9999.99、10000、99999.99、100000及最大合法输入。\n- BIZ-05:公开演示凭据demo-sales只映射sales。无效身份401;合法请求试图访问finance返回403。不能信任查询参数宣称的身份。已知路径非GET先返回405;未知路径404。\n- BIZ-06:系统测试覆盖上述正常/边界/越权/重复参数,网页测试验证默认376.50、审批阈值、错误输入、键盘提交和窄屏布局。\n\n## 交付与完成条件\n输出src/main/java/demo/App.java,必要说明放docs;不新增框架或依赖,不修改保护测试。交付包含需求原文、技术设计、源码差异、HTML/CSS/JS网站文件、需求到系统测试对应表、实际编译/测试报告、制品清单与摘要。测试失败时使用真实诊断修复并重新执行;技术通过后给可点击的本地网页,人工验收保持待确认。\n\n\nHF验收批次 20261024T043443Z erp。完整实现上述需求;模型、框架和权限仍由服务端冻结契约决定。"
66
+ },
67
+ "human_acceptance": false,
68
+ "model_calls": [
69
+ {
70
+ "charged": 4086,
71
+ "id": 1,
72
+ "metadata": {
73
+ "finish_reason": "stop",
74
+ "model": "qwen3.8-flash",
75
+ "policy_version": "bailian-task-routing-v2",
76
+ "request_id": "chatcmpl-e0a927f6-ec19-9010-b52d-08edc4361673",
77
+ "requested_output_tokens": 2048,
78
+ "retry_of": null,
79
+ "route_reason": "technical-design",
80
+ "stage": "design"
81
+ },
82
+ "prompt_digest": "000db0eae0ba1c5ba2e3fe30a3effedc72b74910294bb3128b3a7bf3c208a2ec",
83
+ "provider": "bailian-qwen3.8-flash",
84
+ "reservation": 16087,
85
+ "run_id": "run-8f523ff16b6b4c95832e46b4b6110a8d",
86
+ "state": "settled"
87
+ },
88
+ {
89
+ "charged": 5533,
90
+ "id": 2,
91
+ "metadata": {
92
+ "finish_reason": "stop",
93
+ "model": "qwen3.8-max",
94
+ "policy_version": "bailian-task-routing-v2",
95
+ "request_id": "chatcmpl-5210c519-e295-932c-9baf-8d689177d3c3",
96
+ "requested_output_tokens": 8192,
97
+ "retry_of": null,
98
+ "route_reason": "business-code",
99
+ "stage": "code"
100
+ },
101
+ "prompt_digest": "4b488c9662257135d667d65af153280bb1837642bb0e9c9eb79ad2bd3541ab71",
102
+ "provider": "bailian-qwen3.8-max",
103
+ "reservation": 15627,
104
+ "run_id": "run-8f523ff16b6b4c95832e46b4b6110a8d",
105
+ "state": "settled"
106
+ },
107
+ {
108
+ "charged": 6526,
109
+ "id": 3,
110
+ "metadata": {
111
+ "finish_reason": "stop",
112
+ "model": "qwen3.8-max",
113
+ "policy_version": "bailian-task-routing-v2",
114
+ "request_id": "chatcmpl-4c5fac7c-eced-9232-8974-4ae54865a978",
115
+ "requested_output_tokens": 12288,
116
+ "retry_of": null,
117
+ "route_reason": "diagnostic-repair",
118
+ "stage": "repair"
119
+ },
120
+ "prompt_digest": "93f9190dd32cf5bda3fa4debb71e644240a811e147e9480b9618426f37e9b4ac",
121
+ "provider": "bailian-qwen3.8-max",
122
+ "reservation": 28818,
123
+ "run_id": "run-8f523ff16b6b4c95832e46b4b6110a8d",
124
+ "state": "settled"
125
+ }
126
+ ],
127
+ "preview": {
128
+ "cases": 1,
129
+ "classes_digest": "ba589b760a2583fe523da87f68e84a69e3914972b2cb6417c9a44f768ba604a1",
130
+ "config_digest": "d223365fd05e5fe9d0e74ec5a440e3c878a1dbd0cb9726cf04be2d4575c7f603",
131
+ "container": "zk-run-8f523ff16b6b4c95832e46b4b6110a8d",
132
+ "execution_mode": "qemu",
133
+ "image": "zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
134
+ "isolation": {
135
+ "disposable": true,
136
+ "host_mounts": [],
137
+ "memory_mb": 1024,
138
+ "network": "none",
139
+ "vcpu": 1
140
+ },
141
+ "passed": true,
142
+ "passed_cases": 1,
143
+ "preview_scope": "disposable-vm-loopback-http",
144
+ "receipt_digest": "a210412abeeba14e1ed2bf41626eb8b8aad3ed81083a18fac6e4ee45fbc8599c",
145
+ "receipt_ref": "run-8f523ff16b6b4c95832e46b4b6110a8d-3c06b2b5d67941f9ab16db94af4f52d4",
146
+ "source_digest": "86f2fd3b99c6f8b21ceb2595171ed841194fcc7c791b60ea1a8cf0d90d6ba1be",
147
+ "stage": "preview",
148
+ "suite_digest": "9c6339659e17af7ff3da41e664c930429ee4595b97bc1cd9af26dbbe018131ce",
149
+ "tool_receipt": {
150
+ "input_digest": "ee16016099b35922c870fdc1601d65e5fc0b144f3c28490b7066f918f1735ef2",
151
+ "operation": "AO10",
152
+ "result_digest": "296be25de7a105f0124ec41d761ebe1db2afdbf007d0f4730507f8478f093bf1",
153
+ "run_id": "run-8f523ff16b6b4c95832e46b4b6110a8d"
154
+ }
155
+ },
156
+ "repairs": 1,
157
+ "run_id": "run-8f523ff16b6b4c95832e46b4b6110a8d",
158
+ "sandbox_cleaned": true,
159
+ "snapshot": {
160
+ "budget": {
161
+ "max_model_calls": 6,
162
+ "max_repairs": 2,
163
+ "max_seconds": 1800,
164
+ "max_tokens": 120000
165
+ },
166
+ "execution_order": [
167
+ "start",
168
+ "requirements",
169
+ "knowledge",
170
+ "context",
171
+ "design",
172
+ "design_confirm",
173
+ "execution_confirm",
174
+ "code",
175
+ "patch",
176
+ "policy",
177
+ "build",
178
+ "test",
179
+ "preview",
180
+ "acceptance",
181
+ "evidence",
182
+ "end"
183
+ ],
184
+ "execution_status": "not_started",
185
+ "framework": {
186
+ "allowed_paths": [
187
+ "src/main/",
188
+ "src/test/",
189
+ "docs/"
190
+ ],
191
+ "build_tool": "jdk",
192
+ "dependencies": {},
193
+ "evidence_refs": [
194
+ "local-toolchain:zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
195
+ "user-authorized-local-validation"
196
+ ],
197
+ "frontend": [
198
+ "html",
199
+ "javascript",
200
+ "css"
201
+ ],
202
+ "java_release": 17,
203
+ "language": "java",
204
+ "profile_id": "java17-standard-web",
205
+ "state": "approved",
206
+ "version": "0.1.0"
207
+ },
208
+ "knowledge": [
209
+ {
210
+ "collection_id": "java-basics",
211
+ "digest": "6de6f354ff0e845da78ad210164775f51d9a4c5f01a1e5e355911423bd6a5b5c",
212
+ "enterprise_approved": false,
213
+ "quality_status": "imported_unreviewed",
214
+ "revision": "corpus-6de6f354ff0e845da78ad210",
215
+ "scope": "reference"
216
+ },
217
+ {
218
+ "collection_id": "java-patterns",
219
+ "digest": "803bd1aef5f0764242a56a8c85a3eca81b26cebbe4ec3e6b53d3c4da8864aa2d",
220
+ "enterprise_approved": false,
221
+ "quality_status": "imported_unreviewed",
222
+ "revision": "corpus-803bd1aef5f0764242a56a8c",
223
+ "scope": "reference"
224
+ },
225
+ {
226
+ "collection_id": "erp",
227
+ "digest": "12726dd26fa3208098be6048f2f1d7bea99a9a6954b825d93672daef85bcbafc",
228
+ "enterprise_approved": false,
229
+ "quality_status": "imported_unreviewed",
230
+ "revision": "corpus-12726dd26fa3208098be6048",
231
+ "scope": "reference"
232
+ },
233
+ {
234
+ "collection_id": "java-frameworks",
235
+ "digest": "28b65fe6ced6682555c8b32b676faf14020011ea525eeee57f17562acd17da4c",
236
+ "enterprise_approved": false,
237
+ "quality_status": "imported_unreviewed",
238
+ "revision": "corpus-28b65fe6ced6682555c8b32b",
239
+ "scope": "reference"
240
+ },
241
+ {
242
+ "collection_id": "web-development",
243
+ "digest": "84c82986259278c89a30d2660f66454f0a5bcb10f871c96c7ec4ea9ebb47e02a",
244
+ "enterprise_approved": false,
245
+ "quality_status": "imported_unreviewed",
246
+ "revision": "corpus-84c82986259278c89a30d266",
247
+ "scope": "reference"
248
+ },
249
+ {
250
+ "collection_id": "java-persistence",
251
+ "digest": "972ee7e1f0072e413bec262b67b8af46364ff8aac445a9faeeeb8c041eb07f92",
252
+ "enterprise_approved": false,
253
+ "quality_status": "imported_unreviewed",
254
+ "revision": "corpus-972ee7e1f0072e413bec262b",
255
+ "scope": "reference"
256
+ },
257
+ {
258
+ "collection_id": "java-testing",
259
+ "digest": "8af9017057c130eef9f9a1617a2654859ba80ed4f108b28054aecf14a3d39c45",
260
+ "enterprise_approved": false,
261
+ "quality_status": "imported_unreviewed",
262
+ "revision": "corpus-8af9017057c130eef9f9a161",
263
+ "scope": "reference"
264
+ },
265
+ {
266
+ "collection_id": "java-integration",
267
+ "digest": "befde1177fa13476703d89a8df3902d90ad01cb7d497d0583cfe15620348c7b1",
268
+ "enterprise_approved": false,
269
+ "quality_status": "imported_unreviewed",
270
+ "revision": "corpus-befde1177fa13476703d89a8",
271
+ "scope": "reference"
272
+ }
273
+ ],
274
+ "operations_lock": {
275
+ "AO01@0.1.0": "6f2a89d1624450c6e4afd8f776f23c7df4bf402976a82d0992dfd6cfdc643bf2",
276
+ "AO02@0.1.0": "6a4491053f9a3f55d900f3f907f81a0cfc44f09a1e2f1e770248287bc0b8d7f6",
277
+ "AO03@0.1.0": "8a1387e065674c2987930ad865a2bdb4ab7346cb589505c350c6bb1907a7eb6d",
278
+ "AO04@0.1.0": "3ef3f1be1b0f9240f066fa6d0b3b1430026d55763d15b5fc584a801c64be688b",
279
+ "AO05@0.2.0": "eeac70849a9d8bebd00b1d2111545f9376cc6901f6aa611412b1cb73238e47a7",
280
+ "AO06@0.1.0": "2b369879ba0cd2847c173cfb7cb583c1dc051553d3d3ea80f954c81c21f1f233",
281
+ "AO07@0.1.0": "69e1e824b4c5129f62595ac3df578eec7b083411cd391a72d47303eec3843baa",
282
+ "AO08@0.1.0": "1d75566610ac000990fd15b9fd18a6518de8af12a329b3c56d51ff29c0c30623",
283
+ "AO09@0.1.0": "2e4bf4b3fcdfce184b8dea9ffebd18ffe91af7320b0ef3ce430edb3b5cc15c52",
284
+ "AO10@0.1.0": "d05863bea57e94ad860696bd6ac85e072034f89f6f038f132c65b854dd366e9f",
285
+ "AO11@0.1.0": "43b910a51da7a58810d3890eb2305d80663db6a1c187b51466f8e396a94956f0"
286
+ },
287
+ "project_id": "erp-demo",
288
+ "release_digest": "15ad0cfd9f30d9056932653f24bfc7d6d804c1ff586472c301be15f8bf589228",
289
+ "release_ref": "erp-java-development@local-15ad0cfd9f30d905",
290
+ "snapshot_digest": "eca22fd121931a44491cee768c9f2fa37a2a04f0b645ea0a0c52bbdf7d3a9265",
291
+ "snapshot_id": "snapshot-fb1c13de6e4f43dfaef0f58b7db7b035",
292
+ "source_digest": "44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
293
+ "tenant_id": "demo-tenant",
294
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
295
+ },
296
+ "source": {
297
+ "files": {
298
+ "src/main/java/demo/App.java": "package demo;\n\nimport com.sun.net.httpserver.HttpServer;\nimport com.sun.net.httpserver.HttpExchange;\nimport java.io.IOException;\nimport java.io.OutputStream;\nimport java.math.BigDecimal;\nimport java.math.RoundingMode;\nimport java.net.InetSocketAddress;\nimport java.net.URI;\nimport java.nio.charset.StandardCharsets;\nimport java.util.LinkedHashMap;\nimport java.util.Map;\nimport java.util.regex.Pattern;\n\npublic class App {\n private static final Pattern DEPT_PATTERN = Pattern.compile(\"[A-Za-z][A-Za-z0-9_-]{0,31}\");\n private static final Pattern QTY_PATTERN = Pattern.compile(\"[0-9]+\");\n private static final Pattern PRICE_PATTERN = Pattern.compile(\"[0-9]+(\\\\.[0-9]{1,2})?\");\n\n public static void main(String[] args) throws IOException {\n HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);\n server.createContext(\"/health\", App::handleHealth);\n server.createContext(\"/api/purchase/quote\", App::handleQuote);\n server.createContext(\"/\", App::handleNotFound);\n server.setExecutor(null);\n server.start();\n }\n\n private static void handleNotFound(HttpExchange exchange) throws IOException {\n sendJson(exchange, 404, \"{\\\"error\\\":\\\"NOT_FOUND\\\"}\");\n }\n\n private static void handleHealth(HttpExchange exchange) throws IOException {\n if (!\"GET\".equals(exchange.getRequestMethod())) {\n sendJson(exchange, 405, \"{\\\"error\\\":\\\"METHOD_NOT_ALLOWED\\\"}\");\n return;\n }\n sendJson(exchange, 200, \"{\\\"status\\\":\\\"ok\\\"}\");\n }\n\n private static void handleQuote(HttpExchange exchange) throws IOException {\n if (!\"GET\".equals(exchange.getRequestMethod())) {\n sendJson(exchange, 405, \"{\\\"error\\\":\\\"METHOD_NOT_ALLOWED\\\"}\");\n return;\n }\n String auth = exchange.getRequestHeaders().getFirst(\"Authorization\");\n if (!\"Bearer demo-sales\".equals(auth)) {\n sendJson(exchange, 401, \"{\\\"error\\\":\\\"UNAUTHORIZED\\\"}\");\n return;\n }\n URI uri = exchange.getRequestURI();\n String query = uri.getRawQuery();\n Map<String, String> params = new LinkedHashMap<>();\n if (query != null && !query.isEmpty()) {\n String[] pairs = query.split(\"&\");\n for (String pair : pairs) {\n int eq = pair.indexOf('=');\n String key = eq >= 0 ? pair.substring(0, eq) : pair;\n String val = eq >= 0 ? pair.substring(eq + 1) : \"\";\n if (params.containsKey(key)) {\n sendJson(exchange, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\");\n return;\n }\n params.put(key, val);\n }\n }\n if (params.size() != 3 || !params.containsKey(\"quantity\") || !params.containsKey(\"unitPrice\") || !params.containsKey(\"department\")) {\n sendJson(exchange, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\");\n return;\n }\n String qtyStr = params.get(\"quantity\");\n String priceStr = params.get(\"unitPrice\");\n String deptStr = params.get(\"department\");\n if (!QTY_PATTERN.matcher(qtyStr).matches()) {\n sendJson(exchange, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\");\n return;\n }\n int quantity;\n try {\n quantity = Integer.parseInt(qtyStr);\n } catch (NumberFormatException e) {\n sendJson(exchange, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\");\n return;\n }\n if (quantity < 1 || quantity > 10000) {\n sendJson(exchange, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\");\n return;\n }\n if (!PRICE_PATTERN.matcher(priceStr).matches()) {\n sendJson(exchange, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\");\n return;\n }\n BigDecimal unitPrice;\n try {\n unitPrice = new BigDecimal(priceStr);\n } catch (NumberFormatException e) {\n sendJson(exchange, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\");\n return;\n }\n if (unitPrice.compareTo(BigDecimal.ZERO) <= 0 || unitPrice.compareTo(new BigDecimal(\"1000000\")) > 0) {\n sendJson(exchange, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\");\n return;\n }\n if (!DEPT_PATTERN.matcher(deptStr).matches()) {\n sendJson(exchange, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\");\n return;\n }\n if (!\"sales\".equals(deptStr)) {\n sendJson(exchange, 403, \"{\\\"error\\\":\\\"FORBIDDEN\\\"}\");\n return;\n }\n BigDecimal total = unitPrice.multiply(new BigDecimal(quantity)).setScale(2, RoundingMode.HALF_UP);\n String approval;\n if (total.compareTo(new BigDecimal(\"10000\")) < 0) {\n approval = \"SELF\";\n } else if (total.compareTo(new BigDecimal(\"100000\")) < 0) {\n approval = \"MANAGER\";\n } else {\n approval = \"DIRECTOR\";\n }\n String json = \"{\\\"total\\\":\\\"\" + total.toPlainString() + \"\\\",\\\"approval\\\":\\\"\" + approval + \"\\\",\\\"department\\\":\\\"sales\\\"}\";\n sendJson(exchange, 200, json);\n }\n\n private static void sendJson(HttpExchange exchange, int code, String json) throws IOException {\n byte[] bytes = json.getBytes(StandardCharsets.UTF_8);\n exchange.getResponseHeaders().set(\"Content-Type\", \"application/json; charset=UTF-8\");\n exchange.sendResponseHeaders(code, bytes.length);\n try (OutputStream os = exchange.getResponseBody()) {\n os.write(bytes);\n }\n }\n}"
299
+ },
300
+ "source_digest": "86f2fd3b99c6f8b21ceb2595171ed841194fcc7c791b60ea1a8cf0d90d6ba1be"
301
+ },
302
+ "status": "verified_pending_user_acceptance",
303
+ "test": {
304
+ "cases": 25,
305
+ "classes_digest": "ba589b760a2583fe523da87f68e84a69e3914972b2cb6417c9a44f768ba604a1",
306
+ "config_digest": "d223365fd05e5fe9d0e74ec5a440e3c878a1dbd0cb9726cf04be2d4575c7f603",
307
+ "container": "zk-run-8f523ff16b6b4c95832e46b4b6110a8d",
308
+ "execution_mode": "qemu",
309
+ "image": "zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
310
+ "isolation": {
311
+ "disposable": true,
312
+ "host_mounts": [],
313
+ "memory_mb": 1024,
314
+ "network": "none",
315
+ "vcpu": 1
316
+ },
317
+ "passed": true,
318
+ "passed_cases": 25,
319
+ "preview_scope": "disposable-vm-loopback-http",
320
+ "receipt_digest": "a210412abeeba14e1ed2bf41626eb8b8aad3ed81083a18fac6e4ee45fbc8599c",
321
+ "receipt_ref": "run-8f523ff16b6b4c95832e46b4b6110a8d-3c06b2b5d67941f9ab16db94af4f52d4",
322
+ "source_digest": "86f2fd3b99c6f8b21ceb2595171ed841194fcc7c791b60ea1a8cf0d90d6ba1be",
323
+ "stage": "test",
324
+ "suite_digest": "9c6339659e17af7ff3da41e664c930429ee4595b97bc1cd9af26dbbe018131ce",
325
+ "tool_receipt": {
326
+ "input_digest": "ee16016099b35922c870fdc1601d65e5fc0b144f3c28490b7066f918f1735ef2",
327
+ "operation": "AO09",
328
+ "result_digest": "57378dae1f0db78d0c0b53b47f8ea322951000c6d8aa1db2213fedb79c635405",
329
+ "run_id": "run-8f523ff16b6b4c95832e46b4b6110a8d"
330
+ }
331
+ }
332
+ }
333
+ },
334
+ "local_replay": {
335
+ "generation_run": "run-8f523ff16b6b4c95832e46b4b6110a8d",
336
+ "source_digest": "86f2fd3b99c6f8b21ceb2595171ed841194fcc7c791b60ea1a8cf0d90d6ba1be",
337
+ "lease": "a36fe1894b964ecc9b5dd9be6900eda7",
338
+ "receipt": {
339
+ "source_digest": "86f2fd3b99c6f8b21ceb2595171ed841194fcc7c791b60ea1a8cf0d90d6ba1be",
340
+ "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
341
+ "config_digest": "841129aac9dd785fe877d72002533547377a93994d0afb830dadb1273b51389a",
342
+ "classes_digest": "ba589b760a2583fe523da87f68e84a69e3914972b2cb6417c9a44f768ba604a1",
343
+ "tests": 25,
344
+ "network": "none",
345
+ "host_mounts": []
346
+ }
347
+ },
348
+ "human_acceptance": false
349
+ }
examples/hf-generated/pdf/design.md ADDED
@@ -0,0 +1 @@
 
 
1
+ Implement demo.App as a Java17 HttpServer on port 8080. Define endpoints: GET /health returns {"status":"ok"}; POST /api/pdf/analyze requires Authorization header 'Bearer demo-pdf'. Enforce method/path checks before auth to return 405/404 appropriately. Parse JSON body strictly for single 'base64' field; reject extra fields or non-canonical Base64 with 400 INVALID_INPUT. Limit request size to 180001 bytes and decoded PDF to 131072 bytes (413 PDF_TOO_LARGE). Validate Content-Type starts with application/json. Use PDFBox 3.0.8 Loader.loadPDF(byte[]) in try-with-resources. Check document.isEncrypted() -> 422 ENCRYPTED_PDF. Verify page count: 0 pages -> 400 INVALID_PDF, >20 pages -> 422 PAGE_LIMIT. Extract text per page using PDFTextStripper (sortByPosition=true), normalize CRLF/CR to LF, strip surrounding whitespace. Count Unicode code points. If all pages empty -> status NO_TEXT, else TEXT_EXTRACTED. Check total UTF-8 text length <= 24000 and serialized response <= 60000 bytes; otherwise 413 TEXT_LIMIT. Return JSON with pageCount, pages array, totalCharacters, and status. Ensure no external dependencies beyond pinned PDFBox jar.
examples/hf-generated/pdf/requirement.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DEMO-PDF-01:PDF文件读取与逐页文本解析
2
+
3
+ ## 背景与用户
4
+ 文档管理员需要确认PDF页数,逐页提取可复制的文本并导出,便于资料核对和后续索引。本地演示支持小型文字PDF;扫描件要明确说明没有可提取文字,不能冒充完成OCR。
5
+
6
+ ## 页面与交互
7
+ 标题“PDF文档解析”,左侧为上传区(选择PDF按钮、文件名/大小、128KiB上限、载入示例、开始解析),右侧为页数/文字数摘要和逐页结果。页签或上一页/下一页控件可切换,显示“第n页/共m页”。文本保留换行并可复制;提供TXT和JSON下载,文件名清晰。
8
+ 支持拖入一个文件与移除当前文件;换文件或移除时立即清空旧页和旧导出状态。应用不显示原始接口返回、源码/测试摘要、沙箱启动步骤或代码下载。TXT/JSON导出仅包含用户解析的业务文本;代码、差异和运行证据在工作台查看,预览准备在平台内部完成。
9
+ 选中文件后只显示元信息,点击开始解析才发送。解析时禁用重复提交,真实服务返回后展示结果。重新选文件清空旧成功状态,旧内容不得冒充新文件结果。文件缺失、非PDF、超限、加密、损坏及无文本分别显示可理解说明。示例按钮载入随制品交付的合法两页PDF,用户无自备文件也能完整运行。键盘可操作,窄屏上下排列。
10
+
11
+ ## 编程需求与验收
12
+ - PDF-01:Java17 HttpServer;使用固定Apache PDFBox 3.0.8单一依赖,版本、来源、许可证、SHA256随制品记录。依赖提前校验进入无网沙箱,运行时不下载,不读取宿主文件。
13
+ - PDF-02:POST /api/pdf/analyze,JSON仅base64字符串,公开演示凭据demo-pdf。原始PDF最大131072字节,最多20页,提取文本UTF-8最大24000字节;JSON边界180000字节。只接受真实文件内容,不接受服务端路径或URL。
14
+ - PDF-03:200返回pageCount、pages[{page,text}]、totalCharacters、status。页号从1连续,按页读取文本,去除提取器末尾多余换行;成功文本状态TEXT_EXTRACTED,无文本为NO_TEXT。两页示例输出应与固定期望文本一致。
15
+ - PDF-04:非法JSON/base64为400 INVALID_INPUT;损坏或非PDF为400 INVALID_PDF;加密PDF为422 ENCRYPTED_PDF;超过20页为422 PAGE_LIMIT;文件或文本超限分别413 PDF_TOO_LARGE/TEXT_LIMIT。无身份401、错误method405、未知路径404。解析失败不保留上传文件。
16
+ - PDF-05:独立系统测试覆盖正常多页、无文本、错误内容、加密、页数及大小边界;浏览器测试覆盖选择示例→解析→切页→复制/下载、错误文件、重复点击和窄屏。
17
+
18
+ ## 交付与完成条件
19
+ 交付Java解析源码、HTML/CSS/JS网站、两页测试PDF、固定依赖清单、需求原文、设计、修改差异、逐条验收映射和真实编译/测试报告。生成源码只允许批准路径,不能修改独立测试。以模型或经记录的接管修复迭代到测试通过,给本地网站和源码制品下载;OCR、超限大型文档和生产部署不在本次验收范围。
20
+
21
+
22
+ HF验收批次 20261024T044442Z pdf。完整实现上述需求;模型、框架和权限仍由服务端冻结契约决定。
examples/hf-generated/pdf/src/main/java/demo/App.java ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package demo;
2
+
3
+ import com.sun.net.httpserver.HttpServer;
4
+ import com.sun.net.httpserver.HttpExchange;
5
+ import org.apache.pdfbox.Loader;
6
+ import org.apache.pdfbox.pdmodel.PDDocument;
7
+ import org.apache.pdfbox.text.PDFTextStripper;
8
+ import java.io.*;
9
+ import java.net.InetSocketAddress;
10
+ import java.nio.charset.CharsetDecoder;
11
+ import java.nio.charset.CodingErrorAction;
12
+ import java.nio.charset.StandardCharsets;
13
+ import java.util.Base64;
14
+
15
+ public class App {
16
+ public static void main(String[] args) throws Exception {
17
+ HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
18
+ server.createContext("/", App::handleRoot);
19
+ server.start();
20
+ }
21
+
22
+ private static void send(HttpExchange ex, int code, String json) throws IOException {
23
+ byte[] b = json.getBytes(StandardCharsets.UTF_8);
24
+ ex.getResponseHeaders().set("Content-Type", "application/json");
25
+ ex.sendResponseHeaders(code, b.length);
26
+ try (OutputStream os = ex.getResponseBody()) { os.write(b); }
27
+ ex.close();
28
+ }
29
+
30
+ private static void handleRoot(HttpExchange ex) throws IOException {
31
+ String path = ex.getRequestURI().getPath();
32
+ if ("/health".equals(path)) {
33
+ handleHealth(ex);
34
+ } else if ("/api/pdf/analyze".equals(path)) {
35
+ handleAnalyze(ex);
36
+ } else {
37
+ send(ex, 404, "{\"error\":\"NOT_FOUND\"}");
38
+ }
39
+ }
40
+
41
+ private static void handleHealth(HttpExchange ex) throws IOException {
42
+ if (!"GET".equalsIgnoreCase(ex.getRequestMethod())) {
43
+ send(ex, 405, "{\"error\":\"METHOD_NOT_ALLOWED\"}"); return;
44
+ }
45
+ send(ex, 200, "{\"status\":\"ok\"}");
46
+ }
47
+
48
+ private static void handleAnalyze(HttpExchange ex) throws IOException {
49
+ if (!"POST".equalsIgnoreCase(ex.getRequestMethod())) {
50
+ send(ex, 405, "{\"error\":\"METHOD_NOT_ALLOWED\"}"); return;
51
+ }
52
+ String auth = ex.getRequestHeaders().getFirst("Authorization");
53
+ if (!"Bearer demo-pdf".equals(auth)) {
54
+ send(ex, 401, "{\"error\":\"UNAUTHORIZED\"}"); return;
55
+ }
56
+ if (ex.getRequestURI().getRawQuery() != null && !ex.getRequestURI().getRawQuery().isEmpty()) {
57
+ send(ex, 400, "{\"error\":\"INVALID_INPUT\"}"); return;
58
+ }
59
+ String ct = ex.getRequestHeaders().getFirst("Content-Type");
60
+ if (ct == null || !ct.startsWith("application/json")) {
61
+ send(ex, 400, "{\"error\":\"INVALID_INPUT\"}"); return;
62
+ }
63
+ byte[] body;
64
+ try (InputStream is = ex.getRequestBody(); ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
65
+ byte[] buf = new byte[4096]; int n; long total = 0;
66
+ while ((n = is.read(buf)) > 0) { total += n; if (total > 180001) break; baos.write(buf, 0, n); }
67
+ body = baos.toByteArray();
68
+ }
69
+ if (body.length > 180000) { send(ex, 413, "{\"error\":\"PDF_TOO_LARGE\"}"); return; }
70
+ CharsetDecoder dec = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
71
+ String jsonStr;
72
+ try { jsonStr = dec.decode(java.nio.ByteBuffer.wrap(body)).toString(); } catch (Exception e) { send(ex, 400, "{\"error\":\"INVALID_INPUT\"}"); return; }
73
+ String b64 = parseJson(jsonStr);
74
+ if (b64 == null) { send(ex, 400, "{\"error\":\"INVALID_INPUT\"}"); return; }
75
+ if (b64.isEmpty()) { send(ex, 400, "{\"error\":\"INVALID_INPUT\"}"); return; }
76
+ if (b64.length() % 4 != 0) { send(ex, 400, "{\"error\":\"INVALID_INPUT\"}"); return; }
77
+ if (!b64.matches("^[A-Za-z0-9+/]*={0,2}$")) { send(ex, 400, "{\"error\":\"INVALID_INPUT\"}"); return; }
78
+ byte[] pdfBytes;
79
+ try { pdfBytes = Base64.getDecoder().decode(b64); } catch (Exception e) { send(ex, 400, "{\"error\":\"INVALID_INPUT\"}"); return; }
80
+ if (pdfBytes.length > 131072) { send(ex, 413, "{\"error\":\"PDF_TOO_LARGE\"}"); return; }
81
+ if (pdfBytes.length < 5 || pdfBytes[0]!='%'||pdfBytes[1]!='P'||pdfBytes[2]!='D'||pdfBytes[3]!='F'||pdfBytes[4]!='-') {
82
+ send(ex, 400, "{\"error\":\"INVALID_PDF\"}"); return;
83
+ }
84
+ PDDocument doc;
85
+ try { doc = Loader.loadPDF(pdfBytes); } catch (org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException e) { send(ex, 422, "{\"error\":\"ENCRYPTED_PDF\"}"); return; } catch (Exception e) { send(ex, 400, "{\"error\":\"INVALID_PDF\"}"); return; }
86
+ try (doc) {
87
+ if (doc.isEncrypted()) { send(ex, 422, "{\"error\":\"ENCRYPTED_PDF\"}"); return; }
88
+ int pc = doc.getNumberOfPages();
89
+ if (pc == 0) { send(ex, 400, "{\"error\":\"INVALID_PDF\"}"); return; }
90
+ if (pc > 20) { send(ex, 422, "{\"error\":\"PAGE_LIMIT\"}"); return; }
91
+ PDFTextStripper stripper = new PDFTextStripper();
92
+ stripper.setSortByPosition(true);
93
+ StringBuilder sb = new StringBuilder();
94
+ sb.append("{\"pageCount\":").append(pc).append(",\"pages\":[");
95
+ int totalCp = 0; boolean hasText = false; int totalTextUtf8 = 0;
96
+ for (int i = 1; i <= pc; i++) {
97
+ stripper.setStartPage(i); stripper.setEndPage(i);
98
+ String text;
99
+ try { text = stripper.getText(doc); } catch (Exception e) { send(ex, 400, "{\"error\":\"INVALID_PDF\"}"); return; }
100
+ text = text.replace("\r\n", "\n").replace("\r", "\n").strip();
101
+ int cp = text.codePointCount(0, text.length());
102
+ totalCp += cp;
103
+ if (!text.isEmpty()) hasText = true;
104
+ int utf8Len = text.getBytes(StandardCharsets.UTF_8).length;
105
+ totalTextUtf8 += utf8Len;
106
+ if (i > 1) sb.append(",");
107
+ sb.append("{\"page\":").append(i).append(",\"text\":\"").append(esc(text)).append("\"}");
108
+ }
109
+ if (totalTextUtf8 > 24000) { send(ex, 413, "{\"error\":\"TEXT_LIMIT\"}"); return; }
110
+ sb.append("],\"totalCharacters\":").append(totalCp).append(",\"status\":\"").append(hasText ? "TEXT_EXTRACTED" : "NO_TEXT").append("\"}");
111
+ String resp = sb.toString();
112
+ if (resp.getBytes(StandardCharsets.UTF_8).length > 60000) { send(ex, 413, "{\"error\":\"TEXT_LIMIT\"}"); return; }
113
+ send(ex, 200, resp);
114
+ }
115
+ }
116
+
117
+ private static String parseJson(String s) {
118
+ int i = 0, n = s.length();
119
+ i = skipWs(s, i); if (i >= n || s.charAt(i) != '{') return null; i++;
120
+ i = skipWs(s, i); if (i >= n || s.charAt(i) != '"') return null;
121
+ String key = readStr(s, i); if (key == null || !key.equals("base64")) return null;
122
+ i = advStr(s, i); i = skipWs(s, i); if (i >= n || s.charAt(i) != ':') return null; i++;
123
+ i = skipWs(s, i); if (i >= n || s.charAt(i) != '"') return null;
124
+ String val = readStr(s, i); if (val == null) return null;
125
+ i = advStr(s, i); i = skipWs(s, i);
126
+ if (i < n && s.charAt(i) == ',') {
127
+ i++; i = skipWs(s, i);
128
+ if (i >= n || s.charAt(i) != '"') return null;
129
+ return null;
130
+ }
131
+ if (i >= n || s.charAt(i) != '}') return null;
132
+ i++; i = skipWs(s, i); if (i < n) return null;
133
+ return val;
134
+ }
135
+
136
+ private static int skipWs(String s, int i) { while (i < s.length() && Character.isWhitespace(s.charAt(i))) i++; return i; }
137
+
138
+ private static String readStr(String s, int start) {
139
+ if (start >= s.length() || s.charAt(start) != '"') return null;
140
+ StringBuilder sb = new StringBuilder(); int i = start + 1;
141
+ while (i < s.length()) {
142
+ char c = s.charAt(i);
143
+ if (c == '\\') { i++; if (i >= s.length()) return null; char nx = s.charAt(i);
144
+ switch(nx){case'"':sb.append('"');break;case'\\':sb.append('\\');break;case'/':sb.append('/');break;case'b':sb.append('\b');break;case'f':sb.append('\f');break;case'n':sb.append('\n');break;case'r':sb.append('\r');break;case't':sb.append('\t');break;case'u':if(i+4>=s.length())return null;String h=s.substring(i+1,i+5);try{sb.append((char)Integer.parseInt(h,16));}catch(Exception e){return null;}i+=4;break;default:return null;} i++;
145
+ } else if (c == '"') { return sb.toString(); } else { sb.append(c); i++; }
146
+ }
147
+ return null;
148
+ }
149
+
150
+ private static int advStr(String s, int start) {
151
+ int i = start + 1;
152
+ while (i < s.length()) { char c = s.charAt(i); if (c == '\\') { i += 2; } else if (c == '"') { return i + 1; } else { i++; } }
153
+ return i;
154
+ }
155
+
156
+ private static String esc(String s) {
157
+ StringBuilder sb = new StringBuilder(s.length());
158
+ for (int i = 0; i < s.length(); ) {
159
+ int cp = s.codePointAt(i);
160
+ if (cp == '"') sb.append("\\\"");
161
+ else if (cp == '\\') sb.append("\\\\");
162
+ else if (cp == '\n') sb.append("\\n");
163
+ else if (cp == '\r') sb.append("\\r");
164
+ else if (cp == '\t') sb.append("\\t");
165
+ else if (cp == '\b') sb.append("\\b");
166
+ else if (cp == '\f') sb.append("\\f");
167
+ else if (cp < 0x20) sb.append(String.format("\\u%04x", cp));
168
+ else sb.appendCodePoint(cp);
169
+ i += Character.charCount(cp);
170
+ }
171
+ return sb.toString();
172
+ }
173
+ }
examples/hf-generated/pdf/validation-evidence.json ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "generation": {
3
+ "digest": "1a892920f9043541d038218e1882c70f715b59a19cf47e7de825b549e4348b8a",
4
+ "manifest": {
5
+ "approvals": [
6
+ {
7
+ "authorization_ref": "local-web-delegation-v1:user-c3adb31fc78c4d59970af883326ccff5",
8
+ "digest": "17998906c275b00fbfc618f4fb52b6dc9a462d856003caabed43972e4e62e4ed",
9
+ "increment": true,
10
+ "mechanism": "delegated_local_validation",
11
+ "node": "design_confirm",
12
+ "scope": "design",
13
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
14
+ },
15
+ {
16
+ "authorization_ref": "local-web-delegation-v1:user-c3adb31fc78c4d59970af883326ccff5",
17
+ "digest": "8cf46bd8a9e4cca7b714208b12340afdbc2a816fc657375b648dcab2b8dd9b5f",
18
+ "increment": true,
19
+ "mechanism": "delegated_local_validation",
20
+ "node": "execution_confirm",
21
+ "scope": "execution",
22
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
23
+ },
24
+ {
25
+ "authorization_ref": "local-web-delegation-v1:user-c3adb31fc78c4d59970af883326ccff5",
26
+ "digest": "daf93b893f4a4e3f8d4bb3c1c60d5e0b2c31d1d0522306d626910bedcad3c4fa",
27
+ "increment": false,
28
+ "mechanism": "delegated_local_validation",
29
+ "node": "repair-execution",
30
+ "scope": "execution",
31
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
32
+ }
33
+ ],
34
+ "candidate": {
35
+ "classes_digest": "84d779e18a69c02f3dd173aa8899c5eb2a4688958424aebdacb467c44c50e3fe",
36
+ "config_digest": "a4a4dc0214cc1380cad3d35772556b07e4965e033ec5b6a7cc078c3ed4edcf90",
37
+ "container": "zk-run-415025244a2a42f09cb63bc4e17902ca",
38
+ "execution_mode": "qemu",
39
+ "image": "zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
40
+ "isolation": {
41
+ "disposable": true,
42
+ "host_mounts": [],
43
+ "memory_mb": 1024,
44
+ "network": "none",
45
+ "vcpu": 1
46
+ },
47
+ "passed": true,
48
+ "receipt_digest": "500518ab3fd527ab46e214b0a44713d1e4d3ea93788be79c01578ee1f68a2bca",
49
+ "receipt_ref": "run-415025244a2a42f09cb63bc4e17902ca-0bd532b8ab1543cebdd608e5fbeae3df",
50
+ "source_digest": "9f3208baf0d4fa933050bde2753eee151517a6e197f2983a14bfdc7c92d9e79b",
51
+ "stage": "build",
52
+ "suite_digest": "6f34e0f7890e031d81ff5718d7f192eacc2c98b2ed9ad50cce8acf4ce17ba74b",
53
+ "tool_receipt": {
54
+ "input_digest": "dfeb5e173126e5783f6d7f08a96c21a9c49aa1d7440b9104ae72bbda351f5ad4",
55
+ "operation": "AO08",
56
+ "result_digest": "cf75c0dcc1768c58bfc9fef85912c45ffedde40723d00032716a281a3886294c",
57
+ "run_id": "run-415025244a2a42f09cb63bc4e17902ca"
58
+ }
59
+ },
60
+ "deployment": "not_performed",
61
+ "development": {
62
+ "design": {
63
+ "summary": "Implement demo.App as a Java17 HttpServer on port 8080. Define endpoints: GET /health returns {\"status\":\"ok\"}; POST /api/pdf/analyze requires Authorization header 'Bearer demo-pdf'. Enforce method/path checks before auth to return 405/404 appropriately. Parse JSON body strictly for single 'base64' field; reject extra fields or non-canonical Base64 with 400 INVALID_INPUT. Limit request size to 180001 bytes and decoded PDF to 131072 bytes (413 PDF_TOO_LARGE). Validate Content-Type starts with application/json. Use PDFBox 3.0.8 Loader.loadPDF(byte[]) in try-with-resources. Check document.isEncrypted() -> 422 ENCRYPTED_PDF. Verify page count: 0 pages -> 400 INVALID_PDF, >20 pages -> 422 PAGE_LIMIT. Extract text per page using PDFTextStripper (sortByPosition=true), normalize CRLF/CR to LF, strip surrounding whitespace. Count Unicode code points. If all pages empty -> status NO_TEXT, else TEXT_EXTRACTED. Check total UTF-8 text length <= 24000 and serialized response <= 60000 bytes; otherwise 413 TEXT_LIMIT. Return JSON with pageCount, pages array, totalCharacters, and status. Ensure no external dependencies beyond pinned PDFBox jar."
64
+ },
65
+ "requirement": "# DEMO-PDF-01:PDF文件读取与逐页文本解析\n\n## 背景与用户\n文档管理员需要确认PDF页数,逐页提取可复制的文本并导出,便于资料核对和后续索引。本地演示支持小型文字PDF;扫描件要明确说明没有可提取文字,不能冒充完成OCR。\n\n## 页面与交互\n标题“PDF文档解析”,左侧为上传区(选择PDF按钮、文件名/大小、128KiB上限、载入示例、开始解析),右侧为页数/文字数摘要和逐页结果。页签或上一页/下一页控件可切换,显示“第n页/共m页”。文本保留换行并可复制;提供TXT和JSON下载,文件名清晰。\n支持拖入一个文件与移除当前文件;换文件或移除时立即清空旧页和旧导出状态。应用不显示原始接口返回、源码/测试摘要、沙箱启动步骤或代码下载。TXT/JSON导出仅包含用户解析的业务文本;代码、差异和运行证据在��作台查看,预览准备在平台内部完成。\n选中文件后只显示元信息,点击开始解析才发送。解析时禁用重复提交,真实服务返回后展示结果。重新选文件清空旧成功状态,旧内容不得冒充新文件结果。文件缺失、非PDF、超限、加密、损坏及无文本分别显示可理解说明。示例按钮载入随制品交付的合法两页PDF,用户无自备文件也能完整运行。键盘可操作,窄屏上下排列。\n\n## 编程需求与验收\n- PDF-01:Java17 HttpServer;使用固定Apache PDFBox 3.0.8单一依赖,版本、来源、许可证、SHA256随制品记录。依赖提前校验进入无网沙箱,运行时不下载,不读取宿主文件。\n- PDF-02:POST /api/pdf/analyze,JSON仅base64字符串,公开演示凭据demo-pdf。原始PDF最大131072字节,最多20页,提取文本UTF-8最大24000字节;JSON边界180000字节。只接受真实文件内容,不接受服务端路径或URL。\n- PDF-03:200返回pageCount、pages[{page,text}]、totalCharacters、status。页号从1连续,按页读取文本,去除提取器末尾多余换行;成功文本状态TEXT_EXTRACTED,无文本为NO_TEXT。两页示例输出应与固定期望文本一致。\n- PDF-04:非法JSON/base64为400 INVALID_INPUT;损坏或非PDF为400 INVALID_PDF;加密PDF为422 ENCRYPTED_PDF;超过20页为422 PAGE_LIMIT;文件或文本超限分别413 PDF_TOO_LARGE/TEXT_LIMIT。无身份401、错误method405、未知路径404。解析失败不保留上传文件。\n- PDF-05:独立系统测试覆盖正常多页、无文本、错误内容、加密、页数及大小边界;浏览器测试覆盖选择示例→解析→切页→复制/下载、错误文件、重复点击和窄屏。\n\n## 交付与完成条件\n交付Java解析源码、HTML/CSS/JS网站、两页测试PDF、固定依赖清单、需求原文、设计、修改差异、逐条验收映射和真实编译/测试报告。生成源码只允许批准路径,不能修改独立测试。以模型或经记录的接管修复迭代到测试通过,给本地网站和源码制品下载;OCR、超限大型文档和生产部署不在本次验收范围。\n\n\nHF验收批次 20261024T044442Z pdf。完整实现上述需求;模型、框架和权限仍由服务端冻结契约决定。"
66
+ },
67
+ "human_acceptance": false,
68
+ "model_calls": [
69
+ {
70
+ "charged": 4747,
71
+ "id": 11,
72
+ "metadata": {
73
+ "finish_reason": "stop",
74
+ "model": "qwen3.8-flash",
75
+ "policy_version": "bailian-task-routing-v2",
76
+ "request_id": "chatcmpl-df9c9b8a-441c-9a3b-a7b6-30b34a91302b",
77
+ "requested_output_tokens": 2048,
78
+ "retry_of": null,
79
+ "route_reason": "technical-design",
80
+ "stage": "design"
81
+ },
82
+ "prompt_digest": "1883f3a2c0f255c592dddef1559993e05cf7eb47499d603d82982493e8ea63c2",
83
+ "provider": "bailian-qwen3.8-flash",
84
+ "reservation": 17625,
85
+ "run_id": "run-415025244a2a42f09cb63bc4e17902ca",
86
+ "state": "settled"
87
+ },
88
+ {
89
+ "charged": 5126,
90
+ "id": 12,
91
+ "metadata": {
92
+ "finish_reason": "stop",
93
+ "model": "qwen3.8-max",
94
+ "policy_version": "bailian-task-routing-v2",
95
+ "request_id": "chatcmpl-91d41343-d438-9ae0-981f-2a8a6c41fdee",
96
+ "requested_output_tokens": 12288,
97
+ "retry_of": null,
98
+ "route_reason": "dependency-code",
99
+ "stage": "code"
100
+ },
101
+ "prompt_digest": "71bbb2934c2e069cb8638b383a568cda6d0f40baf000d0ef6f1196a268be9676",
102
+ "provider": "bailian-qwen3.8-max",
103
+ "reservation": 21598,
104
+ "run_id": "run-415025244a2a42f09cb63bc4e17902ca",
105
+ "state": "settled"
106
+ },
107
+ {
108
+ "charged": 7267,
109
+ "id": 13,
110
+ "metadata": {
111
+ "finish_reason": "stop",
112
+ "model": "qwen3.8-max",
113
+ "policy_version": "bailian-task-routing-v2",
114
+ "request_id": "chatcmpl-aef13472-7cab-953b-9f71-13de021222ce",
115
+ "requested_output_tokens": 12288,
116
+ "retry_of": null,
117
+ "route_reason": "diagnostic-repair",
118
+ "stage": "repair"
119
+ },
120
+ "prompt_digest": "7b04c1c06dd33d0632ea85c7ea1c4aa23a72dbb25ddc6d9203e49d69911356cc",
121
+ "provider": "bailian-qwen3.8-max",
122
+ "reservation": 27804,
123
+ "run_id": "run-415025244a2a42f09cb63bc4e17902ca",
124
+ "state": "settled"
125
+ }
126
+ ],
127
+ "preview": {
128
+ "cases": 1,
129
+ "classes_digest": "84d779e18a69c02f3dd173aa8899c5eb2a4688958424aebdacb467c44c50e3fe",
130
+ "config_digest": "a4a4dc0214cc1380cad3d35772556b07e4965e033ec5b6a7cc078c3ed4edcf90",
131
+ "container": "zk-run-415025244a2a42f09cb63bc4e17902ca",
132
+ "execution_mode": "qemu",
133
+ "image": "zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
134
+ "isolation": {
135
+ "disposable": true,
136
+ "host_mounts": [],
137
+ "memory_mb": 1024,
138
+ "network": "none",
139
+ "vcpu": 1
140
+ },
141
+ "passed": true,
142
+ "passed_cases": 1,
143
+ "preview_scope": "disposable-vm-loopback-http",
144
+ "receipt_digest": "500518ab3fd527ab46e214b0a44713d1e4d3ea93788be79c01578ee1f68a2bca",
145
+ "receipt_ref": "run-415025244a2a42f09cb63bc4e17902ca-0bd532b8ab1543cebdd608e5fbeae3df",
146
+ "source_digest": "9f3208baf0d4fa933050bde2753eee151517a6e197f2983a14bfdc7c92d9e79b",
147
+ "stage": "preview",
148
+ "suite_digest": "6f34e0f7890e031d81ff5718d7f192eacc2c98b2ed9ad50cce8acf4ce17ba74b",
149
+ "tool_receipt": {
150
+ "input_digest": "bd266373b3cd18a067d1bc70d46e70fed30d70b44422943c60d4c3dc8d8921cf",
151
+ "operation": "AO10",
152
+ "result_digest": "8ddca3e5d0edd9476f7033b90f2c8f1c1d8605574e207519c33b56330fb342db",
153
+ "run_id": "run-415025244a2a42f09cb63bc4e17902ca"
154
+ }
155
+ },
156
+ "repairs": 1,
157
+ "run_id": "run-415025244a2a42f09cb63bc4e17902ca",
158
+ "sandbox_cleaned": true,
159
+ "snapshot": {
160
+ "budget": {
161
+ "max_model_calls": 6,
162
+ "max_repairs": 2,
163
+ "max_seconds": 1800,
164
+ "max_tokens": 120000
165
+ },
166
+ "execution_order": [
167
+ "start",
168
+ "requirements",
169
+ "knowledge",
170
+ "context",
171
+ "design",
172
+ "design_confirm",
173
+ "execution_confirm",
174
+ "code",
175
+ "patch",
176
+ "policy",
177
+ "build",
178
+ "test",
179
+ "preview",
180
+ "acceptance",
181
+ "evidence",
182
+ "end"
183
+ ],
184
+ "execution_status": "not_started",
185
+ "framework": {
186
+ "allowed_paths": [
187
+ "src/main/",
188
+ "src/test/",
189
+ "docs/"
190
+ ],
191
+ "build_tool": "jdk",
192
+ "dependencies": {
193
+ "org.apache.pdfbox:pdfbox-app": "3.0.8"
194
+ },
195
+ "evidence_refs": [
196
+ "local-toolchain:zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
197
+ "user-requested-pdf-development"
198
+ ],
199
+ "frontend": [
200
+ "html",
201
+ "javascript",
202
+ "css"
203
+ ],
204
+ "java_release": 17,
205
+ "language": "java",
206
+ "profile_id": "java17-pdfbox-web",
207
+ "state": "approved",
208
+ "version": "0.1.0"
209
+ },
210
+ "knowledge": [
211
+ {
212
+ "collection_id": "java-basics",
213
+ "digest": "6de6f354ff0e845da78ad210164775f51d9a4c5f01a1e5e355911423bd6a5b5c",
214
+ "enterprise_approved": false,
215
+ "quality_status": "imported_unreviewed",
216
+ "revision": "corpus-6de6f354ff0e845da78ad210",
217
+ "scope": "reference"
218
+ },
219
+ {
220
+ "collection_id": "java-patterns",
221
+ "digest": "803bd1aef5f0764242a56a8c85a3eca81b26cebbe4ec3e6b53d3c4da8864aa2d",
222
+ "enterprise_approved": false,
223
+ "quality_status": "imported_unreviewed",
224
+ "revision": "corpus-803bd1aef5f0764242a56a8c",
225
+ "scope": "reference"
226
+ },
227
+ {
228
+ "collection_id": "java-integration",
229
+ "digest": "befde1177fa13476703d89a8df3902d90ad01cb7d497d0583cfe15620348c7b1",
230
+ "enterprise_approved": false,
231
+ "quality_status": "imported_unreviewed",
232
+ "revision": "corpus-befde1177fa13476703d89a8",
233
+ "scope": "reference"
234
+ },
235
+ {
236
+ "collection_id": "java-frameworks",
237
+ "digest": "28b65fe6ced6682555c8b32b676faf14020011ea525eeee57f17562acd17da4c",
238
+ "enterprise_approved": false,
239
+ "quality_status": "imported_unreviewed",
240
+ "revision": "corpus-28b65fe6ced6682555c8b32b",
241
+ "scope": "reference"
242
+ },
243
+ {
244
+ "collection_id": "web-development",
245
+ "digest": "84c82986259278c89a30d2660f66454f0a5bcb10f871c96c7ec4ea9ebb47e02a",
246
+ "enterprise_approved": false,
247
+ "quality_status": "imported_unreviewed",
248
+ "revision": "corpus-84c82986259278c89a30d266",
249
+ "scope": "reference"
250
+ },
251
+ {
252
+ "collection_id": "java-persistence",
253
+ "digest": "972ee7e1f0072e413bec262b67b8af46364ff8aac445a9faeeeb8c041eb07f92",
254
+ "enterprise_approved": false,
255
+ "quality_status": "imported_unreviewed",
256
+ "revision": "corpus-972ee7e1f0072e413bec262b",
257
+ "scope": "reference"
258
+ },
259
+ {
260
+ "collection_id": "java-testing",
261
+ "digest": "8af9017057c130eef9f9a1617a2654859ba80ed4f108b28054aecf14a3d39c45",
262
+ "enterprise_approved": false,
263
+ "quality_status": "imported_unreviewed",
264
+ "revision": "corpus-8af9017057c130eef9f9a161",
265
+ "scope": "reference"
266
+ }
267
+ ],
268
+ "operations_lock": {
269
+ "AO01@0.1.0": "6f2a89d1624450c6e4afd8f776f23c7df4bf402976a82d0992dfd6cfdc643bf2",
270
+ "AO02@0.1.0": "6a4491053f9a3f55d900f3f907f81a0cfc44f09a1e2f1e770248287bc0b8d7f6",
271
+ "AO03@0.1.0": "8a1387e065674c2987930ad865a2bdb4ab7346cb589505c350c6bb1907a7eb6d",
272
+ "AO04@0.1.0": "3ef3f1be1b0f9240f066fa6d0b3b1430026d55763d15b5fc584a801c64be688b",
273
+ "AO05@0.2.0": "eeac70849a9d8bebd00b1d2111545f9376cc6901f6aa611412b1cb73238e47a7",
274
+ "AO06@0.1.0": "2b369879ba0cd2847c173cfb7cb583c1dc051553d3d3ea80f954c81c21f1f233",
275
+ "AO07@0.1.0": "69e1e824b4c5129f62595ac3df578eec7b083411cd391a72d47303eec3843baa",
276
+ "AO08@0.1.0": "1d75566610ac000990fd15b9fd18a6518de8af12a329b3c56d51ff29c0c30623",
277
+ "AO09@0.1.0": "2e4bf4b3fcdfce184b8dea9ffebd18ffe91af7320b0ef3ce430edb3b5cc15c52",
278
+ "AO10@0.1.0": "d05863bea57e94ad860696bd6ac85e072034f89f6f038f132c65b854dd366e9f",
279
+ "AO11@0.1.0": "43b910a51da7a58810d3890eb2305d80663db6a1c187b51466f8e396a94956f0"
280
+ },
281
+ "project_id": "pdf-demo",
282
+ "release_digest": "2e5501ff1636f29a752f2a621841b75cb8f99e631d478624339bb1ce8d22e4b5",
283
+ "release_ref": "pdf-java-development@local-2e5501ff1636f29a",
284
+ "snapshot_digest": "2c37dbbbb59b8337551a146adb34a4d15ebadc48ae682b3f36ba20578334e8c3",
285
+ "snapshot_id": "snapshot-c644848878d84584840d58748c70e4fc",
286
+ "source_digest": "44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
287
+ "tenant_id": "demo-tenant",
288
+ "user_id": "user-c3adb31fc78c4d59970af883326ccff5"
289
+ },
290
+ "source": {
291
+ "files": {
292
+ "src/main/java/demo/App.java": "package demo;\n\nimport com.sun.net.httpserver.HttpServer;\nimport com.sun.net.httpserver.HttpExchange;\nimport org.apache.pdfbox.Loader;\nimport org.apache.pdfbox.pdmodel.PDDocument;\nimport org.apache.pdfbox.text.PDFTextStripper;\nimport java.io.*;\nimport java.net.InetSocketAddress;\nimport java.nio.charset.CharsetDecoder;\nimport java.nio.charset.CodingErrorAction;\nimport java.nio.charset.StandardCharsets;\nimport java.util.Base64;\n\npublic class App {\n public static void main(String[] args) throws Exception {\n HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);\n server.createContext(\"/\", App::handleRoot);\n server.start();\n }\n\n private static void send(HttpExchange ex, int code, String json) throws IOException {\n byte[] b = json.getBytes(StandardCharsets.UTF_8);\n ex.getResponseHeaders().set(\"Content-Type\", \"application/json\");\n ex.sendResponseHeaders(code, b.length);\n try (OutputStream os = ex.getResponseBody()) { os.write(b); }\n ex.close();\n }\n\n private static void handleRoot(HttpExchange ex) throws IOException {\n String path = ex.getRequestURI().getPath();\n if (\"/health\".equals(path)) {\n handleHealth(ex);\n } else if (\"/api/pdf/analyze\".equals(path)) {\n handleAnalyze(ex);\n } else {\n send(ex, 404, \"{\\\"error\\\":\\\"NOT_FOUND\\\"}\");\n }\n }\n\n private static void handleHealth(HttpExchange ex) throws IOException {\n if (!\"GET\".equalsIgnoreCase(ex.getRequestMethod())) {\n send(ex, 405, \"{\\\"error\\\":\\\"METHOD_NOT_ALLOWED\\\"}\"); return;\n }\n send(ex, 200, \"{\\\"status\\\":\\\"ok\\\"}\");\n }\n\n private static void handleAnalyze(HttpExchange ex) throws IOException {\n if (!\"POST\".equalsIgnoreCase(ex.getRequestMethod())) {\n send(ex, 405, \"{\\\"error\\\":\\\"METHOD_NOT_ALLOWED\\\"}\"); return;\n }\n String auth = ex.getRequestHeaders().getFirst(\"Authorization\");\n if (!\"Bearer demo-pdf\".equals(auth)) {\n send(ex, 401, \"{\\\"error\\\":\\\"UNAUTHORIZED\\\"}\"); return;\n }\n if (ex.getRequestURI().getRawQuery() != null && !ex.getRequestURI().getRawQuery().isEmpty()) {\n send(ex, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return;\n }\n String ct = ex.getRequestHeaders().getFirst(\"Content-Type\");\n if (ct == null || !ct.startsWith(\"application/json\")) {\n send(ex, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return;\n }\n byte[] body;\n try (InputStream is = ex.getRequestBody(); ByteArrayOutputStream baos = new ByteArrayOutputStream()) {\n byte[] buf = new byte[4096]; int n; long total = 0;\n while ((n = is.read(buf)) > 0) { total += n; if (total > 180001) break; baos.write(buf, 0, n); }\n body = baos.toByteArray();\n }\n if (body.length > 180000) { send(ex, 413, \"{\\\"error\\\":\\\"PDF_TOO_LARGE\\\"}\"); return; }\n CharsetDecoder dec = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);\n String jsonStr;\n try { jsonStr = dec.decode(java.nio.ByteBuffer.wrap(body)).toString(); } catch (Exception e) { send(ex, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n String b64 = parseJson(jsonStr);\n if (b64 == null) { send(ex, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n if (b64.isEmpty()) { send(ex, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n if (b64.length() % 4 != 0) { send(ex, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n if (!b64.matches(\"^[A-Za-z0-9+/]*={0,2}$\")) { send(ex, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n byte[] pdfBytes;\n try { pdfBytes = Base64.getDecoder().decode(b64); } catch (Exception e) { send(ex, 400, \"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n if (pdfBytes.length > 131072) { send(ex, 413, \"{\\\"error\\\":\\\"PDF_TOO_LARGE\\\"}\"); return; }\n if (pdfBytes.length < 5 || pdfBytes[0]!='%'||pdfBytes[1]!='P'||pdfBytes[2]!='D'||pdfBytes[3]!='F'||pdfBytes[4]!='-') {\n send(ex, 400, \"{\\\"error\\\":\\\"INVALID_PDF\\\"}\"); return;\n }\n PDDocument doc;\n try { doc = Loader.loadPDF(pdfBytes); } catch (org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException e) { send(ex, 422, \"{\\\"error\\\":\\\"ENCRYPTED_PDF\\\"}\"); return; } catch (Exception e) { send(ex, 400, \"{\\\"error\\\":\\\"INVALID_PDF\\\"}\"); return; }\n try (doc) {\n if (doc.isEncrypted()) { send(ex, 422, \"{\\\"error\\\":\\\"ENCRYPTED_PDF\\\"}\"); return; }\n int pc = doc.getNumberOfPages();\n if (pc == 0) { send(ex, 400, \"{\\\"error\\\":\\\"INVALID_PDF\\\"}\"); return; }\n if (pc > 20) { send(ex, 422, \"{\\\"error\\\":\\\"PAGE_LIMIT\\\"}\"); return; }\n PDFTextStripper stripper = new PDFTextStripper();\n stripper.setSortByPosition(true);\n StringBuilder sb = new StringBuilder();\n sb.append(\"{\\\"pageCount\\\":\").append(pc).append(\",\\\"pages\\\":[\");\n int totalCp = 0; boolean hasText = false; int totalTextUtf8 = 0;\n for (int i = 1; i <= pc; i++) {\n stripper.setStartPage(i); stripper.setEndPage(i);\n String text;\n try { text = stripper.getText(doc); } catch (Exception e) { send(ex, 400, \"{\\\"error\\\":\\\"INVALID_PDF\\\"}\"); return; }\n text = text.replace(\"\\r\\n\", \"\\n\").replace(\"\\r\", \"\\n\").strip();\n int cp = text.codePointCount(0, text.length());\n totalCp += cp;\n if (!text.isEmpty()) hasText = true;\n int utf8Len = text.getBytes(StandardCharsets.UTF_8).length;\n totalTextUtf8 += utf8Len;\n if (i > 1) sb.append(\",\");\n sb.append(\"{\\\"page\\\":\").append(i).append(\",\\\"text\\\":\\\"\").append(esc(text)).append(\"\\\"}\");\n }\n if (totalTextUtf8 > 24000) { send(ex, 413, \"{\\\"error\\\":\\\"TEXT_LIMIT\\\"}\"); return; }\n sb.append(\"],\\\"totalCharacters\\\":\").append(totalCp).append(\",\\\"status\\\":\\\"\").append(hasText ? \"TEXT_EXTRACTED\" : \"NO_TEXT\").append(\"\\\"}\");\n String resp = sb.toString();\n if (resp.getBytes(StandardCharsets.UTF_8).length > 60000) { send(ex, 413, \"{\\\"error\\\":\\\"TEXT_LIMIT\\\"}\"); return; }\n send(ex, 200, resp);\n }\n }\n\n private static String parseJson(String s) {\n int i = 0, n = s.length();\n i = skipWs(s, i); if (i >= n || s.charAt(i) != '{') return null; i++;\n i = skipWs(s, i); if (i >= n || s.charAt(i) != '\"') return null;\n String key = readStr(s, i); if (key == null || !key.equals(\"base64\")) return null;\n i = advStr(s, i); i = skipWs(s, i); if (i >= n || s.charAt(i) != ':') return null; i++;\n i = skipWs(s, i); if (i >= n || s.charAt(i) != '\"') return null;\n String val = readStr(s, i); if (val == null) return null;\n i = advStr(s, i); i = skipWs(s, i);\n if (i < n && s.charAt(i) == ',') {\n i++; i = skipWs(s, i);\n if (i >= n || s.charAt(i) != '\"') return null;\n return null;\n }\n if (i >= n || s.charAt(i) != '}') return null;\n i++; i = skipWs(s, i); if (i < n) return null;\n return val;\n }\n\n private static int skipWs(String s, int i) { while (i < s.length() && Character.isWhitespace(s.charAt(i))) i++; return i; }\n\n private static String readStr(String s, int start) {\n if (start >= s.length() || s.charAt(start) != '\"') return null;\n StringBuilder sb = new StringBuilder(); int i = start + 1;\n while (i < s.length()) {\n char c = s.charAt(i);\n if (c == '\\\\') { i++; if (i >= s.length()) return null; char nx = s.charAt(i);\n switch(nx){case'\"':sb.append('\"');break;case'\\\\':sb.append('\\\\');break;case'/':sb.append('/');break;case'b':sb.append('\\b');break;case'f':sb.append('\\f');break;case'n':sb.append('\\n');break;case'r':sb.append('\\r');break;case't':sb.append('\\t');break;case'u':if(i+4>=s.length())return null;String h=s.substring(i+1,i+5);try{sb.append((char)Integer.parseInt(h,16));}catch(Exception e){return null;}i+=4;break;default:return null;} i++;\n } else if (c == '\"') { return sb.toString(); } else { sb.append(c); i++; }\n }\n return null;\n }\n\n private static int advStr(String s, int start) {\n int i = start + 1;\n while (i < s.length()) { char c = s.charAt(i); if (c == '\\\\') { i += 2; } else if (c == '\"') { return i + 1; } else { i++; } }\n return i;\n }\n\n private static String esc(String s) {\n StringBuilder sb = new StringBuilder(s.length());\n for (int i = 0; i < s.length(); ) {\n int cp = s.codePointAt(i);\n if (cp == '\"') sb.append(\"\\\\\\\"\");\n else if (cp == '\\\\') sb.append(\"\\\\\\\\\");\n else if (cp == '\\n') sb.append(\"\\\\n\");\n else if (cp == '\\r') sb.append(\"\\\\r\");\n else if (cp == '\\t') sb.append(\"\\\\t\");\n else if (cp == '\\b') sb.append(\"\\\\b\");\n else if (cp == '\\f') sb.append(\"\\\\f\");\n else if (cp < 0x20) sb.append(String.format(\"\\\\u%04x\", cp));\n else sb.appendCodePoint(cp);\n i += Character.charCount(cp);\n }\n return sb.toString();\n }\n}"
293
+ },
294
+ "source_digest": "9f3208baf0d4fa933050bde2753eee151517a6e197f2983a14bfdc7c92d9e79b"
295
+ },
296
+ "status": "verified_pending_user_acceptance",
297
+ "test": {
298
+ "cases": 23,
299
+ "classes_digest": "84d779e18a69c02f3dd173aa8899c5eb2a4688958424aebdacb467c44c50e3fe",
300
+ "config_digest": "a4a4dc0214cc1380cad3d35772556b07e4965e033ec5b6a7cc078c3ed4edcf90",
301
+ "container": "zk-run-415025244a2a42f09cb63bc4e17902ca",
302
+ "execution_mode": "qemu",
303
+ "image": "zkcoding-qemu@sha256:5c866338b848ec50afbbcb7f0827f562c2aced18638922dd72ae73eaa6bc15ec",
304
+ "isolation": {
305
+ "disposable": true,
306
+ "host_mounts": [],
307
+ "memory_mb": 1024,
308
+ "network": "none",
309
+ "vcpu": 1
310
+ },
311
+ "passed": true,
312
+ "passed_cases": 23,
313
+ "preview_scope": "disposable-vm-loopback-http",
314
+ "receipt_digest": "500518ab3fd527ab46e214b0a44713d1e4d3ea93788be79c01578ee1f68a2bca",
315
+ "receipt_ref": "run-415025244a2a42f09cb63bc4e17902ca-0bd532b8ab1543cebdd608e5fbeae3df",
316
+ "source_digest": "9f3208baf0d4fa933050bde2753eee151517a6e197f2983a14bfdc7c92d9e79b",
317
+ "stage": "test",
318
+ "suite_digest": "6f34e0f7890e031d81ff5718d7f192eacc2c98b2ed9ad50cce8acf4ce17ba74b",
319
+ "tool_receipt": {
320
+ "input_digest": "bd266373b3cd18a067d1bc70d46e70fed30d70b44422943c60d4c3dc8d8921cf",
321
+ "operation": "AO09",
322
+ "result_digest": "95fb7fabcfbe0d84bb838cb9d6a29bc661ea9ab774ee996ea4d1eba877bd7394",
323
+ "run_id": "run-415025244a2a42f09cb63bc4e17902ca"
324
+ }
325
+ }
326
+ }
327
+ },
328
+ "local_replay": {
329
+ "generation_run": "run-415025244a2a42f09cb63bc4e17902ca",
330
+ "source_digest": "9f3208baf0d4fa933050bde2753eee151517a6e197f2983a14bfdc7c92d9e79b",
331
+ "lease": "8a108743da8b4cdc8ba5bf29b4b7c749",
332
+ "receipt": {
333
+ "source_digest": "9f3208baf0d4fa933050bde2753eee151517a6e197f2983a14bfdc7c92d9e79b",
334
+ "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
335
+ "config_digest": "128defe2109c8b7693134f252f9235bc863b5915fc11d640b8bd52394e589c72",
336
+ "classes_digest": "84d779e18a69c02f3dd173aa8899c5eb2a4688958424aebdacb467c44c50e3fe",
337
+ "tests": 23,
338
+ "network": "none",
339
+ "host_mounts": []
340
+ }
341
+ },
342
+ "human_acceptance": false
343
+ }
examples/hf-ingress-validation.json CHANGED
@@ -8,7 +8,7 @@
8
  "popup receives the exact parent identity; an independent programmer remains denied"
9
  ],
10
  "errors": [],
11
- "platform_code_digest": "e0a3ec3a5ae02330a93942d3ac9e324c0cd186e23a92e8872fbaa8e11ccdc3b2",
12
  "cloud_runtime_files": {
13
  "deploy/hf/adapter.py": "0088b19648ab9661bb6eb6bdf4fa34de368f5fe5d6c347a58504c60331f42e95",
14
  "deploy/hf/app.py": "0e8a5729b5e99aae88c277d718e0afa6de21350515f92452996d10deac7612f3",
@@ -24,29 +24,21 @@
24
  "receipt": {
25
  "source_digest": "b80e5c95d1153f8e664d4b7bac3701d52fecab2a41de12e5a49ea0fd795cd7a4",
26
  "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
27
- "config_digest": "c46d1daa9b28bd7f8fdd157e1113ddd512216799fb1b752b9c165d6465d0ac96",
28
  "classes_digest": "779f483b28864a212c3e199cedc317c3664d207bc8eab14f7d48e47d6be085ad",
29
  "tests": 39,
30
  "network": "none",
31
  "host_mounts": []
32
  },
33
  "passed": 6,
34
- "tested_at_utc": "2026-10-24T04:29:23.425297+00:00",
35
  "unit_tests": {
36
- "passed": 26,
37
  "skipped": 0
38
  },
39
  "core_tests": {
40
- "total": 236,
41
- "passed": 234,
42
  "skipped": 2
43
- },
44
- "preview_scope": "single-preview-only",
45
- "null_window_reference_reproduced": true,
46
- "cloud_publication": {
47
- "space": "dellweb3/VibeCoding",
48
- "state": "third_candidate_ready",
49
- "cloud_acceptance_pending": true,
50
- "model_secret_configured": true
51
  }
52
  }
 
8
  "popup receives the exact parent identity; an independent programmer remains denied"
9
  ],
10
  "errors": [],
11
+ "platform_code_digest": "cc0bd4d6541c7fd2c321bc1de034f9ef635384bfb24b8d0bebfc0b741573f5b2",
12
  "cloud_runtime_files": {
13
  "deploy/hf/adapter.py": "0088b19648ab9661bb6eb6bdf4fa34de368f5fe5d6c347a58504c60331f42e95",
14
  "deploy/hf/app.py": "0e8a5729b5e99aae88c277d718e0afa6de21350515f92452996d10deac7612f3",
 
24
  "receipt": {
25
  "source_digest": "b80e5c95d1153f8e664d4b7bac3701d52fecab2a41de12e5a49ea0fd795cd7a4",
26
  "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
27
+ "config_digest": "ec1c941302d1f0bf34512b9b524f7c8dc5bfd523f22fe50093f8cd757cdfc848",
28
  "classes_digest": "779f483b28864a212c3e199cedc317c3664d207bc8eab14f7d48e47d6be085ad",
29
  "tests": 39,
30
  "network": "none",
31
  "host_mounts": []
32
  },
33
  "passed": 6,
34
+ "tested_at_utc": "2026-10-24T05:09:19.413583+00:00",
35
  "unit_tests": {
36
+ "passed": 27,
37
  "skipped": 0
38
  },
39
  "core_tests": {
40
+ "total": 241,
41
+ "passed": 239,
42
  "skipped": 2
 
 
 
 
 
 
 
 
43
  }
44
  }
examples/waiting-recovery-validation.json ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "waiting": {
3
+ "checks": [
4
+ "Original wizard submits an explicit recovery policy; conversation tail shows actual phase, elapsed time and read freshness instead of dots",
5
+ "Controlled GET interruption is visible and retries the same task without re-submitting",
6
+ "Actual Java compile failure automatically creates exactly one linked continuation, preserves old failure and reaches 39 protected HTTP passes without a user repair click",
7
+ "Recovered files and diff are reviewable; separate Java website calculates and rejects division by zero; original workbench and narrow layout remain usable"
8
+ ],
9
+ "errors": [],
10
+ "controlled_failure": true,
11
+ "external_model_calls": 0,
12
+ "platform_code_digest": "cc0bd4d6541c7fd2c321bc1de034f9ef635384bfb24b8d0bebfc0b741573f5b2",
13
+ "fixture_budget_max_repairs": 0,
14
+ "original_run": "run-96763d49b9614327af86b1f0ee179916",
15
+ "final_run": "run-9cbdd0d6a3e24031a5ac60de6608da54",
16
+ "protected_http_cases": 39,
17
+ "controlled_provider_calls": 4,
18
+ "passed": 4
19
+ },
20
+ "https": {
21
+ "checks": [
22
+ "original conversation shell and all three real sessions work over HTTPS with secure cookies",
23
+ "foreign-origin mutation is rejected before entering the local app",
24
+ "workbench preview click opens the actual Java calculator on the same public HTTPS origin; decimal and error paths operate",
25
+ "application refresh is usable and original workbench remains at root",
26
+ "fresh third-party iframe and null WindowProxy popup receive only an authorized manager lease capability and run real Java",
27
+ "popup receives the exact parent identity; an independent programmer remains denied"
28
+ ],
29
+ "errors": [],
30
+ "platform_code_digest": "cc0bd4d6541c7fd2c321bc1de034f9ef635384bfb24b8d0bebfc0b741573f5b2",
31
+ "cloud_runtime_files": {
32
+ "deploy/hf/adapter.py": "0088b19648ab9661bb6eb6bdf4fa34de368f5fe5d6c347a58504c60331f42e95",
33
+ "deploy/hf/app.py": "0e8a5729b5e99aae88c277d718e0afa6de21350515f92452996d10deac7612f3",
34
+ "deploy/hf/prepare_image.py": "8c548bf8881ee0510fd65e5d2de6b464df3d4212bcc5f736363bbdaac32ff0c7",
35
+ "deploy/hf/Dockerfile": "e18a9d956fec5943436409223be6ec5df6f85be46980a58458e02c9ce3439f31",
36
+ "deploy/hf/preview_bridge.py": "9a5fe782621e8a9afe2ff199f294018ae4910c007244e350c31829eaaf19d093",
37
+ "deploy/hf/scoped_preview.py": "278f70a4cff3b6fabf26d66a648910518356aa6efeba2a46b4a45f4332eee5bf",
38
+ "deploy/hf/preview-parent.js": "3f4dcde23d39cce65b597059ad42d759f8c4b35a76813a2c0f6ffb7483f9a442",
39
+ "deploy/hf/preview-bridge.js": "436c295efd8631f88cbcc46021a14f53173e3c4f6e471e63fcf8b3c1fe6ec014",
40
+ "deploy/hf/preview-bridge.html": "0f709ec2027d6f623cfa5c4b6aad4f104355895fdc768907b8c6dd31a52b06cc"
41
+ },
42
+ "scope": "local HTTPS ingress, not HF runtime",
43
+ "receipt": {
44
+ "source_digest": "b80e5c95d1153f8e664d4b7bac3701d52fecab2a41de12e5a49ea0fd795cd7a4",
45
+ "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
46
+ "config_digest": "ec1c941302d1f0bf34512b9b524f7c8dc5bfd523f22fe50093f8cd757cdfc848",
47
+ "classes_digest": "779f483b28864a212c3e199cedc317c3664d207bc8eab14f7d48e47d6be085ad",
48
+ "tests": 39,
49
+ "network": "none",
50
+ "host_mounts": []
51
+ },
52
+ "passed": 6,
53
+ "tested_at_utc": "2026-10-24T05:09:19.413583+00:00"
54
+ },
55
+ "three_apps": {
56
+ "checks": [
57
+ "erp: exact HF-generated source passes protected tests again, real website operates and refreshes independently",
58
+ "calculator: exact HF-generated source passes protected tests again, real website operates and refreshes independently",
59
+ "pdf: exact HF-generated source passes protected tests again, real website operates and refreshes independently",
60
+ "All three independent real Java websites coexist; original conversation workbench stays at its entry"
61
+ ],
62
+ "errors": [],
63
+ "scenarios": {
64
+ "erp": {
65
+ "generation_run": "run-8f523ff16b6b4c95832e46b4b6110a8d",
66
+ "source_digest": "86f2fd3b99c6f8b21ceb2595171ed841194fcc7c791b60ea1a8cf0d90d6ba1be",
67
+ "lease": "a36fe1894b964ecc9b5dd9be6900eda7",
68
+ "receipt": {
69
+ "source_digest": "86f2fd3b99c6f8b21ceb2595171ed841194fcc7c791b60ea1a8cf0d90d6ba1be",
70
+ "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
71
+ "config_digest": "841129aac9dd785fe877d72002533547377a93994d0afb830dadb1273b51389a",
72
+ "classes_digest": "ba589b760a2583fe523da87f68e84a69e3914972b2cb6417c9a44f768ba604a1",
73
+ "tests": 25,
74
+ "network": "none",
75
+ "host_mounts": []
76
+ }
77
+ },
78
+ "calculator": {
79
+ "generation_run": "run-4e2329b555864957bc5b477ae1432717",
80
+ "source_digest": "e1c26eeccec092a09b3481bc6f601f6f02b043b0e0e41219ff67a2e295b6a798",
81
+ "lease": "22cb0f942ecf446c833abff754e1a6cf",
82
+ "receipt": {
83
+ "source_digest": "e1c26eeccec092a09b3481bc6f601f6f02b043b0e0e41219ff67a2e295b6a798",
84
+ "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
85
+ "config_digest": "ec1c941302d1f0bf34512b9b524f7c8dc5bfd523f22fe50093f8cd757cdfc848",
86
+ "classes_digest": "31888e310a086e6807cc096b7bdb06164ae9a556c8f582228d9e9d7b43b0b6cf",
87
+ "tests": 39,
88
+ "network": "none",
89
+ "host_mounts": []
90
+ }
91
+ },
92
+ "pdf": {
93
+ "generation_run": "run-415025244a2a42f09cb63bc4e17902ca",
94
+ "source_digest": "9f3208baf0d4fa933050bde2753eee151517a6e197f2983a14bfdc7c92d9e79b",
95
+ "lease": "8a108743da8b4cdc8ba5bf29b4b7c749",
96
+ "receipt": {
97
+ "source_digest": "9f3208baf0d4fa933050bde2753eee151517a6e197f2983a14bfdc7c92d9e79b",
98
+ "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
99
+ "config_digest": "128defe2109c8b7693134f252f9235bc863b5915fc11d640b8bd52394e589c72",
100
+ "classes_digest": "84d779e18a69c02f3dd173aa8899c5eb2a4688958424aebdacb467c44c50e3fe",
101
+ "tests": 23,
102
+ "network": "none",
103
+ "host_mounts": []
104
+ }
105
+ }
106
+ },
107
+ "external_model_calls": 0,
108
+ "platform_code_digest": "cc0bd4d6541c7fd2c321bc1de034f9ef635384bfb24b8d0bebfc0b741573f5b2",
109
+ "scope": "Exact prior HF-generated source replay on local QEMU, not a new cloud generation",
110
+ "passed": 4
111
+ },
112
+ "main": {
113
+ "passed": 3,
114
+ "checks": [
115
+ "Original 8789 shell and three real users remain usable",
116
+ "8810 QA was separate: production workbench still uses 8789 and independent 8791 previews",
117
+ "Wizard injects full brief into original composer and discloses bounded recovery before send"
118
+ ],
119
+ "errors": [],
120
+ "model_calls_started": 0,
121
+ "platform_code_digest": "cc0bd4d6541c7fd2c321bc1de034f9ef635384bfb24b8d0bebfc0b741573f5b2"
122
+ },
123
+ "platform_code_digest": "cc0bd4d6541c7fd2c321bc1de034f9ef635384bfb24b8d0bebfc0b741573f5b2",
124
+ "unit_tests": {
125
+ "total": 241,
126
+ "passed": 239,
127
+ "skipped": 2
128
+ },
129
+ "hf_unit_tests": {
130
+ "passed": 27
131
+ },
132
+ "real_model_repair": {
133
+ "verification_run": "run-8dffb94f45144a9a919eb68fa9324c3e",
134
+ "model_generation_run": "run-38d1cd6dabbe4f57891547a0beccf54f",
135
+ "original_status": "unknown",
136
+ "original_error": "SANDBOX_TIMEOUT",
137
+ "method": "independent verification of unchanged, settled model output after local sandbox timeout; no model replay",
138
+ "source": {
139
+ "files": {
140
+ "src/main/java/demo/App.java": "package demo;\n\nimport com.sun.net.httpserver.HttpServer;\nimport com.sun.net.httpserver.HttpExchange;\nimport java.io.*;\nimport java.math.*;\nimport java.net.InetSocketAddress;\nimport java.nio.ByteBuffer;\nimport java.nio.CharBuffer;\nimport java.nio.charset.*;\nimport java.util.Base64;\nimport java.util.concurrent.Executors;\n\npublic class App {\n static final BigDecimal LIMIT = new BigDecimal(\"1e24\");\n static final MathContext MC = MathContext.DECIMAL128;\n static int ops, depth, pos; static String s;\n\n public static void main(String[] args) throws Exception {\n HttpServer svr = HttpServer.create(new InetSocketAddress(8080), 0);\n svr.setExecutor(Executors.newSingleThreadExecutor());\n svr.createContext(\"/\", App::handle);\n svr.start();\n }\n\n static void handle(HttpExchange ex) throws IOException {\n try { doHandle(ex); } finally { ex.close(); }\n }\n\n static void doHandle(HttpExchange ex) throws IOException {\n String p = ex.getRequestURI().getPath();\n if (\"/health\".equals(p)) {\n if (!\"GET\".equals(ex.getRequestMethod())) { send(ex,405,\"{\\\"error\\\":\\\"METHOD_NOT_ALLOWED\\\"}\"); return; }\n send(ex,200,\"{\\\"status\\\":\\\"ok\\\"}\"); return;\n }\n if (\"/api/calculate\".equals(p)) {\n if (!\"GET\".equals(ex.getRequestMethod())) { send(ex,405,\"{\\\"error\\\":\\\"METHOD_NOT_ALLOWED\\\"}\"); return; }\n String auth = ex.getRequestHeaders().getFirst(\"Authorization\");\n if (!\"Bearer demo-calculator\".equals(auth)) { send(ex,401,\"{\\\"error\\\":\\\"UNAUTHORIZED\\\"}\"); return; }\n calc(ex); return;\n }\n send(ex,404,\"{\\\"error\\\":\\\"NOT_FOUND\\\"}\");\n }\n\n static void calc(HttpExchange ex) throws IOException {\n String q = ex.getRequestURI().getRawQuery();\n if (q == null || q.isEmpty()) { send(ex,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n String[] parts = q.split(\"&\"); boolean found = false; String val = null;\n for (String part : parts) {\n int eq = part.indexOf('='); String k = eq<0?part:part.substring(0,eq); String v = eq<0?\"\":part.substring(eq+1);\n if (\"expression64\".equals(k)) { if (found||v.isEmpty()) { send(ex,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; } found=true; val=v; }\n else { send(ex,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n }\n if (!found) { send(ex,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n if (val.length()>256) { send(ex,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n if (!val.matches(\"[A-Za-z0-9_-]*\")) { send(ex,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n byte[] bytes; try { bytes=Base64.getUrlDecoder().decode(val); } catch(Exception e) { send(ex,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n CharsetDecoder dec = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);\n CharBuffer cb; try { cb=dec.decode(ByteBuffer.wrap(bytes)); } catch(Exception e) { send(ex,400,\"{\\\"error\\\":\\\"INVALID_INPUT\\\"}\"); return; }\n s=cb.toString();\n if (s.length()>128) { send(ex,422,\"{\\\"error\\\":\\\"LIMIT_EXCEEDED\\\"}\"); return; }\n ops=0; depth=0; pos=0;\n try {\n BigDecimal r=sum(); skip();\n if (pos<s.length()) throw new RuntimeException(\"INVALID_EXPRESSION\");\n BigDecimal f=r.setScale(12,RoundingMode.HALF_UP).stripTrailingZeros();\n String rs=f.compareTo(BigDecimal.ZERO)==0?\"0\":f.toPlainString();\n String j=\"{\\\"expression\\\":\\\"\"+esc(s)+\"\\\",\\\"result\\\":\\\"\"+rs+\"\\\"}\";\n send(ex,200,j);\n } catch(RuntimeException re) {\n String m=re.getMessage(); int c=400;\n if (\"LIMIT_EXCEEDED\".equals(m)) c=422;\n send(ex,c,\"{\\\"error\\\":\\\"\"+m+\"\\\"}\");\n }\n }\n\n static BigDecimal sum() {\n BigDecimal l=product(); skip();\n while(pos<s.length()&&(s.charAt(pos)=='+'||s.charAt(pos)=='-')) {\n char o=s.charAt(pos++); ops++; if(ops>64) throw new RuntimeException(\"LIMIT_EXCEEDED\");\n skip(); BigDecimal r=product();\n l=o=='+'?l.add(r,MC):l.subtract(r,MC); chk(l); skip();\n }\n return l;\n }\n\n static BigDecimal product() {\n BigDecimal l=unary(); skip();\n while(pos<s.length()&&(s.charAt(pos)=='*'||s.charAt(pos)=='/')) {\n char o=s.charAt(pos++); ops++; if(ops>64) throw new RuntimeException(\"LIMIT_EXCEEDED\");\n skip(); BigDecimal r=unary();\n if(o=='*') { l=l.multiply(r,MC); chk(l); } else {\n if(r.signum()==0) throw new RuntimeException(\"DIVISION_BY_ZERO\");\n l=l.divide(r,MC); chk(l);\n } skip();\n }\n return l;\n }\n\n static BigDecimal unary() {\n skip(); boolean neg=false;\n while(pos<s.length()&&(s.charAt(pos)=='+'||s.charAt(pos)=='-')) {\n if(s.charAt(pos)=='-') neg=!neg; ops++; if(ops>64) throw new RuntimeException(\"LIMIT_EXCEEDED\");\n pos++; skip();\n }\n BigDecimal r=atom(); return neg?r.negate(MC):r;\n }\n\n static BigDecimal atom() {\n skip();\n if(pos>=s.length()) throw new RuntimeException(\"INVALID_EXPRESSION\");\n char c=s.charAt(pos);\n if(c=='(') {\n depth++; if(depth>16) throw new RuntimeException(\"LIMIT_EXCEEDED\");\n pos++; skip(); BigDecimal r=sum(); skip();\n if(pos>=s.length()||s.charAt(pos)!=')') throw new RuntimeException(\"INVALID_EXPRESSION\");\n pos++; depth--; return r;\n }\n if((c>='0'&&c<='9')||c=='.') return num();\n throw new RuntimeException(\"INVALID_EXPRESSION\");\n }\n\n static BigDecimal num() {\n int st=pos, dc=0; boolean dot=false;\n while(pos<s.length()) {\n char c=s.charAt(pos);\n if(c>='0'&&c<='9') { dc++; pos++; }\n else if(c=='.'&&!dot) { dot=true; pos++; if(pos>=s.length()||s.charAt(pos)<'0'||s.charAt(pos)>'9') throw new RuntimeException(\"INVALID_EXPRESSION\"); }\n else break;\n }\n if(dc>24) throw new RuntimeException(\"LIMIT_EXCEEDED\");\n if(st==pos) throw new RuntimeException(\"INVALID_EXPRESSION\");\n BigDecimal v=new BigDecimal(s.substring(st,pos)); chk(v); return v;\n }\n\n static void skip() { while(pos<s.length()&&s.charAt(pos)==' ') pos++; }\n static void chk(BigDecimal v) { if(v.abs().compareTo(LIMIT)>0) throw new RuntimeException(\"LIMIT_EXCEEDED\"); }\n static String esc(String x) { return x.replace(\"\\\\\",\"\\\\\\\\\").replace(\"\\\"\",\"\\\\\\\"\"); }\n\n static void send(HttpExchange ex, int code, String body) throws IOException {\n byte[] b=body.getBytes(StandardCharsets.UTF_8);\n ex.getResponseHeaders().set(\"Content-Type\",\"application/json; charset=utf-8\");\n ex.sendResponseHeaders(code,b.length);\n try(OutputStream os=ex.getResponseBody()){os.write(b);}\n }\n}"
141
+ },
142
+ "source_digest": "198f9d9ba839838518e8c4843698fc4bf240db862db4aa7832327eb78e9eb2dd"
143
+ },
144
+ "candidate": {
145
+ "source_digest": "198f9d9ba839838518e8c4843698fc4bf240db862db4aa7832327eb78e9eb2dd",
146
+ "classes_digest": "22439f77fd1c0620d947e95ec701a10067557775516220bc2bf458ab9cd99218",
147
+ "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
148
+ "suite_digest": "05e353f239f8919946d419e91e63fedccbf62b02386fa12f39ad8795b6a4de4d",
149
+ "config_digest": "ec1c941302d1f0bf34512b9b524f7c8dc5bfd523f22fe50093f8cd757cdfc848",
150
+ "execution_mode": "qemu",
151
+ "container": "zk-run-8dffb94f45144a9a919eb68fa9324c3e",
152
+ "stage": "build",
153
+ "passed": true,
154
+ "receipt_ref": "run-8dffb94f45144a9a919eb68fa9324c3e-1f4b6c01e0fa4b9ebe7c1ba9849012a4",
155
+ "receipt_digest": "69236467e2d3a73bc64fefbb69e0b1fb3df6545dabb65b7b39099ef36f7ddc2d",
156
+ "isolation": {
157
+ "network": "none",
158
+ "host_mounts": [],
159
+ "memory_mb": 1024,
160
+ "vcpu": 1,
161
+ "disposable": true
162
+ }
163
+ },
164
+ "test": {
165
+ "source_digest": "198f9d9ba839838518e8c4843698fc4bf240db862db4aa7832327eb78e9eb2dd",
166
+ "classes_digest": "22439f77fd1c0620d947e95ec701a10067557775516220bc2bf458ab9cd99218",
167
+ "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
168
+ "suite_digest": "05e353f239f8919946d419e91e63fedccbf62b02386fa12f39ad8795b6a4de4d",
169
+ "config_digest": "ec1c941302d1f0bf34512b9b524f7c8dc5bfd523f22fe50093f8cd757cdfc848",
170
+ "execution_mode": "qemu",
171
+ "container": "zk-run-8dffb94f45144a9a919eb68fa9324c3e",
172
+ "stage": "test",
173
+ "passed": true,
174
+ "receipt_ref": "run-8dffb94f45144a9a919eb68fa9324c3e-1f4b6c01e0fa4b9ebe7c1ba9849012a4",
175
+ "receipt_digest": "69236467e2d3a73bc64fefbb69e0b1fb3df6545dabb65b7b39099ef36f7ddc2d",
176
+ "isolation": {
177
+ "network": "none",
178
+ "host_mounts": [],
179
+ "memory_mb": 1024,
180
+ "vcpu": 1,
181
+ "disposable": true
182
+ },
183
+ "cases": 39,
184
+ "passed_cases": 39,
185
+ "preview_scope": "disposable-vm-loopback-http"
186
+ },
187
+ "preview": {
188
+ "source_digest": "198f9d9ba839838518e8c4843698fc4bf240db862db4aa7832327eb78e9eb2dd",
189
+ "classes_digest": "22439f77fd1c0620d947e95ec701a10067557775516220bc2bf458ab9cd99218",
190
+ "image": "zkcoding-qemu@sha256:123b955068e212a3cb1cf6db348cc8efab24c44ca2b4fb67835100845a9e7ddf",
191
+ "suite_digest": "05e353f239f8919946d419e91e63fedccbf62b02386fa12f39ad8795b6a4de4d",
192
+ "config_digest": "ec1c941302d1f0bf34512b9b524f7c8dc5bfd523f22fe50093f8cd757cdfc848",
193
+ "execution_mode": "qemu",
194
+ "container": "zk-run-8dffb94f45144a9a919eb68fa9324c3e",
195
+ "stage": "preview",
196
+ "passed": true,
197
+ "receipt_ref": "run-8dffb94f45144a9a919eb68fa9324c3e-1f4b6c01e0fa4b9ebe7c1ba9849012a4",
198
+ "receipt_digest": "69236467e2d3a73bc64fefbb69e0b1fb3df6545dabb65b7b39099ef36f7ddc2d",
199
+ "isolation": {
200
+ "network": "none",
201
+ "host_mounts": [],
202
+ "memory_mb": 1024,
203
+ "vcpu": 1,
204
+ "disposable": true
205
+ },
206
+ "cases": 1,
207
+ "passed_cases": 1,
208
+ "preview_scope": "disposable-vm-loopback-http"
209
+ },
210
+ "model_calls": [
211
+ {
212
+ "id": 1,
213
+ "run_id": "run-38d1cd6dabbe4f57891547a0beccf54f",
214
+ "reservation": 18896,
215
+ "charged": 5170,
216
+ "state": "settled",
217
+ "provider": "bailian-qwen3.8-flash",
218
+ "prompt_digest": "a47fc206373edcb787938993078dd4a54e94d5ec3103de599ea9ddfe1266637e",
219
+ "metadata": {
220
+ "finish_reason": "stop",
221
+ "model": "qwen3.8-flash",
222
+ "policy_version": "bailian-task-routing-v2",
223
+ "request_id": "chatcmpl-169d689f-a21e-9223-a60e-09775bd4a25b",
224
+ "requested_output_tokens": 2048,
225
+ "retry_of": null,
226
+ "route_reason": "technical-design",
227
+ "stage": "design"
228
+ }
229
+ },
230
+ {
231
+ "id": 2,
232
+ "run_id": "run-38d1cd6dabbe4f57891547a0beccf54f",
233
+ "reservation": 30901,
234
+ "charged": 6951,
235
+ "state": "settled",
236
+ "provider": "bailian-qwen3.8-max",
237
+ "prompt_digest": "c075a52c3e5d6dabb319198b6bd85ba64a614dcf256b21e88278d0e328560fd8",
238
+ "metadata": {
239
+ "finish_reason": "stop",
240
+ "model": "qwen3.8-max",
241
+ "policy_version": "bailian-task-routing-v2",
242
+ "request_id": "chatcmpl-9cf1ec43-6da2-9acb-9b1c-9246e9c7210a",
243
+ "requested_output_tokens": 12288,
244
+ "retry_of": null,
245
+ "route_reason": "diagnostic-repair",
246
+ "stage": "code"
247
+ }
248
+ }
249
+ ],
250
+ "new_model_calls": 0,
251
+ "human_acceptance": false
252
+ },
253
+ "tested_at_utc": "2026-10-24T05:16:14.381187+00:00",
254
+ "cloud_recovery_release_verified": false,
255
+ "human_acceptance": false
256
+ }
sites/zkcoding-workbench/dist/app.js CHANGED
@@ -79,7 +79,11 @@ function renderContext() {
79
  $('matterTitle').textContent = chat()?.title || '新对话';
80
  $('welcomeDescription').textContent = p ? `在「${p.name}」中开始。` : '一个想法,一段对话。';
81
  $('modelLabel').textContent = MODELS.find(m => m.id === prefs.model)?.name || '自动选择模型';
82
- $('skillLabel').textContent = prefs.skill ? `Skill · ${runtime.skillOptions().find(s => s.id === prefs.skill)?.name || 'Java ERP'}` : 'Skill';
 
 
 
 
83
  $('chooseSkills').classList.toggle('selected-choice', prefs.skill);
84
  $('knowledgeLabel').textContent = prefs.bases.length ? `知识库 · ${prefs.bases.length}` : '知识库';
85
  $('chooseBases').classList.toggle('selected-choice', !!prefs.bases.length);
@@ -88,9 +92,11 @@ function renderContext() {
88
  }
89
  function renderMessages() {
90
  const c = chat();
 
 
91
  const openDetails=[...document.querySelectorAll('.development-result details[open][data-detail]')].map(el=>[el.closest('.development-result').dataset.runId,el.dataset.detail]);
92
  $('welcome').hidden = !!c?.messages.length;
93
- $('messages').innerHTML = (c?.messages || []).map((m, i) => `<article class="message ${m.role === 'user' ? 'user' : 'assistant'}">${m.role === 'assistant' ? '<div class="message-head"><span class="assistant-mark">&lt;/&gt;</span>Vibe Coding</div>' : ''}${m.attachments?.length ? `<div class="message-attachments">${m.attachments.map(f => `<span>${esc(f.name)}${f.type === 'directory' ? '/' : ''}</span>`).join('')}</div>` : ''}<div class="message-body">${m.business ? runtime.renderBusinessMessage(m.business,i,m.actionState,m.resetState) : m.job ? runtime.renderJobMessage(m.job,i,m.jobError) : esc(m.content)}</div>${m.role === 'assistant' ? `<div class="message-meta">${m.preview ? '<span>前端交互示例</span>' : ''}<button class="icon-button message-copy" data-copy-message="${i}" aria-label="复制回复" title="复制回复">${icon('copy')}</button></div>` : ''}</article>`).join('') + (pending && c && pending.chatId === c.id ? '<div class="loading-reply" aria-label="等待真实运行结果"><i></i><i></i><i></i></div>' : '');
94
  for(const [runId,key] of openDetails){const section=[...document.querySelectorAll('.development-result')].find(el=>el.dataset.runId===runId);const detail=section?.querySelector(`details[data-detail="${key}"]`);if(detail)detail.open=true;}
95
  document.querySelectorAll('[data-job-followup],[data-job-repair],[data-job-refresh],.development-result button[data-runtime]').forEach(button=>{button.disabled=!!switchingUser;});
96
  document.querySelectorAll('.development-result a').forEach(link=>{link.inert=!!switchingUser;});
@@ -440,6 +446,16 @@ async function monitorJavaJob(c,response,job,active) {
440
  response.jobObservedAt=Date.now();job.observed_at=response.jobObservedAt;
441
  response.job=job;response.jobError='';response.content=runtime.jobText(job);saveRequestResult(c,active);
442
  if(!['queued','working'].includes(job.status)){
 
 
 
 
 
 
 
 
 
 
443
  if(job.status==='verified'&&!job.project){try{job.project=await runtime.api(`/api/jobs/${encodeURIComponent(job.id)}/project`,{});saveRequestResult(c,active);}catch(error){response.jobError='工程保存未完成:'+error.message;saveRequestResult(c,active);}}
444
  break;
445
  }
@@ -538,7 +554,7 @@ async function send(event) {
538
  const programming=option&&!business;
539
  const bound = selectedProject()?.serverId;
540
  if(programming && selectedProject() && !bound){toast('此项目只有浏览器目录引用。Java 编程请先选择已接入后端的 ERP、WMS 或设备项目。');return;}
541
- if(programming && bound && bound !== runtime.scenarios.find(s => s.id === option.scenario)?.project_id){toast('所选 Java 技能与项目不一致,请选择对应项目。');return;}
542
  if(!option && !business && prefs.bases.length){toast('请选择对应业务助手,或选择 Java Skill 使用编码资料。');return;}
543
  let c = chat();
544
  if (!c) {
@@ -554,7 +570,7 @@ async function send(event) {
554
  const result=await runtime.api('/api/business/ask',{scenario:business.scenario,question:content});
555
  response.content=runtime.businessText(result);response.business={...result,scenario:business.scenario};
556
  } else if(programming) {
557
- const job=await runtime.api('/api/jobs',{scenario:option.scenario,requirement:content,request_key:active.key,...(option.id.startsWith('java-')?{skill_id:option.id}:{})});
558
  await monitorJavaJob(c,response,job,active);
559
  } else {
560
  let result=await runtime.api('/api/chat',{conversation:c.id,prompt:content,request_key:active.key,project:bound||null});
 
79
  $('matterTitle').textContent = chat()?.title || '新对话';
80
  $('welcomeDescription').textContent = p ? `在「${p.name}」中开始。` : '一个想法,一段对话。';
81
  $('modelLabel').textContent = MODELS.find(m => m.id === prefs.model)?.name || '自动选择模型';
82
+ $('skillLabel').textContent = prefs.skill ? `Skill · ${runtime.skillOptions().find(s => s.id === prefs.skill)?.name || 'Java ERP'}` : 'Skill';
83
+ const coding=prefs.skill&&runtime.skillOptions().find(s=>s.id===prefs.skill)?.kind!=='business'&&runtime.session?.capabilities?.automatic_recovery;
84
+ const note=document.querySelector('.compose-note');
85
+ note.innerHTML=coding?'Enter 发送<span>·</span>自动诊断修复,必要时续修1轮<span>·</span>Shift + Enter 换行':'Enter 发送<span>·</span>Shift + Enter 换行<span>·</span>对话与项目保存在此浏览器';
86
+ note.title=coding?'每任务最多6次调用、120000 Token、2次诊断修复;额外自动续修最多1轮。两轮合计最多12次调用、240000 Token,仍受服务端配额限制。':'';
87
  $('chooseSkills').classList.toggle('selected-choice', prefs.skill);
88
  $('knowledgeLabel').textContent = prefs.bases.length ? `知识库 · ${prefs.bases.length}` : '知识库';
89
  $('chooseBases').classList.toggle('selected-choice', !!prefs.bases.length);
 
92
  }
93
  function renderMessages() {
94
  const c = chat();
95
+ if(pending&&!pending.startedAt)pending.startedAt=Date.now();
96
+ const waitingMessage=pending&&c?.messages.findLast(m=>m.job?.id===pending.runId);
97
  const openDetails=[...document.querySelectorAll('.development-result details[open][data-detail]')].map(el=>[el.closest('.development-result').dataset.runId,el.dataset.detail]);
98
  $('welcome').hidden = !!c?.messages.length;
99
+ $('messages').innerHTML = (c?.messages || []).map((m, i) => `<article class="message ${m.role === 'user' ? 'user' : 'assistant'}">${m.role === 'assistant' ? '<div class="message-head"><span class="assistant-mark">&lt;/&gt;</span>Vibe Coding</div>' : ''}${m.attachments?.length ? `<div class="message-attachments">${m.attachments.map(f => `<span>${esc(f.name)}${f.type === 'directory' ? '/' : ''}</span>`).join('')}</div>` : ''}<div class="message-body">${m.business ? runtime.renderBusinessMessage(m.business,i,m.actionState,m.resetState) : m.job ? runtime.renderJobMessage(m.job,i,m.jobError) : esc(m.content)}</div>${m.role === 'assistant' ? `<div class="message-meta">${m.preview ? '<span>前端交互示例</span>' : ''}<button class="icon-button message-copy" data-copy-message="${i}" aria-label="复制回复" title="复制回复">${icon('copy')}</button></div>` : ''}</article>`).join('') + (pending && c && pending.chatId === c.id ? runtime.renderPendingMessage(waitingMessage?.job,pending,waitingMessage?.jobError) : '');
100
  for(const [runId,key] of openDetails){const section=[...document.querySelectorAll('.development-result')].find(el=>el.dataset.runId===runId);const detail=section?.querySelector(`details[data-detail="${key}"]`);if(detail)detail.open=true;}
101
  document.querySelectorAll('[data-job-followup],[data-job-repair],[data-job-refresh],.development-result button[data-runtime]').forEach(button=>{button.disabled=!!switchingUser;});
102
  document.querySelectorAll('.development-result a').forEach(link=>{link.inert=!!switchingUser;});
 
446
  response.jobObservedAt=Date.now();job.observed_at=response.jobObservedAt;
447
  response.job=job;response.jobError='';response.content=runtime.jobText(job);saveRequestResult(c,active);
448
  if(!['queued','working'].includes(job.status)){
449
+ if(job.status==='failed'&&job.auto_recovery&&!job.auto_recovery.attempt&&!job.auto_recovery.error&&!job.auto_recovery.next_run_id){
450
+ await new Promise(resolve=>setTimeout(resolve,2000));
451
+ job=await runtime.api(`/api/jobs/${encodeURIComponent(job.id)}`);response.job=job;
452
+ }
453
+ if(job.auto_recovery?.next_run_id&&!active.stopped&&pending===active){
454
+ job=await runtime.api(`/api/jobs/${encodeURIComponent(job.auto_recovery.next_run_id)}`);
455
+ response=c.messages.find(m=>m.job?.id===job.id)||{role:'assistant',content:'正在自动恢复,保留原任务和诊断。',job};
456
+ if(!c.messages.includes(response))c.messages.push(response);
457
+ active.runId=job.id;c.runId=job.id;continue;
458
+ }
459
  if(job.status==='verified'&&!job.project){try{job.project=await runtime.api(`/api/jobs/${encodeURIComponent(job.id)}/project`,{});saveRequestResult(c,active);}catch(error){response.jobError='工程保存未完成:'+error.message;saveRequestResult(c,active);}}
460
  break;
461
  }
 
554
  const programming=option&&!business;
555
  const bound = selectedProject()?.serverId;
556
  if(programming && selectedProject() && !bound){toast('此项目只有浏览器目录引用。Java 编程请先选择已接入后端的 ERP、WMS 或设备项目。');return;}
557
+ if(programming && bound && bound !== runtime.scenarios.find(s => s.id === option.scenario)?.project_id){toast('所选 Java 技能与项目不一致,请选择对应项目。');return;}
558
  if(!option && !business && prefs.bases.length){toast('请选择对应业务助手,或选择 Java Skill 使用编码资料。');return;}
559
  let c = chat();
560
  if (!c) {
 
570
  const result=await runtime.api('/api/business/ask',{scenario:business.scenario,question:content});
571
  response.content=runtime.businessText(result);response.business={...result,scenario:business.scenario};
572
  } else if(programming) {
573
+ const job=await runtime.api('/api/jobs',{scenario:option.scenario,requirement:content,request_key:active.key,...(runtime.session?.capabilities?.automatic_recovery?{auto_recover:true}:{}),...(option.id.startsWith('java-')?{skill_id:option.id}:{})});
574
  await monitorJavaJob(c,response,job,active);
575
  } else {
576
  let result=await runtime.api('/api/chat',{conversation:c.id,prompt:content,request_key:active.key,project:bound||null});
sites/zkcoding-workbench/dist/runtime.css CHANGED
@@ -91,3 +91,5 @@
91
  .execution-pulse{width:8px;height:8px;background:#4b7fb6;border-radius:50%;animation:execution-pulse 1.8s ease-in-out infinite}
92
  @keyframes execution-pulse{50%{opacity:.35}}
93
  @media(prefers-reduced-motion:reduce){.execution-pulse{animation:none}}
 
 
 
91
  .execution-pulse{width:8px;height:8px;background:#4b7fb6;border-radius:50%;animation:execution-pulse 1.8s ease-in-out infinite}
92
  @keyframes execution-pulse{50%{opacity:.35}}
93
  @media(prefers-reduced-motion:reduce){.execution-pulse{animation:none}}
94
+
95
+ .waiting-feedback{display:flex;flex-direction:column;align-items:flex-start;gap:5px;padding:10px 0;line-height:1.7;overflow-wrap:anywhere}.waiting-feedback strong{font-size:12px;color:#526d91}.waiting-feedback small{font-size:11px;color:#7c899c}.waiting-feedback [data-pending-delay]:empty{display:none}
sites/zkcoding-workbench/dist/runtime.js CHANGED
@@ -96,8 +96,20 @@ function eventTime(value) {
96
  function diagnosticText(value) {
97
  return typeof value==='string'?value:JSON.stringify(value,null,2);
98
  }
99
- const duration=seconds=>{const n=Math.max(0,Math.floor(Number(seconds)||0));return n<60?`${n} 秒`:`${Math.floor(n/60)} 分 ${n%60} 秒`;};
100
- export function tickJobClocks() {
 
 
 
 
 
 
 
 
 
 
 
 
101
  for(const card of document.querySelectorAll('[data-job-clock]')){
102
  const active=card.dataset.active==='true',delta=active?Math.max(0,(Date.now()-Number(card.dataset.observed))/1000):0;
103
  card.querySelector('[data-total-time]').textContent=duration(Number(card.dataset.elapsed)+delta);
@@ -109,7 +121,7 @@ export function tickJobClocks() {
109
  }
110
  function progressCard(job,error){
111
  const p=job.progress||{},active=['queued','working'].includes(job.status),verified=job.status==='verified';
112
- const headline=p.headline||(verified?'开发完成 · 技术通过':active?'正在执行,尚未结束':statusText(job.status));
113
  const project=job.project;
114
  return `<article class="execution-card" data-state="${esc(job.status)}" data-job-clock data-active="${active}" data-observed="${esc(job.observed_at||Date.now())}" data-elapsed="${esc(p.elapsed_seconds||0)}" data-stage-elapsed="${esc(p.stage_elapsed_seconds||0)}" role="status" aria-live="polite">
115
  <strong class="execution-headline">${active?'<span class="execution-pulse" aria-hidden="true"></span>':''}${esc(headline)}</strong>
@@ -129,7 +141,8 @@ export function renderJobMessage(job,index,error='') {
129
  const complete=job.status==='verified';
130
  const attrs=`data-kind="run" data-ref="${esc(job.id)}"`;
131
  return `<section class="development-result" data-run-id="${esc(job.id)}" aria-label="Java 开发进度">
132
- <div class="development-heading"><strong>${esc(scenarios.find(s=>s.id===job.scenario)?.name||job.scenario)} · Java 开发</strong><span class="development-status">${esc(statusText(job.status))}</span></div>
 
133
  <p class="development-meta">任务 ${esc(job.id)} · 模型调用 ${esc(job.model_calls?.length??0)} 次 · 模型修复 ${esc(job.repairs??0)} 次</p>
134
  ${job.model_calls?.length?`<details class="development-diagnostics" data-detail="models"><summary>本任务实际模型与用量</summary><ul>${job.model_calls.map(call=>`<li>${esc(call.metadata?.stage||'历史阶段')} · ${esc(call.metadata?.model||call.provider)} · ${esc(call.state)} · ${call.charged===null?'用量待核对':esc(call.charged)+' Token'}${call.metadata?.requested_output_tokens?` · 输出上限 ${esc(call.metadata.requested_output_tokens)}`:''}${call.metadata?.error?` · ${esc(call.metadata.error)}`:''}</li>`).join('')}</ul></details>`:''}
135
  ${job.evidence?.manifest?.repair_origin?`<p class="development-meta">本制品由 Codex 接管修复后独立验证。原模型任务 ${esc(job.evidence.manifest.repair_origin.generation_run)} 保留原结果。</p>`:''}
 
96
  function diagnosticText(value) {
97
  return typeof value==='string'?value:JSON.stringify(value,null,2);
98
  }
99
+ const duration=seconds=>{const n=Math.max(0,Math.floor(Number(seconds)||0));return n<60?`${n} 秒`:`${Math.floor(n/60)} 分 ${n%60} 秒`;};
100
+ export function renderPendingMessage(job,active,error='') {
101
+ const p=job?.progress||{},observed=job?.observed_at||active.startedAt;
102
+ const title=error?'状态读取中断,正在重连':p.headline||(active.kind==='java'?'正在提交开发任务':active.kind==='business-action'?'正在登记并回读':'正在等待服务端响应');
103
+ return `<div class="loading-reply waiting-feedback" role="status" data-pending-clock data-started="${esc(active.startedAt)}" data-observed="${esc(observed)}" data-elapsed="${esc(p.elapsed_seconds||0)}" data-stage-elapsed="${esc(p.stage_elapsed_seconds||0)}" data-job="${!!job}" data-queued="${job?.status==='queued'}"><strong>${esc(title)}</strong><span data-pending-time aria-live="off"></span><span>${esc(error||p.detail||'请求已提交,等待真实结果;请勿重复发送。')}</span><small data-pending-freshness aria-live="off"></small><small data-pending-delay></small></div>`;
104
+ }
105
+ export function tickJobClocks() {
106
+ for(const line of document.querySelectorAll('[data-pending-clock]')){
107
+ const delta=Math.max(0,(Date.now()-Number(line.dataset.observed))/1000),hasJob=line.dataset.job==='true';
108
+ const elapsed=hasJob?Number(line.dataset.elapsed)+delta:(Date.now()-Number(line.dataset.started))/1000;
109
+ line.querySelector('[data-pending-time]').textContent=`已等待 ${duration(elapsed)}`;
110
+ line.querySelector('[data-pending-freshness]').textContent=hasJob?`最近读取:${duration(delta)}前 · 自动核对同一任务,不会重复提交`:'正在等待服务端首次回执;尚不能确认执行结果';
111
+ line.querySelector('[data-pending-delay]').textContent=delta>12&&hasJob?'状态连接暂未更新,正在重连;这不代表任务已失败。':Number(line.dataset.stageElapsed)+delta>=60?(line.dataset.queued==='true'?'仍在排队等待执行器,本任务尚未开始编译。':'当前步骤等待较久,尚未收到完成结果;可展开上方执行记录查看最近心跳。'):'';
112
+ }
113
  for(const card of document.querySelectorAll('[data-job-clock]')){
114
  const active=card.dataset.active==='true',delta=active?Math.max(0,(Date.now()-Number(card.dataset.observed))/1000):0;
115
  card.querySelector('[data-total-time]').textContent=duration(Number(card.dataset.elapsed)+delta);
 
121
  }
122
  function progressCard(job,error){
123
  const p=job.progress||{},active=['queued','working'].includes(job.status),verified=job.status==='verified';
124
+ const headline=job.auto_recovery?.next_run_id?'当前候选未通过,已自动转入恢复任务':p.headline||(verified?'开发完成 · 技术通过':active?'正在执行,尚未结束':statusText(job.status));
125
  const project=job.project;
126
  return `<article class="execution-card" data-state="${esc(job.status)}" data-job-clock data-active="${active}" data-observed="${esc(job.observed_at||Date.now())}" data-elapsed="${esc(p.elapsed_seconds||0)}" data-stage-elapsed="${esc(p.stage_elapsed_seconds||0)}" role="status" aria-live="polite">
127
  <strong class="execution-headline">${active?'<span class="execution-pulse" aria-hidden="true"></span>':''}${esc(headline)}</strong>
 
141
  const complete=job.status==='verified';
142
  const attrs=`data-kind="run" data-ref="${esc(job.id)}"`;
143
  return `<section class="development-result" data-run-id="${esc(job.id)}" aria-label="Java 开发进度">
144
+ <div class="development-heading"><strong>${esc(scenarios.find(s=>s.id===job.scenario)?.name||job.scenario)} · Java 开发</strong><span class="development-status">${job.auto_recovery?.next_run_id?'本轮失败 · 已自动转入恢复任务':esc(statusText(job.status))}</span></div>
145
+ ${job.auto_recovery?`<p class="development-meta">自动恢复已开启 · 本任务最多2次诊断修复,必要时额外续修1轮;原失败和费用保留,未知结果不重放。${job.auto_recovery.error?'恢复未能安排:'+esc(job.auto_recovery.error):job.auto_recovery.attempt?' 当前为最后一轮自动续修。':''}</p>`:''}
146
  <p class="development-meta">任务 ${esc(job.id)} · 模型调用 ${esc(job.model_calls?.length??0)} 次 · 模型修复 ${esc(job.repairs??0)} 次</p>
147
  ${job.model_calls?.length?`<details class="development-diagnostics" data-detail="models"><summary>本任务实际模型与用量</summary><ul>${job.model_calls.map(call=>`<li>${esc(call.metadata?.stage||'历史阶段')} · ${esc(call.metadata?.model||call.provider)} · ${esc(call.state)} · ${call.charged===null?'用量待核对':esc(call.charged)+' Token'}${call.metadata?.requested_output_tokens?` · 输出上限 ${esc(call.metadata.requested_output_tokens)}`:''}${call.metadata?.error?` · ${esc(call.metadata.error)}`:''}</li>`).join('')}</ul></details>`:''}
148
  ${job.evidence?.manifest?.repair_origin?`<p class="development-meta">本制品由 Codex 接管修复后独立验证。原模型任务 ${esc(job.evidence.manifest.repair_origin.generation_run)} 保留原结果。</p>`:''}
src/adapters/sandbox/preview.py CHANGED
@@ -122,6 +122,9 @@ class PreviewSession:
122
  threading.Thread(target=read,daemon=True).start()
123
  prefix,ready=self.messages.get(timeout=210 if self.sandbox.config.dependency_profile=='pdfbox-3.0.8' else 150)
124
  if prefix!='ZKCODING_VM_READY=' or not all(ready.get(k,{}).get('passed') for k in ('build','test','preview')):
 
 
 
125
  raise SkillError('PREVIEW_VALIDATION_FAILED','新预览未通过独立检查。')
126
  if len({ready[k]['classes_digest'] for k in ('build','test','preview')})!=1:
127
  raise SkillError('EVIDENCE_BINDING_MISMATCH','预览产物不一致。')
 
122
  threading.Thread(target=read,daemon=True).start()
123
  prefix,ready=self.messages.get(timeout=210 if self.sandbox.config.dependency_profile=='pdfbox-3.0.8' else 150)
124
  if prefix!='ZKCODING_VM_READY=' or not all(ready.get(k,{}).get('passed') for k in ('build','test','preview')):
125
+ # Keep the actual failed receipt for authenticated diagnosis.
126
+ # A generic failure code alone is insufficient for recovery.
127
+ self.diagnostics=json.loads(json.dumps(ready))
128
  raise SkillError('PREVIEW_VALIDATION_FAILED','新预览未通过独立检查。')
129
  if len({ready[k]['classes_digest'] for k in ('build','test','preview')})!=1:
130
  raise SkillError('EVIDENCE_BINDING_MISMATCH','预览产物不一致。')
src/apps/workbench/agent_sandboxes.py CHANGED
@@ -24,6 +24,7 @@ class AgentSandboxPool:
24
  session=unit['session']
25
  return dict(id=session.id,agent_id='agent-'+session.id,scenario=unit['scenario'],kind=unit['kind'],reference=unit['reference'],
26
  status=session.status,error=session.error,expires_at=session.expires,receipt=session.receipt,
 
27
  backend=getattr(session,'execution_mode','qemu'),progress=session.progress(),
28
  url=getattr(self.engine,'preview_origin','')+'/preview-site/?lease='+session.id if session.status=='ready' else None)
29
 
 
24
  session=unit['session']
25
  return dict(id=session.id,agent_id='agent-'+session.id,scenario=unit['scenario'],kind=unit['kind'],reference=unit['reference'],
26
  status=session.status,error=session.error,expires_at=session.expires,receipt=session.receipt,
27
+ diagnostics=getattr(session,'diagnostics',None),
28
  backend=getattr(session,'execution_mode','qemu'),progress=session.progress(),
29
  url=getattr(self.engine,'preview_origin','')+'/preview-site/?lease='+session.id if session.status=='ready' else None)
30
 
src/apps/workbench/development.py CHANGED
@@ -9,6 +9,7 @@ TITLES={'start':'接收开发需求','requirements':'整理需求与验收目标
9
  'preview':'核验Java服务运行回执','acceptance':'技术交付,等待用户验收','evidence':'保存制品证据','end':'完成交付',
10
  'review':'独立续作与修复来源','repair':'模型依据失败诊断修复','execution':'执行状态',
11
  'routing':'按任务选择模型','model_recovery':'恢复已知输出问题'}
 
12
 
13
 
14
  def progress(run, state, events, now):
 
9
  'preview':'核验Java服务运行回执','acceptance':'技术交付,等待用户验收','evidence':'保存制品证据','end':'完成交付',
10
  'review':'独立续作与修复来源','repair':'模型依据失败诊断修复','execution':'执行状态',
11
  'routing':'按任务选择模型','model_recovery':'恢复已知输出问题'}
12
+ TITLES['recovery']='自动恢复任务'
13
 
14
 
15
  def progress(run, state, events, now):
src/apps/workbench/engine.py CHANGED
@@ -22,7 +22,7 @@ from src.modules.knowledge.application.catalog import KnowledgeCatalog
22
  from src.modules.knowledge.erp_assistant import ERPAssistant
23
  from src.modules.harness.policy import Harness
24
  from src.modules.llm_gateway.service import LLMGateway
25
- from src.modules.orchestrator.service import AgentRuntime
26
  from src.modules.artifact_catalog.service import ArtifactCatalog
27
  from src.modules.governance.local_validation import LocalValidation
28
  from src.apps.workbench.conversation import Conversations
@@ -122,6 +122,7 @@ class LocalWorkbench:
122
  CREATE TABLE IF NOT EXISTS web_jobs(id TEXT PRIMARY KEY,owner TEXT,scenario TEXT,request_key TEXT,request_digest TEXT,state TEXT,evidence TEXT,error TEXT,UNIQUE(owner,request_key));
123
  CREATE TABLE IF NOT EXISTS web_examples(scenario TEXT PRIMARY KEY,run_id TEXT,evidence TEXT);
124
  CREATE TABLE IF NOT EXISTS web_job_links(previous_run TEXT NOT NULL,new_run TEXT PRIMARY KEY,owner TEXT NOT NULL);
 
125
  ''')
126
  if recover_incomplete:
127
  db.execute("UPDATE web_jobs SET state='unknown',error='SERVER_RESTART_RESULT_UNKNOWN' WHERE state IN ('queued','working')")
@@ -131,7 +132,7 @@ class LocalWorkbench:
131
  self.identity.project_access(actor,SCENARIOS[scenario]['project'])
132
  return SCENARIOS[scenario]
133
 
134
- def submit(self,actor,scenario,requirement,key,skill_id=None,*,recovery_of=None):
135
  spec=self.spec(actor,scenario)
136
  baseline=None;recovery_diagnostics=None
137
  if recovery_of and skill_id:raise SkillError('RECOVERY_SOURCE_CONFLICT','修复任务只能选择一个明确源码基线。',409)
@@ -151,7 +152,7 @@ class LocalWorkbench:
151
  baseline=skill['evidence']['manifest']['source']
152
  self.runtimes[scenario].harness.files({'files':baseline['files']},skill['evidence']['manifest']['snapshot']['framework'])
153
  if not isinstance(key,str) or not 8<=len(key)<=128: raise SkillError('INVALID_IDEMPOTENCY_KEY','需要有效请求键。')
154
- fingerprint=digest({'scenario':scenario,'requirement':requirement,'skill_id':skill_id,**({'recovery_of':recovery_of} if recovery_of else {})})
155
  with self.lock:
156
  with self.store.connect() as db:
157
  old=db.execute('SELECT * FROM web_jobs WHERE owner=? AND request_key=?',(actor.user_id,key)).fetchone()
@@ -166,14 +167,46 @@ class LocalWorkbench:
166
  release=self.skills.stage_local_validation(self.author,spec['skill'],auth,validation_owner=actor.user_id)
167
  run=runtime.create(actor,dict(release_ref=release['key'],project_id=spec['project'],source_digest=baseline['source_digest'] if baseline else digest({}),
168
  baseline=baseline,generated_skill_id=skill_id,
 
169
  requirement=requirement,**({'recovery_of':recovery_of} if recovery_of else {}),
170
  **({'recovery_diagnostics':recovery_diagnostics,'baseline_origin':'unverified-failed-candidate'} if recovery_diagnostics else {}),
171
  query={'erp':'purchase order BigDecimal','wms':'stock idempotency','equipment':'maintenance state machine','calculator':'BigDecimal expression parser','pdf':'PDFBox text extraction'}[scenario]),key)
172
  with self.store.connect() as db:
173
  db.execute('INSERT INTO web_jobs VALUES(?,?,?,?,?,?,?,?)',(run['id'],actor.user_id,scenario,key,fingerprint,'queued',None,None))
174
  if recovery_of:db.execute('INSERT INTO web_job_links VALUES(?,?,?)',(recovery_of,run['id'],actor.user_id))
 
175
  self.queue.put_nowait(run['id'])
176
- return self.job(actor,run['id'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
  def worker(self):
179
  while not self.stopped.is_set():
@@ -210,9 +243,10 @@ class LocalWorkbench:
210
  with self.store.connect() as db: db.execute("UPDATE web_jobs SET state='verified',evidence=? WHERE id=?",(canonical(evidence),run_id))
211
  if actor.user_id=='local-example-builder': self.save_example(row['scenario'],run_id,evidence)
212
  return
213
- if run['status'] in {'failed','unknown','cancelled','succeeded'}:
214
- with self.store.connect() as db: db.execute('UPDATE web_jobs SET state=?,error=? WHERE id=?',(run['status'],run['error'],run_id))
215
- return
 
216
  LocalValidation(runtime,actor,'local-web-delegation-v1:'+actor.user_id).step(run_id)
217
  raise SkillError('WORKER_STEP_LIMIT','任务推进步数超限。')
218
  except Exception as exc:
@@ -231,6 +265,9 @@ class LocalWorkbench:
231
  events=self.store.stages(run_id)
232
  design=next((v['design'].get('summary','') for v in run.get('outputs',{}).values() if isinstance(v,dict) and isinstance(v.get('design'),dict)), '')
233
  from src.apps.workbench.project_files import project_info
 
 
 
234
  return dict(id=run_id,scenario=row['scenario'],requirement=run['request']['requirement'],status=row['state'],runtime_status=run['status'],
235
  error=row['error'] or run['error'],cursor=run['cursor'],stages=run['release']['execution_order'],repairs=run['repairs'],
236
  model_calls=self.store.calls(run_id),created_at=run['created_at'],source=source,
@@ -238,7 +275,7 @@ class LocalWorkbench:
238
  timeline=timeline(self.store,run,events),progress=progress(run,row['state'],events,time.time()),
239
  design_summary=design,project=project_info(self,actor,run_id),
240
  artifacts_available=bool(source),human_acceptance=False,
241
- recovery_of=run['request'].get('recovery_of'),followups=followups)
242
 
243
  def jobs(self,actor):
244
  with self.store.connect() as db: ids=[r['id'] for r in db.execute('SELECT id FROM web_jobs ORDER BY rowid DESC LIMIT 100')]
 
22
  from src.modules.knowledge.erp_assistant import ERPAssistant
23
  from src.modules.harness.policy import Harness
24
  from src.modules.llm_gateway.service import LLMGateway
25
+ from src.modules.orchestrator.service import AgentRuntime, REPAIRABLE
26
  from src.modules.artifact_catalog.service import ArtifactCatalog
27
  from src.modules.governance.local_validation import LocalValidation
28
  from src.apps.workbench.conversation import Conversations
 
122
  CREATE TABLE IF NOT EXISTS web_jobs(id TEXT PRIMARY KEY,owner TEXT,scenario TEXT,request_key TEXT,request_digest TEXT,state TEXT,evidence TEXT,error TEXT,UNIQUE(owner,request_key));
123
  CREATE TABLE IF NOT EXISTS web_examples(scenario TEXT PRIMARY KEY,run_id TEXT,evidence TEXT);
124
  CREATE TABLE IF NOT EXISTS web_job_links(previous_run TEXT NOT NULL,new_run TEXT PRIMARY KEY,owner TEXT NOT NULL);
125
+ CREATE TABLE IF NOT EXISTS web_job_recovery(run_id TEXT PRIMARY KEY,root_run TEXT NOT NULL,attempt INTEGER NOT NULL,error TEXT);
126
  ''')
127
  if recover_incomplete:
128
  db.execute("UPDATE web_jobs SET state='unknown',error='SERVER_RESTART_RESULT_UNKNOWN' WHERE state IN ('queued','working')")
 
132
  self.identity.project_access(actor,SCENARIOS[scenario]['project'])
133
  return SCENARIOS[scenario]
134
 
135
+ def submit(self,actor,scenario,requirement,key,skill_id=None,*,recovery_of=None,auto_recover=False):
136
  spec=self.spec(actor,scenario)
137
  baseline=None;recovery_diagnostics=None
138
  if recovery_of and skill_id:raise SkillError('RECOVERY_SOURCE_CONFLICT','修复任务只能选择一个明确源码基线。',409)
 
152
  baseline=skill['evidence']['manifest']['source']
153
  self.runtimes[scenario].harness.files({'files':baseline['files']},skill['evidence']['manifest']['snapshot']['framework'])
154
  if not isinstance(key,str) or not 8<=len(key)<=128: raise SkillError('INVALID_IDEMPOTENCY_KEY','需要有效请求键。')
155
+ fingerprint=digest({'scenario':scenario,'requirement':requirement,'skill_id':skill_id,**({'recovery_of':recovery_of} if recovery_of else {}),**({'auto_recover':True} if auto_recover else {})})
156
  with self.lock:
157
  with self.store.connect() as db:
158
  old=db.execute('SELECT * FROM web_jobs WHERE owner=? AND request_key=?',(actor.user_id,key)).fetchone()
 
167
  release=self.skills.stage_local_validation(self.author,spec['skill'],auth,validation_owner=actor.user_id)
168
  run=runtime.create(actor,dict(release_ref=release['key'],project_id=spec['project'],source_digest=baseline['source_digest'] if baseline else digest({}),
169
  baseline=baseline,generated_skill_id=skill_id,
170
+ **({'recovery_policy':{'version':'bounded-continuation-v1','max_continuations':1,'authorization':'explicit-request-auto_recover'}} if auto_recover else {}),
171
  requirement=requirement,**({'recovery_of':recovery_of} if recovery_of else {}),
172
  **({'recovery_diagnostics':recovery_diagnostics,'baseline_origin':'unverified-failed-candidate'} if recovery_diagnostics else {}),
173
  query={'erp':'purchase order BigDecimal','wms':'stock idempotency','equipment':'maintenance state machine','calculator':'BigDecimal expression parser','pdf':'PDFBox text extraction'}[scenario]),key)
174
  with self.store.connect() as db:
175
  db.execute('INSERT INTO web_jobs VALUES(?,?,?,?,?,?,?,?)',(run['id'],actor.user_id,scenario,key,fingerprint,'queued',None,None))
176
  if recovery_of:db.execute('INSERT INTO web_job_links VALUES(?,?,?)',(recovery_of,run['id'],actor.user_id))
177
+ if auto_recover:db.execute('INSERT INTO web_job_recovery VALUES(?,?,0,NULL)',(run['id'],run['id']))
178
  self.queue.put_nowait(run['id'])
179
+ return self.job(actor,run['id'])
180
+
181
+ def auto_recover(self,actor,run_id):
182
+ """One explicitly opted-in continuation; never replay unknown/charged calls."""
183
+ with self.lock:
184
+ with self.store.connect() as db:
185
+ policy=db.execute('SELECT * FROM web_job_recovery WHERE run_id=?',(run_id,)).fetchone()
186
+ if not policy or policy['attempt'] != 0:return None
187
+ run=self.store.get(run_id)
188
+ if run['owner_id'] != actor.user_id:return None
189
+ calls=self.store.calls(run_id)
190
+ if (run['status']!='failed' or run['error'] not in REPAIRABLE or run.get('cancel_requested')
191
+ or not calls or any(c['state'] not in {'settled','rejected'} for c in calls)):
192
+ return None
193
+ old=self.job(actor,run_id)
194
+ # Any already linked recovery, including an explicit user action, wins.
195
+ if old['followups']:return old['followups'][0]['id']
196
+ try:
197
+ next_job=self.submit(actor,old['scenario'],old['requirement'],
198
+ 'automatic-recovery-v1:'+run_id,recovery_of=run_id)
199
+ with self.store.connect() as db:
200
+ db.execute('INSERT OR IGNORE INTO web_job_recovery VALUES(?,?,1,NULL)',(next_job['id'],policy['root_run']))
201
+ self.store.stage_event(run_id,'recovery','scheduled','原任务保留;已依据失败源码与真实诊断创建一次自动恢复:'+next_job['id'])
202
+ return next_job['id']
203
+ except SkillError as exc:
204
+ # A scheduling refusal does not turn a known failure into unknown.
205
+ with self.store.connect() as db:db.execute('UPDATE web_job_recovery SET error=? WHERE run_id=?',(exc.code,run_id))
206
+ return None
207
+ except Exception:
208
+ with self.store.connect() as db:db.execute("UPDATE web_job_recovery SET error='AUTO_RECOVERY_SCHEDULING_FAILED' WHERE run_id=?",(run_id,))
209
+ return None
210
 
211
  def worker(self):
212
  while not self.stopped.is_set():
 
243
  with self.store.connect() as db: db.execute("UPDATE web_jobs SET state='verified',evidence=? WHERE id=?",(canonical(evidence),run_id))
244
  if actor.user_id=='local-example-builder': self.save_example(row['scenario'],run_id,evidence)
245
  return
246
+ if run['status'] in {'failed','unknown','cancelled','succeeded'}:
247
+ with self.store.connect() as db: db.execute('UPDATE web_jobs SET state=?,error=? WHERE id=?',(run['status'],run['error'],run_id))
248
+ if run['status']=='failed':self.auto_recover(actor,run_id)
249
+ return
250
  LocalValidation(runtime,actor,'local-web-delegation-v1:'+actor.user_id).step(run_id)
251
  raise SkillError('WORKER_STEP_LIMIT','任务推进步数超限。')
252
  except Exception as exc:
 
265
  events=self.store.stages(run_id)
266
  design=next((v['design'].get('summary','') for v in run.get('outputs',{}).values() if isinstance(v,dict) and isinstance(v.get('design'),dict)), '')
267
  from src.apps.workbench.project_files import project_info
268
+ with self.store.connect() as db:policy=db.execute('SELECT * FROM web_job_recovery WHERE run_id=?',(run_id,)).fetchone()
269
+ recovery=dict(root_run=policy['root_run'],attempt=policy['attempt'],max_continuations=1,
270
+ next_run_id=followups[0]['id'] if followups else None,error=policy['error']) if policy else None
271
  return dict(id=run_id,scenario=row['scenario'],requirement=run['request']['requirement'],status=row['state'],runtime_status=run['status'],
272
  error=row['error'] or run['error'],cursor=run['cursor'],stages=run['release']['execution_order'],repairs=run['repairs'],
273
  model_calls=self.store.calls(run_id),created_at=run['created_at'],source=source,
 
275
  timeline=timeline(self.store,run,events),progress=progress(run,row['state'],events,time.time()),
276
  design_summary=design,project=project_info(self,actor,run_id),
277
  artifacts_available=bool(source),human_acceptance=False,
278
+ recovery_of=run['request'].get('recovery_of'),followups=followups,auto_recovery=recovery)
279
 
280
  def jobs(self,actor):
281
  with self.store.connect() as db: ids=[r['id'] for r in db.execute('SELECT id FROM web_jobs ORDER BY rowid DESC LIMIT 100')]
src/apps/workbench/web.py CHANGED
@@ -33,6 +33,7 @@ class Job(Input):
33
  request_key:str=Field(min_length=8,max_length=128)
34
  skill_id:str|None=Field(default=None,max_length=80)
35
  recovery_of:str|None=Field(default=None,max_length=80)
 
36
  class Chat(Input):
37
  conversation:str=Field(min_length=1,max_length=80)
38
  prompt:str=Field(min_length=1,max_length=4000)
@@ -126,7 +127,8 @@ def create_web(engine,port=8789,*,preview_port=None,workbench_port=None,preview_
126
  actor,csrf,name=identity.session(request.cookies.get('zk_session',''))
127
  if preview_only:return {'authenticated':True,'csrf':csrf_for_origin(csrf),'workbench_origin':workbench_origin,'preview_origin':preview_origin,'scope':'generated-app-preview'}
128
  return {'authenticated':True,'username':name,'actor':actor.model_dump(),'csrf':csrf,'projects':identity.projects(actor),
129
- 'preview_origin':preview_origin,'workbench_origin':workbench_origin}
 
130
  except SkillError:
131
  return {'authenticated':False,'needs_setup':identity.needs_setup()}
132
  def signed_in(data):
@@ -156,7 +158,8 @@ def create_web(engine,port=8789,*,preview_port=None,workbench_port=None,preview_
156
  @app.post('/api/jobs',status_code=202)
157
  def submit(data:Job,actor=Depends(principal)):
158
  return engine.submit(actor,data.scenario,data.requirement,data.request_key,data.skill_id,
159
- **({'recovery_of':data.recovery_of} if data.recovery_of else {}))
 
160
  @app.post('/api/chat',status_code=202)
161
  def chat(data:Chat,actor=Depends(principal)):
162
  return engine.conversations.submit(actor,data.conversation,data.prompt,data.request_key,data.project)
 
33
  request_key:str=Field(min_length=8,max_length=128)
34
  skill_id:str|None=Field(default=None,max_length=80)
35
  recovery_of:str|None=Field(default=None,max_length=80)
36
+ auto_recover:bool=False
37
  class Chat(Input):
38
  conversation:str=Field(min_length=1,max_length=80)
39
  prompt:str=Field(min_length=1,max_length=4000)
 
127
  actor,csrf,name=identity.session(request.cookies.get('zk_session',''))
128
  if preview_only:return {'authenticated':True,'csrf':csrf_for_origin(csrf),'workbench_origin':workbench_origin,'preview_origin':preview_origin,'scope':'generated-app-preview'}
129
  return {'authenticated':True,'username':name,'actor':actor.model_dump(),'csrf':csrf,'projects':identity.projects(actor),
130
+ 'preview_origin':preview_origin,'workbench_origin':workbench_origin,
131
+ 'capabilities':{'automatic_recovery':'bounded-continuation-v1'}}
132
  except SkillError:
133
  return {'authenticated':False,'needs_setup':identity.needs_setup()}
134
  def signed_in(data):
 
158
  @app.post('/api/jobs',status_code=202)
159
  def submit(data:Job,actor=Depends(principal)):
160
  return engine.submit(actor,data.scenario,data.requirement,data.request_key,data.skill_id,
161
+ **({'recovery_of':data.recovery_of} if data.recovery_of else {}),
162
+ **({'auto_recover':True} if data.auto_recover else {}))
163
  @app.post('/api/chat',status_code=202)
164
  def chat(data:Chat,actor=Depends(principal)):
165
  return engine.conversations.submit(actor,data.conversation,data.prompt,data.request_key,data.project)
src/modules/execution/scenarios/calculator.py CHANGED
@@ -27,6 +27,7 @@ Known endpoints wrong method=>405 {"error":"METHOD_NOT_ALLOWED"} before auth. /a
27
  Expression grammar: sum=product ((+|-) product)*; product=unary ((*|/) unary)*; unary=(+|-)* atom; atom=number | (sum). Number is digits optionally followed by dot and one-or-more digits, or dot followed by digits. Allow ASCII spaces between tokens, not within a number. Only ASCII digits, space, + - * / ( ) dot. No exponent, implicit multiplication, NaN or Infinity. Binary operations left associative; multiplication/division precede addition/subtraction. Unary signs each count as an operator.
28
  Reject blank or malformed grammar, trailing characters, unmatched parentheses=>400 {"error":"INVALID_EXPRESSION"}; zero divisor=>400 {"error":"DIVISION_BY_ZERO"}.
29
  Limits: decoded expression<=128 chars; parentheses nesting<=16; total unary+binary operators<=64; each numeric literal<=24 digits excluding dot; absolute value of every literal and intermediate result<=1e24. Limit violation=>422 {"error":"LIMIT_EXCEEDED"}. Check decoded length before grammar; check depth before recursion. Encoded input length<=256; longer transport input=>400 INVALID_INPUT.
 
30
  Successful200 JSON exactly {"expression":"<original decoded expression>","result":"<decimal string>"}. Round FINAL value only to scale12 HALF_UP, stripTrailingZeros and use toPlainString; any zero is "0". For 1/6 result "0.166666666667", 0.1+0.2 result "0.3". JSON UTF-8. Empty expression64 is INVALID_INPUT; encoded spaces is INVALID_EXPRESSION. Health needs no auth. Do not modify protected tests, runner, API contract or sandbox.'''
31
 
32
 
 
27
  Expression grammar: sum=product ((+|-) product)*; product=unary ((*|/) unary)*; unary=(+|-)* atom; atom=number | (sum). Number is digits optionally followed by dot and one-or-more digits, or dot followed by digits. Allow ASCII spaces between tokens, not within a number. Only ASCII digits, space, + - * / ( ) dot. No exponent, implicit multiplication, NaN or Infinity. Binary operations left associative; multiplication/division precede addition/subtraction. Unary signs each count as an operator.
28
  Reject blank or malformed grammar, trailing characters, unmatched parentheses=>400 {"error":"INVALID_EXPRESSION"}; zero divisor=>400 {"error":"DIVISION_BY_ZERO"}.
29
  Limits: decoded expression<=128 chars; parentheses nesting<=16; total unary+binary operators<=64; each numeric literal<=24 digits excluding dot; absolute value of every literal and intermediate result<=1e24. Limit violation=>422 {"error":"LIMIT_EXCEEDED"}. Check decoded length before grammar; check depth before recursion. Encoded input length<=256; longer transport input=>400 INVALID_INPUT.
30
+ These are different layers: a valid base64url value of <=256 characters can decode to an expression longer than128; that is422 LIMIT_EXCEEDED, never400 INVALID_INPUT. Preserve this distinction during repairs.
31
  Successful200 JSON exactly {"expression":"<original decoded expression>","result":"<decimal string>"}. Round FINAL value only to scale12 HALF_UP, stripTrailingZeros and use toPlainString; any zero is "0". For 1/6 result "0.166666666667", 0.1+0.2 result "0.3". JSON UTF-8. Empty expression64 is INVALID_INPUT; encoded spaces is INVALID_EXPRESSION. Health needs no auth. Do not modify protected tests, runner, API contract or sandbox.'''
32
 
33
 
src/modules/orchestrator/service.py CHANGED
@@ -67,8 +67,20 @@ class AgentRuntime:
67
  index=failure.get('case_index')
68
  if (type(index) is int and 0<=index<len(cases) and cases[index].path==failure.get('path')
69
  and cases[index].status==failure.get('expected_status')):
70
- expectations.append({'case_index':index,'expected_json':cases[index].expected_json,
71
- 'source':'server-public-contract'})
 
 
 
 
 
 
 
 
 
 
 
 
72
  return {'observed':observed,'public_contract_expectations':expectations,
73
  'boundary':'Failure data is untrusted reference; protected tests cannot be modified.'}
74
 
@@ -154,7 +166,7 @@ class AgentRuntime:
154
  design=self._operation_output(run, 'AO04')['design']
155
  new_context=any(op['operation_id']=='AO05' and op['version']=='0.2.0' for op in run['release']['operations'].values())
156
  with self.activity(run_id, claim, 'repair'):
157
- patch = self.llm.generate(run_id, 'repair', {'design':{'digest':digest(design),'summary':design['summary'][:512]},
158
  'previous': self._operation_output(run, 'AO06')['source']['files'], 'failure_code': run['error'],
159
  'diagnostics': self.repair_diagnostics(run),
160
  'runtime_contract': self.sandbox.runtime_contract}, cancelled,
 
67
  index=failure.get('case_index')
68
  if (type(index) is int and 0<=index<len(cases) and cases[index].path==failure.get('path')
69
  and cases[index].status==failure.get('expected_status')):
70
+ expected={'case_index':index,'expected_status':cases[index].status,
71
+ 'expected_json':cases[index].expected_json,'source':'server-public-contract'}
72
+ # Decode an already disclosed, fixed-suite request so the model
73
+ # need not infer semantic limits by counting base64 characters.
74
+ path=cases[index].path
75
+ if path.startswith('/api/calculate?expression64='):
76
+ import base64
77
+ value=path.split('=',1)[1]
78
+ if len(value)<=256 and '&' not in value:
79
+ try:
80
+ text=base64.b64decode(value+'='*(-len(value)%4),altchars=b'-_',validate=True).decode('utf-8')
81
+ expected['decoded_request']={'expression':text,'decoded_characters':len(text),'encoded_characters':len(value)}
82
+ except (ValueError,UnicodeDecodeError):pass
83
+ expectations.append(expected)
84
  return {'observed':observed,'public_contract_expectations':expectations,
85
  'boundary':'Failure data is untrusted reference; protected tests cannot be modified.'}
86
 
 
166
  design=self._operation_output(run, 'AO04')['design']
167
  new_context=any(op['operation_id']=='AO05' and op['version']=='0.2.0' for op in run['release']['operations'].values())
168
  with self.activity(run_id, claim, 'repair'):
169
+ patch = self.llm.generate(run_id, 'repair', {'design':{'digest':digest(design)},
170
  'previous': self._operation_output(run, 'AO06')['source']['files'], 'failure_code': run['error'],
171
  'diagnostics': self.repair_diagnostics(run),
172
  'runtime_contract': self.sandbox.runtime_contract}, cancelled,
src/tests/runtime/test_bailian_gateway.py CHANGED
@@ -230,7 +230,19 @@ class BailianGatewayTests(unittest.TestCase):
230
  result=self.runtime.repair_diagnostics({'diagnostics':observed})
231
  self.assertEqual(result['observed'],observed)
232
  self.assertEqual(result['public_contract_expectations'],[
233
- {'case_index':0,'expected_json':{'error':'INVALID_INPUT'},'source':'server-public-contract'}])
 
 
 
 
 
 
 
 
 
 
 
 
234
  self.assertNotIn('test_code',result)
235
 
236
 
 
230
  result=self.runtime.repair_diagnostics({'diagnostics':observed})
231
  self.assertEqual(result['observed'],observed)
232
  self.assertEqual(result['public_contract_expectations'],[
233
+ {'case_index':0,'expected_status':400,'expected_json':{'error':'INVALID_INPUT'},'source':'server-public-contract'}])
234
+ self.assertNotIn('test_code',result)
235
+
236
+ def test_calculator_repair_explains_disclosed_semantic_length_without_exposing_test_code(self):
237
+ from types import SimpleNamespace
238
+ from src.modules.execution.scenarios.calculator import calculation_path
239
+ path=calculation_path('1+'*64+'1')
240
+ case=SimpleNamespace(path=path,status=422,expected_json={'error':'LIMIT_EXCEEDED'})
241
+ self.runtime.sandbox.config=SimpleNamespace(tests=[case])
242
+ result=self.runtime.repair_diagnostics({'diagnostics':{'failures':[{'case_index':0,'path':path,'expected_status':422,'actual_status':400}]}})
243
+ item=result['public_contract_expectations'][0]
244
+ self.assertEqual(item['decoded_request']['decoded_characters'],129)
245
+ self.assertEqual(item['expected_status'],422)
246
  self.assertNotIn('test_code',result)
247
 
248
 
src/tests/runtime/test_local_web.py CHANGED
@@ -172,6 +172,49 @@ class LocalReleaseTests(unittest.TestCase):
172
 
173
 
174
  class WorkQueueTests(unittest.TestCase):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  def setUp(self):
176
  runtime,_,model,sandbox=setup(self.enterContext(workspace()))
177
  sandbox.preflight=lambda:None
 
172
 
173
 
174
  class WorkQueueTests(unittest.TestCase):
175
+ def test_opted_in_failure_continues_once_with_original_source_and_diagnostics(self):
176
+ e=self.engine
177
+ old=e.submit(USER,'erp','Original Java requirement','automatic-recovery-old',auto_recover=True)
178
+ e.runtimes['erp'].sandbox.fail='build'
179
+ e.process(e.queue.get_nowait())
180
+ failed=e.job(USER,old['id']);next_id=failed['auto_recovery']['next_run_id']
181
+ self.assertEqual(failed['status'],'failed');self.assertTrue(next_id)
182
+ self.assertEqual(e.auto_recover(USER,old['id']),next_id)
183
+ self.assertEqual(e.queue.qsize(),1)
184
+ request=e.store.get(next_id)['request']
185
+ self.assertEqual(request['baseline']['source_digest'],failed['source']['source_digest'])
186
+ self.assertEqual(request['recovery_of'],old['id']);self.assertIn('observed',request['recovery_diagnostics'])
187
+ e.process(e.queue.get_nowait())
188
+ last=e.job(USER,next_id)
189
+ self.assertEqual(last['status'],'failed');self.assertEqual(last['auto_recovery']['attempt'],1)
190
+ self.assertFalse(last['auto_recovery']['next_run_id']);self.assertTrue(e.queue.empty())
191
+ self.assertIsNone(e.auto_recover(USER,next_id))
192
+ self.assertEqual(e.store.get(old['id'])['budget'],e.store.get(next_id)['budget'])
193
+
194
+ def test_failure_without_opt_in_never_creates_a_paid_continuation(self):
195
+ e=self.engine;old=e.submit(USER,'erp','Original Java requirement','no-auto-recovery')
196
+ e.runtimes['erp'].sandbox.fail='build';e.process(e.queue.get_nowait())
197
+ self.assertFalse(e.job(USER,old['id'])['followups']);self.assertTrue(e.queue.empty())
198
+
199
+ def test_unknown_or_unsettled_failure_cannot_auto_replay(self):
200
+ e=self.engine;old=e.submit(USER,'erp','Original Java requirement','unknown-auto-recovery',auto_recover=True)
201
+ rid=e.queue.get_nowait()
202
+ e.store.mutate(rid,lambda r:r.update(status='unknown',error='MODEL_RESULT_UNKNOWN'))
203
+ self.assertIsNone(e.auto_recover(USER,rid));self.assertTrue(e.queue.empty())
204
+ e.store.mutate(rid,lambda r:r.update(status='running',error=None))
205
+ call=e.store.reserve(rid,'fixture',{},1)
206
+ e.store.mutate(rid,lambda r:r.update(status='failed',error='JAVA_TEST_FAILED'))
207
+ self.assertIsNone(e.auto_recover(USER,rid));self.assertTrue(e.queue.empty())
208
+ self.assertEqual(e.store.calls(rid)[0]['state'],'reserved')
209
+
210
+ def test_auto_recovery_cannot_cross_owner_or_restart_a_cancelled_task(self):
211
+ from src.tests.runtime.fixtures import OTHER
212
+ e=self.engine;old=e.submit(USER,'erp','Original Java requirement','cancel-auto-recovery',auto_recover=True)
213
+ rid=e.queue.get_nowait()
214
+ e.store.mutate(rid,lambda r:r.update(status='failed',error='JAVA_TEST_FAILED',cancel_requested=True))
215
+ self.assertIsNone(e.auto_recover(USER,rid));self.assertIsNone(e.auto_recover(OTHER,rid))
216
+ self.assertTrue(e.queue.empty())
217
+
218
  def setUp(self):
219
  runtime,_,model,sandbox=setup(self.enterContext(workspace()))
220
  sandbox.preflight=lambda:None