Publish the current 141-task UXInteract release
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- README.md +85 -1
- SHA256SUMS +0 -0
- VALIDATION.md +204 -0
- task_001/acceptance_checklist.json +16 -0
- task_001/environment/Dockerfile +10 -0
- task_001/environment/code/.gitkeep +0 -0
- task_001/environment/docker-compose.yaml +4 -0
- task_001/instruction.md +16 -0
- task_001/quality_notes.md +2 -0
- task_001/solution/README.md +13 -0
- task_001/solution/code/index.html +145 -0
- task_001/solution/solve.sh +5 -0
- task_001/task.toml +21 -0
- task_001/task_meta.json +18 -0
- task_001/tests/_shared/contract_checker.js +576 -0
- task_001/tests/_shared/static_enhancer.sh +3 -0
- task_001/tests/enhancement_cases.json +5 -0
- task_001/tests/pixel_changes.js +49 -0
- task_001/tests/task_contract.json +23 -0
- task_001/tests/test.sh +14 -0
- task_001/tests/validate_aaav_dynamic.js +149 -0
- task_001/tests/validate_browser_smoke.js +6 -0
- task_001/tests/validate_enhanced_cases.js +104 -0
- task_001/tests/validate_lines.js +86 -0
- task_001/tests/validate_semantics.js +4 -0
- task_002/acceptance_checklist.json +18 -0
- task_002/environment/Dockerfile +10 -0
- task_002/environment/code/.gitkeep +0 -0
- task_002/environment/docker-compose.yaml +4 -0
- task_002/instruction.md +16 -0
- task_002/quality_notes.md +3 -0
- task_002/solution/README.md +13 -0
- task_002/solution/code/index.html +128 -0
- task_002/solution/solve.sh +5 -0
- task_002/task.toml +21 -0
- task_002/task_meta.json +18 -0
- task_002/tests/_shared/contract_checker.js +577 -0
- task_002/tests/_shared/static_enhancer.sh +3 -0
- task_002/tests/enhancement_cases.json +5 -0
- task_002/tests/pixel_changes.js +49 -0
- task_002/tests/task_contract.json +21 -0
- task_002/tests/test.sh +13 -0
- task_002/tests/validate_aaav_dynamic.js +149 -0
- task_002/tests/validate_browser_smoke.js +6 -0
- task_002/tests/validate_enhanced_cases.js +134 -0
- task_002/tests/validate_semantics.js +4 -0
- task_003/acceptance_checklist.json +18 -0
- task_003/environment/Dockerfile +10 -0
- task_003/environment/code/.gitkeep +0 -0
.gitattributes
CHANGED
|
@@ -58,3 +58,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
task_141/environment/assets/explorer.glb filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
task_141/solution/assets/explorer.glb filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
pretty_name: UXInteract
|
| 3 |
+
license: other
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
---
|
| 7 |
+
|
| 8 |
+
# UXInteract 0.1
|
| 9 |
+
|
| 10 |
+
UXInteract contains 141 tasks for coding agents working on interactive software and practical development workflows. Each task includes an instruction, an initial environment, a reference solution and an executable verifier.
|
| 11 |
+
|
| 12 |
+
[Website](https://uxinteract.pages.dev/) · [GitHub](https://github.com/LegoX/UXInteract) · [Hugging Face](https://huggingface.co/datasets/Lego-X/UXInteract) · [Discord](https://discord.gg/sKHZTzVShG)
|
| 13 |
+
|
| 14 |
+
## Release identity
|
| 15 |
+
|
| 16 |
+
The dataset revision is **ux_bench_0.1-v3.4-review.3**. Task IDs run from `task_001` through `task_141`. The inventory is in [task_map.json](task_map.json). [task_id_map.json](task_id_map.json) preserves the historical ID mapping for tasks 001–139; [Sky Orchard](task_140/) and [Lantern Run](task_141/) were added after the historical snapshot.
|
| 17 |
+
|
| 18 |
+
The same release files are distributed at the root of the Hugging Face dataset and under `datasets/ux_bench_0.1` on GitHub. Record the exact repository commit with evaluation results.
|
| 19 |
+
|
| 20 |
+
This revision appends Lantern Run to the 140-task snapshot. Model-free checks and remaining verifier limitations are documented in [VALIDATION.md](VALIDATION.md).
|
| 21 |
+
|
| 22 |
+
## Task layout
|
| 23 |
+
|
| 24 |
+
```text
|
| 25 |
+
task_001/
|
| 26 |
+
├── instruction.md
|
| 27 |
+
├── task.toml
|
| 28 |
+
├── environment/
|
| 29 |
+
├── solution/
|
| 30 |
+
└── tests/
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
`instruction.md` is the agent-visible task specification. The environment supplies the starting files. Reference solutions and verifier assets belong to evaluation and must be withheld from the tested agent until verification.
|
| 34 |
+
|
| 35 |
+
## Time budgets
|
| 36 |
+
|
| 37 |
+
All 141 tasks declare these base limits in `task.toml`.
|
| 38 |
+
|
| 39 |
+
| Stage | Seconds |
|
| 40 |
+
| --- | ---: |
|
| 41 |
+
| Agent execution | 3600 |
|
| 42 |
+
| Verifier | 300 |
|
| 43 |
+
| Environment build | 1200 |
|
| 44 |
+
|
| 45 |
+
The standard multi-turn runner uses `agent_timeout_multiplier: 1.0`, so each agent round has a 3,600-second limit. Record explicit overrides as part of the evaluation configuration.
|
| 46 |
+
|
| 47 |
+
## Download and verify
|
| 48 |
+
|
| 49 |
+
Install the Hugging Face CLI and authenticate with an account that has repository access.
|
| 50 |
+
|
| 51 |
+
```bash
|
| 52 |
+
hf auth login
|
| 53 |
+
hf download Lego-X/UXInteract \
|
| 54 |
+
--type dataset \
|
| 55 |
+
--revision main \
|
| 56 |
+
--local-dir ./uxinteract-data
|
| 57 |
+
cd ./uxinteract-data
|
| 58 |
+
sha256sum -c SHA256SUMS
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
Use `shasum -a 256 -c SHA256SUMS` on macOS. For a reproducible download, replace `main` with the release commit SHA. The checksum list covers every distributed file except itself.
|
| 62 |
+
|
| 63 |
+
## Run with Harbor
|
| 64 |
+
|
| 65 |
+
Use Harbor 0.24.0 and a Docker execution host. Container builds may download task dependencies.
|
| 66 |
+
|
| 67 |
+
```bash
|
| 68 |
+
uvx --from 'harbor==0.24.0' harbor run \
|
| 69 |
+
-p ./task_001 -a oracle -n 1 -k 1 --jobs-dir ../runs/oracle
|
| 70 |
+
|
| 71 |
+
uvx --from 'harbor==0.24.0' harbor run \
|
| 72 |
+
-p ./task_001 -a nop -n 1 -k 1 --jobs-dir ../runs/nop
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
Replace the task path with `.` for the full inventory. Configure a supported agent and model provider to evaluate a coding model. The project repository includes the separately configured [multi-turn runner](https://github.com/LegoX/UXInteract/tree/main/scripts).
|
| 76 |
+
|
| 77 |
+
## Scoring and results
|
| 78 |
+
|
| 79 |
+
Reward 1 denotes complete success under the bundled verifier. Some tasks preserve fractional rewards. Report attempted trials, full successes, partial rewards and execution exceptions together, with the dataset commit, Harbor version, agent, model, concurrency and protocol settings.
|
| 80 |
+
|
| 81 |
+
The 2026-11 instruction and verifier revisions require new evaluations before assigning model scores to this release. Historical scores retain their original dataset and evaluator identities.
|
| 82 |
+
|
| 83 |
+
## Validation and privacy
|
| 84 |
+
|
| 85 |
+
[VALIDATION.md](VALIDATION.md) describes the 139-task static review, previous regressions, and separate Sky Orchard and Lantern Run controls. The checks establish their recorded cases and scope. Visual appearance and open-ended reasoning have documented coverage limits.
|
| 86 |
+
|
| 87 |
+
The distribution removes unused personal result paths from 25 admission metadata files. Instructions retain the reviewed technical specifications. Task authorship, source metadata and existing notices are preserved. The project repository explains [provenance and license boundaries](https://github.com/LegoX/UXInteract/blob/main/docs/provenance.md).
|
SHA256SUMS
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
VALIDATION.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Validation
|
| 2 |
+
|
| 3 |
+
This release adds `task_141` to the 140-task snapshot. Validation records identify the task snapshots actually checked.
|
| 4 |
+
|
| 5 |
+
## Lantern Run
|
| 6 |
+
|
| 7 |
+
`task_141` passed all six browser scenarios with the reference solution and earned reward 1 under Harbor 0.24.0 on Docker. The unchanged starter earned 0. Neither run had an execution exception. Local controls accepted an SVG-based runner and rejected arm-only animation, static scenery, invisible scenery markers, a short jump, and an overlong slide. A fresh offline browser loaded the art kit and the three bundled animation clips from the starting environment. Visual polish and naturalness are reviewed separately. The historical results below retain their original scope.
|
| 8 |
+
|
| 9 |
+
## Sky Orchard
|
| 10 |
+
|
| 11 |
+
`task_140` passed all nine browser scenarios with the reference solution and earned reward 1 under Harbor 0.24.0 on Docker. The unchanged starter earned 0. Neither trial had an execution exception. Local browser controls accepted higher ground friction and rejected missing board gravity, missing vertical support, missing bounce, and missing ground friction. Artwork is reviewed separately from the automatic reward. This is model-free validation; the new task is not included in the historical model scores or control table below.
|
| 12 |
+
|
| 13 |
+
## Recorded review and regression
|
| 14 |
+
|
| 15 |
+
| Check | Scope | Outcome |
|
| 16 |
+
| --- | --- | --- |
|
| 17 |
+
| Independent instruction/verifier review | 139 tasks | Every task compared with its earlier instruction and traced through its actual verifier entry point |
|
| 18 |
+
| First verifier revision and coverage extension | 51 tasks | 228 controls matched expectations |
|
| 19 |
+
| Latest instruction/verifier alignment | 7 tasks | 40 controls matched expectations |
|
| 20 |
+
|
| 21 |
+
The 51-task regression used 51 reference solutions, 51 unchanged starters, 51 alternative implementations and 75 incorrect variants. Reference and alternative implementations received reward 1, unchanged starters and incorrect variants received reward 0.
|
| 22 |
+
|
| 23 |
+
The latest seven tasks are `task_025`, `task_027`, `task_037`, `task_041`, `task_049`, `task_106` and `task_107`. Their final snapshots were checked on 2026-11-17 with Harbor 0.24.0 on Docker execution nodes.
|
| 24 |
+
|
| 25 |
+
| Latest control | Count | Actual reward |
|
| 26 |
+
| --- | ---: | --- |
|
| 27 |
+
| Reference solution | 7 | All 1 |
|
| 28 |
+
| Unchanged starter | 7 | All 0 |
|
| 29 |
+
| Reasonable alternative implementation | 10 | All 1 |
|
| 30 |
+
| Incorrect implementation | 16 | 15 at 0, one at 0.9 |
|
| 31 |
+
|
| 32 |
+
The 0.9 result is the `task_049` variant that ends play when the bird's outline touches the boundary. It loses credit for violating the required center-coordinate threshold under the task's existing fractional scoring rule.
|
| 33 |
+
|
| 34 |
+
Two batches contain 51 recorded attempts. The final 40-control set selects the latest task snapshots, including the follow-up checks for `task_037` and `task_041`. No execution exceptions remain in that set. The 51-task and seven-task regressions overlap in task membership and must be reported separately.
|
| 35 |
+
|
| 36 |
+
## Latest behavior checks
|
| 37 |
+
|
| 38 |
+
- `task_025` checks complete source-column retention and the computed per-capita GDP in the 2007 JSON export, including equivalent numeric and table representations.
|
| 39 |
+
- `task_027` accepts SVG text and Canvas `fillText` or `strokeText`. Positive controls cover both Canvas methods, RTL/max-width text and SVG polygon marks. Transparent-text output is rejected. Reports are checked again after the input data changes.
|
| 40 |
+
- `task_037` accepts PNG, SVG, JPEG and WebP. Actual decoded images establish gallery order and preview identity while original stored bytes and MIME types are checked independently. Separate, revoked Blob URLs are accepted. Wrong-image, reversed-order and format-restricting variants fail.
|
| 41 |
+
- `task_041` checks the home menu, separate Start action, both player modes, item-value ordering, visible explosions and default/custom victory thresholds. A local boundary control accepts 100 changed pixels and rejects 99.
|
| 42 |
+
- `task_049` checks that ceiling/ground collision uses the bird's center and freezes state after game over.
|
| 43 |
+
- `task_106` checks the browser title, visible heading, rendered distribution bars, proportional lengths, filters and empty results. Horizontal HTML/CSS and vertical SVG alternatives pass.
|
| 44 |
+
- `task_107` checks the article-detail drawer at either edge while preserving surrounding workspace. A centered modal fails the drawer requirement.
|
| 45 |
+
|
| 46 |
+
The regression used model-free `oracle` and `nop` agents. The static review and finite controls do not provide a model leaderboard or measure model discriminability. Full internal control artifacts are maintained separately.
|
| 47 |
+
|
| 48 |
+
## Remaining limits
|
| 49 |
+
|
| 50 |
+
Independent review identified open-text false-rejection risks in three verifiers. `task_073` can reject a negated quotation about therapeutic efficacy. `task_080` can treat a quoted misleading tooltip that the report proposes replacing as an endorsed statement. `task_112` checks fixed vocabulary in a free-worded refutation and can reject correct synonyms. These limitations remain in this release and should be considered when interpreting affected results.
|
| 51 |
+
|
| 52 |
+
Other recorded limits include presentation constraints for `task_030`, `task_033` and `task_048`, prose matching in `task_115`, the untested over-1,000-row sampling case in `task_027`, and partial visual coverage. The 139-task review traces requirements and executable checks. It is a static review rather than a fresh container execution of every task.
|
| 53 |
+
|
| 54 |
+
## Historical controls
|
| 55 |
+
|
| 56 |
+
The following table retains the 2026-10-22 control results from earlier snapshots. It is included for lineage and must keep that earlier evaluation identity. There were 557 applicable results across 139 tasks, including 140 incorrect variants. Later instruction, verifier and budget changes require affected controls to be rerun before transferring those results to a new snapshot.
|
| 57 |
+
|
| 58 |
+
| Task | Reference reward | No-op reward | Incorrect variant reward(s) | Alternative reward |
|
| 59 |
+
| --- | ---: | ---: | ---: | ---: |
|
| 60 |
+
| `task_001` | 1 | 0 | 0 | 1 |
|
| 61 |
+
| `task_002` | 1 | 0 | 0 | 1 |
|
| 62 |
+
| `task_003` | 1 | 0 | 0 | 1 |
|
| 63 |
+
| `task_004` | 1 | 0 | 0 | 1 |
|
| 64 |
+
| `task_005` | 1 | 0 | 0 | 1 |
|
| 65 |
+
| `task_006` | 1 | 0 | 0 | 1 |
|
| 66 |
+
| `task_007` | 1 | 0 | 0 | 1 |
|
| 67 |
+
| `task_008` | 1 | 0 | 0 | 1 |
|
| 68 |
+
| `task_009` | 1 | 0 | 0 | 1 |
|
| 69 |
+
| `task_010` | 1 | 0 | 0 | 1 |
|
| 70 |
+
| `task_011` | 1 | 0 | 0 | 1 |
|
| 71 |
+
| `task_012` | 1 | 0 | 0 | 1 |
|
| 72 |
+
| `task_013` | 1 | 0 | 0 | 1 |
|
| 73 |
+
| `task_014` | 1 | 0 | 0 | 1 |
|
| 74 |
+
| `task_015` | 1 | 0 | 0 | 1 |
|
| 75 |
+
| `task_016` | 1 | 0 | 0 | 1 |
|
| 76 |
+
| `task_017` | 1 | 0 | 0 | 1 |
|
| 77 |
+
| `task_018` | 1 | 0 | 0 | 1 |
|
| 78 |
+
| `task_019` | 1 | 0 | 0 | 1 |
|
| 79 |
+
| `task_020` | 1 | 0 | 0 | 1 |
|
| 80 |
+
| `task_021` | 1 | 0 | 0 | 1 |
|
| 81 |
+
| `task_022` | 1 | 0 | 0 | 1 |
|
| 82 |
+
| `task_023` | 1 | 0 | 0 | 1 |
|
| 83 |
+
| `task_024` | 1 | 0 | 0 | 1 |
|
| 84 |
+
| `task_025` | 1 | 0 | 0 | 1 |
|
| 85 |
+
| `task_026` | 1 | 0 | 0 | 1 |
|
| 86 |
+
| `task_027` | 1 | 0 | 0 | 1 |
|
| 87 |
+
| `task_028` | 1 | 0 | 0 | 1 |
|
| 88 |
+
| `task_029` | 1 | 0 | 0 | 1 |
|
| 89 |
+
| `task_030` | 1 | 0 | 0 | 1 |
|
| 90 |
+
| `task_031` | 1 | 0 | 0 | 1 |
|
| 91 |
+
| `task_032` | 1 | 0 | 0 | 1 |
|
| 92 |
+
| `task_033` | 1 | 0 | 0 | 1 |
|
| 93 |
+
| `task_034` | 1 | 0 | 0 | 1 |
|
| 94 |
+
| `task_035` | 1 | 0 | 0 | 1 |
|
| 95 |
+
| `task_036` | 1 | 0 | 0 | 1 |
|
| 96 |
+
| `task_037` | 1 | 0 | 0 | 1 |
|
| 97 |
+
| `task_038` | 1 | 0 | 0 | 1 |
|
| 98 |
+
| `task_039` | 1 | 0 | 0 | 1 |
|
| 99 |
+
| `task_040` | 1 | 0 | 0 | 1 |
|
| 100 |
+
| `task_041` | 1 | 0 | 0 | 1 |
|
| 101 |
+
| `task_042` | 1 | 0 | 0 | 1 |
|
| 102 |
+
| `task_043` | 1 | 0 | 0 | 1 |
|
| 103 |
+
| `task_044` | 1 | 0 | 0 | 1 |
|
| 104 |
+
| `task_045` | 1 | 0 | 0 | 1 |
|
| 105 |
+
| `task_046` | 1 | 0 | 0 | 1 |
|
| 106 |
+
| `task_047` | 1 | 0 | 0 | 1 |
|
| 107 |
+
| `task_048` | 1 | 0 | 0.9 | 1 |
|
| 108 |
+
| `task_049` | 1 | 0 | 0.9 | 1 |
|
| 109 |
+
| `task_050` | 1 | 0 | 0.8888888888888888 | 1 |
|
| 110 |
+
| `task_051` | 1 | 0 | 0 | 1 |
|
| 111 |
+
| `task_052` | 1 | 0 | 0 | 1 |
|
| 112 |
+
| `task_053` | 1 | 0 | 0 | 1 |
|
| 113 |
+
| `task_054` | 1 | 0 | 0 | 1 |
|
| 114 |
+
| `task_055` | 1 | 0 | 0 | 1 |
|
| 115 |
+
| `task_056` | 1 | 0 | 0 | 1 |
|
| 116 |
+
| `task_057` | 1 | 0 | 0 | 1 |
|
| 117 |
+
| `task_058` | 1 | 0 | 0 | 1 |
|
| 118 |
+
| `task_059` | 1 | 0 | 0.8888888888888888 | 1 |
|
| 119 |
+
| `task_060` | 1 | 0 | 0 | 1 |
|
| 120 |
+
| `task_061` | 1 | 0 | 0 | 1 |
|
| 121 |
+
| `task_062` | 1 | 0 | 0.875 | 1 |
|
| 122 |
+
| `task_063` | 1 | 0 | 0.875 | 1 |
|
| 123 |
+
| `task_064` | 1 | 0 | 0.875 | 1 |
|
| 124 |
+
| `task_065` | 1 | 0 | 0.875 | 1 |
|
| 125 |
+
| `task_066` | 1 | 0 | 0 | 1 |
|
| 126 |
+
| `task_067` | 1 | 0 | 0 | 1 |
|
| 127 |
+
| `task_068` | 1 | 0 | 0 | 1 |
|
| 128 |
+
| `task_069` | 1 | 0 | 0 | 1 |
|
| 129 |
+
| `task_070` | 1 | 0 | 0 | 1 |
|
| 130 |
+
| `task_071` | 1 | 0 | 0 | 1 |
|
| 131 |
+
| `task_072` | 1 | 0 | 0 | 1 |
|
| 132 |
+
| `task_073` | 1 | 0 | 0 | 1 |
|
| 133 |
+
| `task_074` | 1 | 0 | 0 | 1 |
|
| 134 |
+
| `task_075` | 1 | 0 | 0 | 1 |
|
| 135 |
+
| `task_076` | 1 | 0 | 0 | 1 |
|
| 136 |
+
| `task_077` | 1 | 0 | 0 | 1 |
|
| 137 |
+
| `task_078` | 1 | 0 | 0 | 1 |
|
| 138 |
+
| `task_079` | 1 | 0 | 0 | 1 |
|
| 139 |
+
| `task_080` | 1 | 0 | 0 | 1 |
|
| 140 |
+
| `task_081` | 1 | 0 | 0 | 1 |
|
| 141 |
+
| `task_082` | 1 | 0 | 0 | 1 |
|
| 142 |
+
| `task_083` | 1 | 0 | 0 | 1 |
|
| 143 |
+
| `task_084` | 1 | 0 | 0 | 1 |
|
| 144 |
+
| `task_085` | 1 | 0 | 0 | 1 |
|
| 145 |
+
| `task_086` | 1 | 0 | 0 | 1 |
|
| 146 |
+
| `task_087` | 1 | 0 | 0 | 1 |
|
| 147 |
+
| `task_088` | 1 | 0 | 0 | 1 |
|
| 148 |
+
| `task_089` | 1 | 0 | 0 | 1 |
|
| 149 |
+
| `task_090` | 1 | 0 | 0 | 1 |
|
| 150 |
+
| `task_091` | 1 | 0 | 0 | 1 |
|
| 151 |
+
| `task_092` | 1 | 0 | 0 | 1 |
|
| 152 |
+
| `task_093` | 1 | 0 | 0 | 1 |
|
| 153 |
+
| `task_094` | 1 | 0 | 0 | 1 |
|
| 154 |
+
| `task_095` | 1 | 0 | 0 | 1 |
|
| 155 |
+
| `task_096` | 1 | 0 | 0 | 1 |
|
| 156 |
+
| `task_097` | 1 | 0 | 0 | 1 |
|
| 157 |
+
| `task_098` | 1 | 0 | 0 | 1 |
|
| 158 |
+
| `task_099` | 1 | 0 | 0 | 1 |
|
| 159 |
+
| `task_100` | 1 | 0 | 0 | 1 |
|
| 160 |
+
| `task_101` | 1 | 0 | 0 | 1 |
|
| 161 |
+
| `task_102` | 1 | 0 | 0 | 1 |
|
| 162 |
+
| `task_103` | 1 | 0 | 0 | 1 |
|
| 163 |
+
| `task_104` | 1 | 0 | 0 | 1 |
|
| 164 |
+
| `task_105` | 1 | 0 | 0 | 1 |
|
| 165 |
+
| `task_106` | 1 | 0 | 0 | 1 |
|
| 166 |
+
| `task_107` | 1 | 0 | 0 | 1 |
|
| 167 |
+
| `task_108` | 1 | 0 | 0 | 1 |
|
| 168 |
+
| `task_109` | 1 | 0 | 0 | 1 |
|
| 169 |
+
| `task_110` | 1 | 0 | 0, 0 | 1 |
|
| 170 |
+
| `task_111` | 1 | 0 | 0 | 1 |
|
| 171 |
+
| `task_112` | 1 | 0 | 0 | 1 |
|
| 172 |
+
| `task_113` | 1 | 0 | 0 | 1 |
|
| 173 |
+
| `task_114` | 1 | 0 | 0 | 1 |
|
| 174 |
+
| `task_115` | 1 | 0 | 0 | 1 |
|
| 175 |
+
| `task_116` | 1 | 0 | 0 | 1 |
|
| 176 |
+
| `task_117` | 1 | 0 | 0 | 1 |
|
| 177 |
+
| `task_118` | 1 | 0 | 0 | 1 |
|
| 178 |
+
| `task_119` | 1 | 0 | 0 | 1 |
|
| 179 |
+
| `task_120` | 1 | 0 | 0 | 1 |
|
| 180 |
+
| `task_121` | 1 | 0 | 0 | 1 |
|
| 181 |
+
| `task_122` | 1 | 0 | 0 | 1 |
|
| 182 |
+
| `task_123` | 1 | 0 | 0 | 1 |
|
| 183 |
+
| `task_124` | 1 | 0 | 0 | 1 |
|
| 184 |
+
| `task_125` | 1 | 0 | 0 | 1 |
|
| 185 |
+
| `task_126` | 1 | 0 | 0 | 1 |
|
| 186 |
+
| `task_127` | 1 | 0 | 0 | 1 |
|
| 187 |
+
| `task_128` | 1 | 0 | 0 | 1 |
|
| 188 |
+
| `task_129` | 1 | 0 | 0 | 1 |
|
| 189 |
+
| `task_130` | 1 | 0 | 0 | 1 |
|
| 190 |
+
| `task_131` | 1 | 0 | 0 | 1 |
|
| 191 |
+
| `task_132` | 1 | 0 | 0 | 1 |
|
| 192 |
+
| `task_133` | 1 | 0 | 0 | 1 |
|
| 193 |
+
| `task_134` | 1 | 0 | 0 | 1 |
|
| 194 |
+
| `task_135` | 1 | 0 | 0 | 1 |
|
| 195 |
+
| `task_136` | 1 | 0 | 0 | 1 |
|
| 196 |
+
| `task_137` | 1 | 0 | 0 | 1 |
|
| 197 |
+
| `task_138` | 1 | 0 | 0 | 1 |
|
| 198 |
+
| `task_139` | 1 | 0 | 0 | 1 |
|
| 199 |
+
|
| 200 |
+
## Reproducing controls
|
| 201 |
+
|
| 202 |
+
Each task includes its reference solution and initial environment. Run `oracle` and `nop` with Harbor 0.24.0 as shown in [README.md](README.md). Use a separate jobs directory and record exact task-package hashes with the new results. Incorrect and alternative controls from the internal review are not bundled.
|
| 203 |
+
|
| 204 |
+
The release retains the recorded evaluation budgets of 3,600 seconds for agent execution, 300 seconds for verification and 1,200 seconds for environment builds. Metadata privacy cleanup removes personal result paths and leaves executable task content unchanged from the reviewed candidate.
|
task_001/acceptance_checklist.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": 1,
|
| 3 |
+
"category": "frontend_development",
|
| 4 |
+
"language": "javascript",
|
| 5 |
+
"acceptance_items": [
|
| 6 |
+
"Implements the user-visible behavior described in the prompt, not only the file structure from a sample trajectory.",
|
| 7 |
+
"Keeps the solution runnable without internet access unless the task explicitly provides dependencies."
|
| 8 |
+
],
|
| 9 |
+
"input_assets": [],
|
| 10 |
+
"expected_outputs": [
|
| 11 |
+
"*.html"
|
| 12 |
+
],
|
| 13 |
+
"risk_notes": [],
|
| 14 |
+
"verifier_style": "deterministic runtime behavior and published artifact/protocol checks",
|
| 15 |
+
"repair_revision": "2026-09-29"
|
| 16 |
+
}
|
task_001/environment/Dockerfile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# syntax=docker/dockerfile:1.7-labs
|
| 2 |
+
FROM mcr.microsoft.com/playwright:v1.52.0-noble@sha256:a021500a801bab0611049217ffad6b9697d827205c15babb86a53bc1a61c02d5
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
COPY ./code /app
|
| 5 |
+
|
| 6 |
+
# Benchmark fix: the mcr/playwright base ships browsers but NOT the `playwright`
|
| 7 |
+
# npm package, so the verifier's require('playwright') threw MODULE_NOT_FOUND.
|
| 8 |
+
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
| 9 |
+
RUN npm install -g playwright@1.52.0
|
| 10 |
+
ENV NODE_PATH=/usr/lib/node_modules
|
task_001/environment/code/.gitkeep
ADDED
|
File without changes
|
task_001/environment/docker-compose.yaml
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
main:
|
| 3 |
+
build:
|
| 4 |
+
network: host
|
task_001/instruction.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Gomoku with a victory reveal
|
| 2 |
+
|
| 3 |
+
Build a two-player Gomoku game in HTML and JavaScript. Open the root `index.html` directly in a browser; the game must work offline. Show a 15×15 board and both players' stones. On a win, display the winner and reveal an Easter egg.
|
| 4 |
+
|
| 5 |
+
## Game rules and state interface
|
| 6 |
+
|
| 7 |
+
Players alternate placing stones. Either player wins by completing five consecutive stones of their own color horizontally, vertically, or along either diagonal. A gap or an opposing stone breaks a line.
|
| 8 |
+
|
| 9 |
+
Expose `window.gameTest` with `reset()`, `move(row, col)`, and `state()`. Moves use zero-based coordinates and update the same state and board as user moves. Return `{size, board, current, winner, easterEgg}`: `size` is 15, `board` is a 15×15 array with `null` for empty cells and distinct piece values for the two players, and `current` identifies the current player. When there is a winner, set a nonempty, consistent player-specific `winner` and independently set `easterEgg` to true or a nonempty value.
|
| 10 |
+
|
| 11 |
+
## Acceptance Checklist
|
| 12 |
+
|
| 13 |
+
- The page renders offline without browser errors; legal API moves update the visible board.
|
| 14 |
+
- Occupied and out-of-bounds moves leave state unchanged.
|
| 15 |
+
- Both players can win in all four directions. Winner and Easter egg stay unset before a winning line, including for disconnected stones.
|
| 16 |
+
- Reset clears every cell, the winner and the Easter egg, and restores the first mover.
|
task_001/quality_notes.md
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Quality Notes
|
| 2 |
+
|
task_001/solution/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Reference Solution Policy
|
| 2 |
+
|
| 3 |
+
This closed-suite task reserves `solution/` for benchmark calibration.
|
| 4 |
+
|
| 5 |
+
Before using this task for final scoring, add a known-correct implementation in
|
| 6 |
+
`solution/code/` and a `solution/solve.sh` that copies it into `/app`, then
|
| 7 |
+
verify:
|
| 8 |
+
|
| 9 |
+
- the reference solution receives reward `1`;
|
| 10 |
+
- an empty or stub solution receives reward `0`;
|
| 11 |
+
- the requirements in `instruction.md` are covered by the executable verifier in `tests/`.
|
| 12 |
+
|
| 13 |
+
The reference solution must not be exposed to candidate agents.
|
task_001/solution/code/index.html
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>15x15 Gomoku</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { font-family: system-ui, sans-serif; background: #f3e9d2; text-align: center; margin: 0; padding: 16px; }
|
| 9 |
+
h1 { color: #5a3e1b; }
|
| 10 |
+
#status { font-size: 18px; margin: 10px; min-height: 24px; font-weight: bold; }
|
| 11 |
+
#board {
|
| 12 |
+
display: grid;
|
| 13 |
+
grid-template-columns: repeat(15, 30px);
|
| 14 |
+
grid-template-rows: repeat(15, 30px);
|
| 15 |
+
gap: 0;
|
| 16 |
+
justify-content: center;
|
| 17 |
+
margin: 16px auto;
|
| 18 |
+
background: #d9b372;
|
| 19 |
+
width: max-content;
|
| 20 |
+
border: 2px solid #5a3e1b;
|
| 21 |
+
}
|
| 22 |
+
.cell {
|
| 23 |
+
width: 30px; height: 30px;
|
| 24 |
+
box-sizing: border-box;
|
| 25 |
+
border: 1px solid #a07b3f;
|
| 26 |
+
cursor: pointer;
|
| 27 |
+
display: flex; align-items: center; justify-content: center;
|
| 28 |
+
}
|
| 29 |
+
.stone { width: 24px; height: 24px; border-radius: 50%; }
|
| 30 |
+
.black { background: radial-gradient(circle at 35% 35%, #666, #000); }
|
| 31 |
+
.white { background: radial-gradient(circle at 35% 35%, #fff, #bbb); }
|
| 32 |
+
button { padding: 8px 18px; font-size: 16px; cursor: pointer; border-radius: 6px;
|
| 33 |
+
border: none; background: #5a3e1b; color: #fff; }
|
| 34 |
+
#easter { font-size: 40px; margin-top: 12px; min-height: 48px; }
|
| 35 |
+
</style>
|
| 36 |
+
</head>
|
| 37 |
+
<body>
|
| 38 |
+
<h1>15x15 Gomoku</h1>
|
| 39 |
+
<div id="status">Black moves first. Place a stone.</div>
|
| 40 |
+
<div id="board"></div>
|
| 41 |
+
<button id="reset">Restart</button>
|
| 42 |
+
<div id="easter"></div>
|
| 43 |
+
|
| 44 |
+
<script>
|
| 45 |
+
const SIZE = 15; // 15x15 board
|
| 46 |
+
const TOTAL = SIZE * SIZE; // 225 intersections
|
| 47 |
+
const boardEl = document.getElementById('board');
|
| 48 |
+
const statusEl = document.getElementById('status');
|
| 49 |
+
const easterEl = document.getElementById('easter');
|
| 50 |
+
let grid = [];
|
| 51 |
+
let current = 'black';
|
| 52 |
+
let gameOver = false;
|
| 53 |
+
let celebrationTimer = null;
|
| 54 |
+
|
| 55 |
+
function buildBoard() {
|
| 56 |
+
if (celebrationTimer !== null) {
|
| 57 |
+
clearInterval(celebrationTimer);
|
| 58 |
+
celebrationTimer = null;
|
| 59 |
+
}
|
| 60 |
+
boardEl.innerHTML = '';
|
| 61 |
+
grid = Array.from({ length: SIZE }, () => Array(SIZE).fill(null));
|
| 62 |
+
current = 'black';
|
| 63 |
+
gameOver = false;
|
| 64 |
+
easterEl.textContent = '';
|
| 65 |
+
statusEl.textContent = 'Black moves first. Place a stone.';
|
| 66 |
+
for (let r = 0; r < SIZE; r++) {
|
| 67 |
+
for (let c = 0; c < SIZE; c++) {
|
| 68 |
+
const cell = document.createElement('div');
|
| 69 |
+
cell.className = 'cell';
|
| 70 |
+
cell.dataset.r = r;
|
| 71 |
+
cell.dataset.c = c;
|
| 72 |
+
cell.addEventListener('click', onCellClick);
|
| 73 |
+
boardEl.appendChild(cell);
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
function onCellClick(e) {
|
| 79 |
+
if (gameOver) return;
|
| 80 |
+
const r = +e.currentTarget.dataset.r;
|
| 81 |
+
const c = +e.currentTarget.dataset.c;
|
| 82 |
+
if (grid[r][c]) return;
|
| 83 |
+
grid[r][c] = current;
|
| 84 |
+
const stone = document.createElement('div');
|
| 85 |
+
stone.className = 'stone ' + current;
|
| 86 |
+
e.currentTarget.appendChild(stone);
|
| 87 |
+
if (checkWin(r, c, current)) {
|
| 88 |
+
gameOver = true;
|
| 89 |
+
const winner = current === 'black' ? 'Black' : 'White';
|
| 90 |
+
statusEl.textContent = '🎉 Winner: ' + winner + '!';
|
| 91 |
+
showEasterEgg();
|
| 92 |
+
return;
|
| 93 |
+
}
|
| 94 |
+
current = current === 'black' ? 'white' : 'black';
|
| 95 |
+
statusEl.textContent = (current === 'black' ? 'Black' : 'White') + "'s turn";
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
function checkWin(r, c, color) {
|
| 99 |
+
const dirs = [[1, 0], [0, 1], [1, 1], [1, -1]];
|
| 100 |
+
for (const [dr, dc] of dirs) {
|
| 101 |
+
let count = 1;
|
| 102 |
+
for (let s = 1; s < 5; s++) {
|
| 103 |
+
const nr = r + dr * s, nc = c + dc * s;
|
| 104 |
+
if (nr < 0 || nr >= SIZE || nc < 0 || nc >= SIZE || grid[nr][nc] !== color) break;
|
| 105 |
+
count++;
|
| 106 |
+
}
|
| 107 |
+
for (let s = 1; s < 5; s++) {
|
| 108 |
+
const nr = r - dr * s, nc = c - dc * s;
|
| 109 |
+
if (nr < 0 || nr >= SIZE || nc < 0 || nc >= SIZE || grid[nr][nc] !== color) break;
|
| 110 |
+
count++;
|
| 111 |
+
}
|
| 112 |
+
if (count >= 5) return true;
|
| 113 |
+
}
|
| 114 |
+
return false;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
// celebration animation shown after a winner is decided
|
| 118 |
+
function showEasterEgg() {
|
| 119 |
+
const easter = ['🎆', '🎉', '🥚', '✨', '🏆'];
|
| 120 |
+
let i = 0;
|
| 121 |
+
easterEl.textContent = easter[0].repeat(5);
|
| 122 |
+
celebrationTimer = setInterval(() => {
|
| 123 |
+
easterEl.textContent = easter[i % easter.length].repeat(5);
|
| 124 |
+
if (++i > 10) {
|
| 125 |
+
clearInterval(celebrationTimer);
|
| 126 |
+
celebrationTimer = null;
|
| 127 |
+
}
|
| 128 |
+
}, 150);
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
document.getElementById('reset').addEventListener('click', buildBoard);
|
| 132 |
+
buildBoard();
|
| 133 |
+
window.gameTest = {
|
| 134 |
+
reset: buildBoard,
|
| 135 |
+
move(r, c) {
|
| 136 |
+
if (!Number.isInteger(r) || !Number.isInteger(c) || r < 0 || r >= SIZE || c < 0 || c >= SIZE) return this.state();
|
| 137 |
+
const cell = boardEl.children[r * SIZE + c];
|
| 138 |
+
if (cell) cell.click();
|
| 139 |
+
return this.state();
|
| 140 |
+
},
|
| 141 |
+
state() { return { size: SIZE, board: grid.map(row => [...row]), current, winner: gameOver ? current : null, easterEgg: gameOver && easterEl.textContent }; }
|
| 142 |
+
};
|
| 143 |
+
</script>
|
| 144 |
+
</body>
|
| 145 |
+
</html>
|
task_001/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 4 |
+
TARGET="${1:-$(pwd)}"
|
| 5 |
+
cp -R "$SCRIPT_DIR/code/." "$TARGET/"
|
task_001/task.toml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[metadata]
|
| 4 |
+
|
| 5 |
+
[verifier]
|
| 6 |
+
timeout_sec = 300.0
|
| 7 |
+
|
| 8 |
+
[agent]
|
| 9 |
+
timeout_sec = 3600.0
|
| 10 |
+
|
| 11 |
+
[environment]
|
| 12 |
+
build_timeout_sec = 1200.0
|
| 13 |
+
cpus = 1
|
| 14 |
+
memory_mb = 2048
|
| 15 |
+
storage_mb = 10240
|
| 16 |
+
gpus = 0
|
| 17 |
+
allow_internet = true
|
| 18 |
+
|
| 19 |
+
[verifier.env]
|
| 20 |
+
|
| 21 |
+
[solution.env]
|
task_001/task_meta.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": 1,
|
| 3 |
+
"task_category": "frontend_development",
|
| 4 |
+
"origin_model": "GLM-4.6",
|
| 5 |
+
"sample_count": 5,
|
| 6 |
+
"user_turns": 1,
|
| 7 |
+
"language": "javascript",
|
| 8 |
+
"tool_files_from_selected_trace": [
|
| 9 |
+
"gomoku.html"
|
| 10 |
+
],
|
| 11 |
+
"input_assets": [],
|
| 12 |
+
"expected_outputs": [
|
| 13 |
+
"*.html"
|
| 14 |
+
],
|
| 15 |
+
"source_row_id": 6,
|
| 16 |
+
"repair_revision": "2026-09-29",
|
| 17 |
+
"instruction_sha256": "6903869c3ab59a41ffbc5c295b71f2b0cf6f156ca59035b2a00de02426946ea1"
|
| 18 |
+
}
|
task_001/tests/_shared/contract_checker.js
ADDED
|
@@ -0,0 +1,576 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs = require('fs');
|
| 2 |
+
const path = require('path');
|
| 3 |
+
const { chromium } = require('playwright');
|
| 4 |
+
|
| 5 |
+
const DEFAULT_TIMEOUT_MS = 12000;
|
| 6 |
+
|
| 7 |
+
function walk(dir) {
|
| 8 |
+
let out = [];
|
| 9 |
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
| 10 |
+
if (entry.name === 'tests' || entry.name === 'logs' || entry.name === 'node_modules') continue;
|
| 11 |
+
const p = path.join(dir, entry.name);
|
| 12 |
+
if (entry.isDirectory()) out = out.concat(walk(p));
|
| 13 |
+
else out.push(p);
|
| 14 |
+
}
|
| 15 |
+
return out;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function stripNoisyComments(text) {
|
| 19 |
+
return text
|
| 20 |
+
.replace(/<!--([\s\S]*?)-->/g, ' ')
|
| 21 |
+
.replace(/\/\*([\s\S]*?)\*\//g, ' ')
|
| 22 |
+
.replace(/(^|[^:])\/\/.*$/gm, '$1 ')
|
| 23 |
+
.toLowerCase();
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
function readSourceText(taskDir) {
|
| 27 |
+
const exts = new Set(['.html', '.js', '.jsx', '.ts', '.tsx', '.css']);
|
| 28 |
+
const files = walk(taskDir).filter((file) => exts.has(path.extname(file).toLowerCase()));
|
| 29 |
+
if (files.length === 0) {
|
| 30 |
+
throw new Error('no source files found for semantic validation');
|
| 31 |
+
}
|
| 32 |
+
return files.map((f) => fs.readFileSync(f, 'utf8')).join('\n');
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
function hasAnyIn(text, list) {
|
| 36 |
+
return list.some((t) => text.includes(String(t).toLowerCase()));
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
function hasAll(text, list) {
|
| 40 |
+
return list.every((t) => text.includes(String(t).toLowerCase()));
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function escapedRegExp(token) {
|
| 44 |
+
return String(token).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function readContract(taskDir) {
|
| 48 |
+
const contractPath = path.join(taskDir, 'task_contract.json');
|
| 49 |
+
if (!fs.existsSync(contractPath)) {
|
| 50 |
+
throw new Error(`missing task_contract.json: ${contractPath}`);
|
| 51 |
+
}
|
| 52 |
+
return JSON.parse(fs.readFileSync(contractPath, 'utf8'));
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
function checkSemantics(contract, taskDir) {
|
| 56 |
+
const text = stripNoisyComments(readSourceText(taskDir));
|
| 57 |
+
const rules = contract.semantics || {};
|
| 58 |
+
const errors = [];
|
| 59 |
+
const warnings = [];
|
| 60 |
+
|
| 61 |
+
if (Array.isArray(rules.all) && rules.all.length && !hasAll(text, rules.all)) {
|
| 62 |
+
errors.push(`missing required semantic tokens: ${rules.all.join(', ')}`);
|
| 63 |
+
}
|
| 64 |
+
if (Array.isArray(rules.any) && rules.any.length && !hasAnyIn(text, rules.any)) {
|
| 65 |
+
errors.push(`missing any semantic tokens: ${rules.any.join(' | ')}`);
|
| 66 |
+
}
|
| 67 |
+
if (Array.isArray(rules.all_groups)) {
|
| 68 |
+
for (const group of rules.all_groups) {
|
| 69 |
+
if (!hasAnyIn(text, group)) {
|
| 70 |
+
errors.push(`missing required semantic group: ${group.join(' | ')}`);
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
if (rules.min_tokens && typeof rules.min_tokens === 'object') {
|
| 75 |
+
for (const [token, minCount] of Object.entries(rules.min_tokens)) {
|
| 76 |
+
const count = (text.match(new RegExp(escapedRegExp(token.toLowerCase()), 'g')) || []).length;
|
| 77 |
+
if (count < minCount) {
|
| 78 |
+
errors.push(`token "${token}" count ${count} < ${minCount}`);
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
if (contract.compat && contract.compat.minSourceBytes) {
|
| 83 |
+
// reserve compatibility pass for extremely small outputs
|
| 84 |
+
const files = walk(taskDir);
|
| 85 |
+
let total = 0;
|
| 86 |
+
for (const f of files) {
|
| 87 |
+
const stat = fs.statSync(f);
|
| 88 |
+
if (stat.isFile()) total += stat.size;
|
| 89 |
+
}
|
| 90 |
+
if (total < Number(contract.compat.minSourceBytes)) {
|
| 91 |
+
warnings.push(`source footprint small: ${total} bytes`);
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
return { strictOk: errors.length === 0, warnings, errors };
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
function pick(selectorList) {
|
| 99 |
+
return selectorList.filter(Boolean).join(', ');
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
async function gatherEntry(taskDir) {
|
| 103 |
+
const files = walk(taskDir);
|
| 104 |
+
const html = files.find((f) => f.toLowerCase().endsWith('.html'));
|
| 105 |
+
if (!html) throw new Error('no html entrypoint found');
|
| 106 |
+
return html;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
async function startBrowser(taskDir) {
|
| 110 |
+
const entry = await gatherEntry(taskDir);
|
| 111 |
+
const browser = await chromium.launch({
|
| 112 |
+
headless: true,
|
| 113 |
+
args: [
|
| 114 |
+
'--no-sandbox',
|
| 115 |
+
'--disable-dev-shm-usage',
|
| 116 |
+
'--disable-gpu'
|
| 117 |
+
]
|
| 118 |
+
});
|
| 119 |
+
const page = await browser.newPage({ viewport: { width: 1100, height: 760 } });
|
| 120 |
+
const errors = [];
|
| 121 |
+
page.on('pageerror', (err) => errors.push(err.message || String(err)));
|
| 122 |
+
page.on('console', (msg) => {
|
| 123 |
+
if (msg.type() === 'error') errors.push(msg.text());
|
| 124 |
+
});
|
| 125 |
+
await page.goto(pathToFileUrl(entry), { waitUntil: 'domcontentloaded' });
|
| 126 |
+
await page.waitForTimeout(250);
|
| 127 |
+
if (errors.length) {
|
| 128 |
+
await browser.close();
|
| 129 |
+
throw new Error('browser load errors: ' + errors.join(' | '));
|
| 130 |
+
}
|
| 131 |
+
return { browser, page, errors };
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
function pathToFileUrl(filePath) {
|
| 135 |
+
const abs = path.resolve(filePath);
|
| 136 |
+
return new URL('file://' + abs.replace(/\\/g, '/')).href;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
function assertStateDiff(before, after, message) {
|
| 140 |
+
if (before === after) {
|
| 141 |
+
throw new Error(message);
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
function toNumberText(v) {
|
| 146 |
+
return Number.parseInt(String(v || '0').replace(/[^\d.-]/g, ''), 10) || 0;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
async function checkGomoku(taskDir, config) {
|
| 150 |
+
const sel = config.selectors || {};
|
| 151 |
+
const cellsSel = pick([sel.cell, '.cell', '[data-r][data-c]']);
|
| 152 |
+
const boardSel = pick([sel.board, '[data-testid="board"]', '#board']);
|
| 153 |
+
const canvasSel = 'canvas';
|
| 154 |
+
const statusSel = sel.status;
|
| 155 |
+
const resetSel = sel.reset;
|
| 156 |
+
|
| 157 |
+
const task = async () => {
|
| 158 |
+
const { browser, page } = await startBrowser(taskDir);
|
| 159 |
+
try {
|
| 160 |
+
const cellCount = await page.locator(cellsSel).count();
|
| 161 |
+
const canvasCount = await page.locator(canvasSel).count();
|
| 162 |
+
|
| 163 |
+
// A 15x15 board is a visible requirement, not a DOM-structure requirement:
|
| 164 |
+
// accept a grid of cells, a <canvas>, OR a [data-testid="board"]/#board container.
|
| 165 |
+
if (cellCount >= 40) {
|
| 166 |
+
// ---- DOM-cell board ----
|
| 167 |
+
const before = await page.evaluate(({ cellsSel, statusSel }) => {
|
| 168 |
+
const cells = Array.from(document.querySelectorAll(cellsSel));
|
| 169 |
+
const status = statusSel ? (document.querySelector(statusSel)?.innerText || '') : '';
|
| 170 |
+
const occupied = cells.filter((c) => c.children.length > 0 || c.innerText.trim().length > 0).length;
|
| 171 |
+
const marker = cells.slice(0, 6).map((c) => c.className + '|' + c.innerText).join('||');
|
| 172 |
+
return { occupied, marker, status, count: cells.length };
|
| 173 |
+
}, { cellsSel, statusSel });
|
| 174 |
+
const first = page.locator(cellsSel).nth(0);
|
| 175 |
+
const second = page.locator(cellsSel).nth(1);
|
| 176 |
+
await first.click({ force: true });
|
| 177 |
+
await page.waitForTimeout(120);
|
| 178 |
+
await second.click({ force: true });
|
| 179 |
+
await page.waitForTimeout(200);
|
| 180 |
+
const afterClicks = await page.evaluate(({ cellsSel, statusSel }) => {
|
| 181 |
+
const cells = Array.from(document.querySelectorAll(cellsSel));
|
| 182 |
+
const status = statusSel ? (document.querySelector(statusSel)?.innerText || '') : '';
|
| 183 |
+
const occupied = cells.filter((c) => c.children.length > 0 || c.innerText.trim().length > 0).length;
|
| 184 |
+
const marker = cells.slice(0, 6).map((c) => c.className + '|' + c.innerText).join('||');
|
| 185 |
+
return { occupied, marker, status, count: cells.length };
|
| 186 |
+
}, { cellsSel, statusSel });
|
| 187 |
+
if (before.occupied === afterClicks.occupied && before.marker === afterClicks.marker) {
|
| 188 |
+
throw new Error('clicking board cells does not alter board state');
|
| 189 |
+
}
|
| 190 |
+
// turn alternation: two stones placed on distinct cells must differ.
|
| 191 |
+
// A stone may be rendered as a child element, a color class on the cell
|
| 192 |
+
// itself, visible text/glyph, or a CSS pseudo-element / background.
|
| 193 |
+
const stones = await page.evaluate((cellsSel) => {
|
| 194 |
+
const cells = Array.from(document.querySelectorAll(cellsSel));
|
| 195 |
+
const sig = (cell) => {
|
| 196 |
+
if (!cell) return '';
|
| 197 |
+
const parts = [];
|
| 198 |
+
const stone = cell.querySelector('.stone, [class*="stone"]') || cell.firstElementChild;
|
| 199 |
+
if (stone && stone.className) {
|
| 200 |
+
const cls = String(stone.className).replace(/\bstone\b/g, '').trim();
|
| 201 |
+
if (cls) parts.push(cls);
|
| 202 |
+
}
|
| 203 |
+
const cellCls = String(cell.className || '')
|
| 204 |
+
.split(/\s+/)
|
| 205 |
+
.filter((c) => /black|white|stone|piece|chess|player|red|blue|dark|light|^b\d|^w\d|^x$|^o$/i.test(c))
|
| 206 |
+
.join(' ');
|
| 207 |
+
if (cellCls) parts.push(cellCls);
|
| 208 |
+
const txt = (cell.innerText || cell.textContent || '').trim();
|
| 209 |
+
if (txt) parts.push(txt);
|
| 210 |
+
try {
|
| 211 |
+
const pb = getComputedStyle(cell, '::before');
|
| 212 |
+
const pa = getComputedStyle(cell, '::after');
|
| 213 |
+
if (pb && pb.content && pb.content !== 'none' && pb.content !== 'normal') parts.push('b:' + pb.content + pb.backgroundColor);
|
| 214 |
+
if (pa && pa.content && pa.content !== 'none' && pa.content !== 'normal') parts.push('a:' + pa.content + pa.backgroundColor);
|
| 215 |
+
} catch (e) { /* ignore */ }
|
| 216 |
+
return parts.join('|').trim();
|
| 217 |
+
};
|
| 218 |
+
return { a: sig(cells[0]), b: sig(cells[1]) };
|
| 219 |
+
}, cellsSel);
|
| 220 |
+
if (!stones.a || !stones.b) {
|
| 221 |
+
throw new Error('placing a stone should leave a marker on each clicked cell');
|
| 222 |
+
}
|
| 223 |
+
if (stones.a === stones.b) {
|
| 224 |
+
throw new Error('turn alternation failed: two consecutive moves produced identical stones (' + stones.a + ')');
|
| 225 |
+
}
|
| 226 |
+
if (resetSel) {
|
| 227 |
+
const resetCount = await page.locator(resetSel).count();
|
| 228 |
+
if (resetCount > 0) {
|
| 229 |
+
await page.locator(resetSel).first().click({ force: true });
|
| 230 |
+
await page.waitForTimeout(250);
|
| 231 |
+
const afterReset = await page.evaluate(({ cellsSel, statusSel }) => {
|
| 232 |
+
const cells = Array.from(document.querySelectorAll(cellsSel));
|
| 233 |
+
const status = statusSel ? (document.querySelector(statusSel)?.innerText || '') : '';
|
| 234 |
+
const occupied = cells.filter((c) => c.children.length > 0 || c.innerText.trim().length > 0).length;
|
| 235 |
+
const marker = cells.slice(0, 6).map((c) => c.className + '|' + c.innerText).join('||');
|
| 236 |
+
return { occupied, marker, status, count: cells.length };
|
| 237 |
+
}, { cellsSel, statusSel });
|
| 238 |
+
if (afterClicks.occupied === afterReset.occupied && afterReset.marker === afterClicks.marker) {
|
| 239 |
+
throw new Error('reset does not restore board state');
|
| 240 |
+
}
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
} else if (canvasCount > 0 || (await page.locator(boardSel).count()) > 0) {
|
| 244 |
+
// ---- canvas or container board: assert clicks change the rendered state ----
|
| 245 |
+
const useCanvas = canvasCount > 0;
|
| 246 |
+
const targetSel = useCanvas ? canvasSel : boardSel;
|
| 247 |
+
const sample = () => page.evaluate(({ targetSel, statusSel, useCanvas }) => {
|
| 248 |
+
const el = document.querySelector(targetSel);
|
| 249 |
+
let canvasSample = '';
|
| 250 |
+
if (useCanvas && el && el.toDataURL) {
|
| 251 |
+
try { canvasSample = el.toDataURL().slice(0, 200); } catch (e) { canvasSample = ''; }
|
| 252 |
+
}
|
| 253 |
+
return {
|
| 254 |
+
canvasSample,
|
| 255 |
+
html: el ? (el.innerHTML.length + ':' + (el.innerText || '').trim()) : '',
|
| 256 |
+
status: statusSel ? (document.querySelector(statusSel)?.innerText || '') : '',
|
| 257 |
+
};
|
| 258 |
+
}, { targetSel, statusSel, useCanvas });
|
| 259 |
+
const before = await sample();
|
| 260 |
+
const target = page.locator(targetSel).first();
|
| 261 |
+
const box = await target.boundingBox();
|
| 262 |
+
if (box) {
|
| 263 |
+
await page.mouse.click(box.x + box.width * 0.3, box.y + box.height * 0.3);
|
| 264 |
+
await page.waitForTimeout(150);
|
| 265 |
+
await page.mouse.click(box.x + box.width * 0.55, box.y + box.height * 0.55);
|
| 266 |
+
await page.waitForTimeout(250);
|
| 267 |
+
}
|
| 268 |
+
const after = await sample();
|
| 269 |
+
if (before.canvasSample === after.canvasSample && before.html === after.html && before.status === after.status) {
|
| 270 |
+
throw new Error('clicking the board does not alter board state');
|
| 271 |
+
}
|
| 272 |
+
if (resetSel) {
|
| 273 |
+
const resetCount = await page.locator(resetSel).count();
|
| 274 |
+
if (resetCount > 0) {
|
| 275 |
+
await page.locator(resetSel).first().click({ force: true });
|
| 276 |
+
await page.waitForTimeout(250);
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
} else {
|
| 280 |
+
throw new Error('no board found: expected a >=40-cell grid, a <canvas>, or [data-testid="board"]/#board');
|
| 281 |
+
}
|
| 282 |
+
await browser.close();
|
| 283 |
+
} catch (err) {
|
| 284 |
+
await browser.close();
|
| 285 |
+
throw err;
|
| 286 |
+
}
|
| 287 |
+
};
|
| 288 |
+
return task();
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
async function checkMemoryMatch(taskDir, config) {
|
| 292 |
+
const sel = config.selectors || {};
|
| 293 |
+
const cardSel = pick([sel.card, '.card', '[data-card]']);
|
| 294 |
+
const task = async () => {
|
| 295 |
+
const { browser, page } = await startBrowser(taskDir);
|
| 296 |
+
try {
|
| 297 |
+
const count = await page.locator(cardSel).count();
|
| 298 |
+
if (count < 8) {
|
| 299 |
+
throw new Error('not enough cards rendered');
|
| 300 |
+
}
|
| 301 |
+
const before = await page.evaluate((cardSel) => {
|
| 302 |
+
const cards = Array.from(document.querySelectorAll(cardSel));
|
| 303 |
+
return {
|
| 304 |
+
flipCount: cards.filter((c) => c.classList.contains('flip')).length,
|
| 305 |
+
matchedCount: cards.filter((c) => c.classList.contains('matched')).length,
|
| 306 |
+
moveText: (document.querySelector('#moves,#stats') || document.querySelector('body')).innerText,
|
| 307 |
+
};
|
| 308 |
+
}, cardSel);
|
| 309 |
+
const first = page.locator(cardSel).nth(0);
|
| 310 |
+
const second = page.locator(cardSel).nth(1);
|
| 311 |
+
await first.click({ force: true });
|
| 312 |
+
await page.waitForTimeout(120);
|
| 313 |
+
await second.click({ force: true });
|
| 314 |
+
await page.waitForTimeout(700);
|
| 315 |
+
const after = await page.evaluate((cardSel) => {
|
| 316 |
+
const cards = Array.from(document.querySelectorAll(cardSel));
|
| 317 |
+
return {
|
| 318 |
+
flipCount: cards.filter((c) => c.classList.contains('flip')).length,
|
| 319 |
+
matchedCount: cards.filter((c) => c.classList.contains('matched')).length,
|
| 320 |
+
moveText: (document.querySelector('#moves,#stats') || document.querySelector('body')).innerText,
|
| 321 |
+
};
|
| 322 |
+
}, cardSel);
|
| 323 |
+
if (before.flipCount === after.flipCount && before.matchedCount === after.matchedCount && before.moveText === after.moveText) {
|
| 324 |
+
throw new Error('card interaction is not reflected in UI state');
|
| 325 |
+
}
|
| 326 |
+
await browser.close();
|
| 327 |
+
} catch (err) {
|
| 328 |
+
await browser.close();
|
| 329 |
+
throw err;
|
| 330 |
+
}
|
| 331 |
+
};
|
| 332 |
+
return task();
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
async function checkTowerDefense(taskDir, config) {
|
| 336 |
+
const sel = config.selectors || {};
|
| 337 |
+
const canvasSel = pick([sel.canvas, 'canvas', '#game']);
|
| 338 |
+
const spawnSel = pick([sel.spawn, '#spawn']);
|
| 339 |
+
const resetSel = pick([sel.reset, '#reset']);
|
| 340 |
+
const task = async () => {
|
| 341 |
+
const { browser, page } = await startBrowser(taskDir);
|
| 342 |
+
try {
|
| 343 |
+
const before = await page.evaluate((canvasSel) => {
|
| 344 |
+
const canvas = document.querySelector(canvasSel);
|
| 345 |
+
if (!canvas) return null;
|
| 346 |
+
let canvasSample = '';
|
| 347 |
+
try {
|
| 348 |
+
canvasSample = canvas.toDataURL().slice(0, 120);
|
| 349 |
+
} catch {
|
| 350 |
+
canvasSample = '';
|
| 351 |
+
}
|
| 352 |
+
return {
|
| 353 |
+
canvasSample,
|
| 354 |
+
hud: document.body ? document.body.innerText.replace(/\s+/g, ' ').trim() : '',
|
| 355 |
+
};
|
| 356 |
+
}, canvasSel);
|
| 357 |
+
if (!before) throw new Error('canvas not found');
|
| 358 |
+
const spawnCount = await page.locator(spawnSel).count();
|
| 359 |
+
if (spawnCount === 0) throw new Error('spawn control not found');
|
| 360 |
+
await page.locator(spawnSel).first().click({ force: true });
|
| 361 |
+
await page.waitForTimeout(900);
|
| 362 |
+
const afterSpawn = await page.evaluate((canvasSel) => {
|
| 363 |
+
const canvas = document.querySelector(canvasSel);
|
| 364 |
+
let canvasSample = '';
|
| 365 |
+
try {
|
| 366 |
+
canvasSample = canvas?.toDataURL().slice(0, 120) || '';
|
| 367 |
+
} catch {
|
| 368 |
+
canvasSample = '';
|
| 369 |
+
}
|
| 370 |
+
return {
|
| 371 |
+
canvasSample,
|
| 372 |
+
hud: document.body ? document.body.innerText.replace(/\s+/g, ' ').trim() : '',
|
| 373 |
+
};
|
| 374 |
+
}, canvasSel);
|
| 375 |
+
if (before.canvasSample === afterSpawn.canvasSample && before.hud === afterSpawn.hud) {
|
| 376 |
+
throw new Error('spawn action has no observable effect');
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
const canvas = page.locator(canvasSel);
|
| 380 |
+
const box = await canvas.boundingBox();
|
| 381 |
+
if (box) {
|
| 382 |
+
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
| 383 |
+
await page.waitForTimeout(500);
|
| 384 |
+
}
|
| 385 |
+
const afterPlace = await page.evaluate((canvasSel) => {
|
| 386 |
+
const canvas = document.querySelector(canvasSel);
|
| 387 |
+
let canvasSample = '';
|
| 388 |
+
try {
|
| 389 |
+
canvasSample = canvas?.toDataURL().slice(0, 120) || '';
|
| 390 |
+
} catch {
|
| 391 |
+
canvasSample = '';
|
| 392 |
+
}
|
| 393 |
+
return {
|
| 394 |
+
canvasSample,
|
| 395 |
+
hud: document.body ? document.body.innerText.replace(/\s+/g, ' ').trim() : '',
|
| 396 |
+
};
|
| 397 |
+
}, canvasSel);
|
| 398 |
+
if (afterSpawn.canvasSample === afterPlace.canvasSample && afterSpawn.hud === afterPlace.hud) {
|
| 399 |
+
throw new Error('placing tower on canvas has no observable effect');
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
if (resetSel) {
|
| 403 |
+
const resetCount = await page.locator(resetSel).count();
|
| 404 |
+
if (resetCount > 0) {
|
| 405 |
+
await page.locator(resetSel).first().click({ force: true });
|
| 406 |
+
await page.waitForTimeout(250);
|
| 407 |
+
}
|
| 408 |
+
}
|
| 409 |
+
await browser.close();
|
| 410 |
+
} catch (err) {
|
| 411 |
+
await browser.close();
|
| 412 |
+
throw err;
|
| 413 |
+
}
|
| 414 |
+
};
|
| 415 |
+
return task();
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
async function checkLudo(taskDir, config) {
|
| 419 |
+
const sel = config.selectors || {};
|
| 420 |
+
const rollSel = pick([sel.roll, '#roll, button']);
|
| 421 |
+
const statusSel = sel.status || '#status';
|
| 422 |
+
const diceSel = sel.dice || '#dice';
|
| 423 |
+
const task = async () => {
|
| 424 |
+
const { browser, page } = await startBrowser(taskDir);
|
| 425 |
+
try {
|
| 426 |
+
const before = await page.evaluate(({ statusSel, diceSel }) => {
|
| 427 |
+
return {
|
| 428 |
+
status: statusSel ? (document.querySelector(statusSel)?.innerText || '') : '',
|
| 429 |
+
dice: diceSel ? (document.querySelector(diceSel)?.innerText || '') : '',
|
| 430 |
+
boardText: document.body ? document.body.innerText.replace(/\s+/g, ' ').trim() : '',
|
| 431 |
+
};
|
| 432 |
+
}, { statusSel, diceSel });
|
| 433 |
+
|
| 434 |
+
const rollCount = await page.locator(rollSel).count();
|
| 435 |
+
if (rollCount === 0) throw new Error('roll control not found');
|
| 436 |
+
for (let i = 0; i < 4; i++) {
|
| 437 |
+
await page.locator(rollSel).first().click({ force: true });
|
| 438 |
+
await page.waitForTimeout(220);
|
| 439 |
+
}
|
| 440 |
+
const after = await page.evaluate(({ statusSel, diceSel }) => {
|
| 441 |
+
return {
|
| 442 |
+
status: statusSel ? (document.querySelector(statusSel)?.innerText || '') : '',
|
| 443 |
+
dice: diceSel ? (document.querySelector(diceSel)?.innerText || '') : '',
|
| 444 |
+
boardText: document.body ? document.body.innerText.replace(/\s+/g, ' ').trim() : '',
|
| 445 |
+
};
|
| 446 |
+
}, { statusSel, diceSel });
|
| 447 |
+
if (before.status === after.status && before.dice === after.dice && before.boardText === after.boardText) {
|
| 448 |
+
throw new Error('turn + dice workflow has no state change');
|
| 449 |
+
}
|
| 450 |
+
await browser.close();
|
| 451 |
+
} catch (err) {
|
| 452 |
+
await browser.close();
|
| 453 |
+
throw err;
|
| 454 |
+
}
|
| 455 |
+
};
|
| 456 |
+
return task();
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
async function checkSpaceShooter(taskDir, config) {
|
| 460 |
+
const sel = config.selectors || {};
|
| 461 |
+
const canvasSel = pick([sel.canvas, 'canvas', '#space']);
|
| 462 |
+
const restartSel = pick([sel.restart, '#restart']);
|
| 463 |
+
const scoreSel = sel.score || '#score';
|
| 464 |
+
const hpSel = sel.hp || '#hp';
|
| 465 |
+
const task = async () => {
|
| 466 |
+
const { browser, page } = await startBrowser(taskDir);
|
| 467 |
+
try {
|
| 468 |
+
const before = await page.evaluate(({ canvasSel, scoreSel, hpSel }) => {
|
| 469 |
+
const canvas = document.querySelector(canvasSel);
|
| 470 |
+
if (!canvas) return null;
|
| 471 |
+
let canvasSample = '';
|
| 472 |
+
try {
|
| 473 |
+
canvasSample = canvas.toDataURL().slice(0, 140);
|
| 474 |
+
} catch {
|
| 475 |
+
canvasSample = '';
|
| 476 |
+
}
|
| 477 |
+
const scoreEl = document.querySelector(scoreSel);
|
| 478 |
+
const hpEl = document.querySelector(hpSel);
|
| 479 |
+
return {
|
| 480 |
+
canvasSample,
|
| 481 |
+
scoreText: scoreEl ? scoreEl.innerText : '',
|
| 482 |
+
hpText: hpEl ? hpEl.innerText : '',
|
| 483 |
+
};
|
| 484 |
+
}, { canvasSel, scoreSel, hpSel });
|
| 485 |
+
if (!before) throw new Error('canvas not found');
|
| 486 |
+
const canvas = page.locator(canvasSel).first();
|
| 487 |
+
await canvas.click({ force: true });
|
| 488 |
+
await page.keyboard.press('Space');
|
| 489 |
+
await page.keyboard.press('Space');
|
| 490 |
+
await page.keyboard.press('Space');
|
| 491 |
+
await page.waitForTimeout(500);
|
| 492 |
+
const after = await page.evaluate(({ canvasSel, scoreSel, hpSel }) => {
|
| 493 |
+
const canvas = document.querySelector(canvasSel);
|
| 494 |
+
let canvasSample = '';
|
| 495 |
+
try {
|
| 496 |
+
canvasSample = canvas?.toDataURL().slice(0, 140) || '';
|
| 497 |
+
} catch {
|
| 498 |
+
canvasSample = '';
|
| 499 |
+
}
|
| 500 |
+
const scoreEl = document.querySelector(scoreSel);
|
| 501 |
+
const hpEl = document.querySelector(hpSel);
|
| 502 |
+
return {
|
| 503 |
+
canvasSample,
|
| 504 |
+
scoreText: scoreEl ? scoreEl.innerText : '',
|
| 505 |
+
hpText: hpEl ? hpEl.innerText : '',
|
| 506 |
+
};
|
| 507 |
+
}, { canvasSel, scoreSel, hpSel });
|
| 508 |
+
if (before.canvasSample === after.canvasSample && before.scoreText === after.scoreText && before.hpText === after.hpText) {
|
| 509 |
+
throw new Error('shooting key interaction has no observable effect');
|
| 510 |
+
}
|
| 511 |
+
if (restartSel) {
|
| 512 |
+
const restartCount = await page.locator(restartSel).count();
|
| 513 |
+
if (restartCount > 0) {
|
| 514 |
+
await page.locator(restartSel).first().click({ force: true });
|
| 515 |
+
await page.waitForTimeout(250);
|
| 516 |
+
}
|
| 517 |
+
}
|
| 518 |
+
await browser.close();
|
| 519 |
+
} catch (err) {
|
| 520 |
+
await browser.close();
|
| 521 |
+
throw err;
|
| 522 |
+
}
|
| 523 |
+
};
|
| 524 |
+
return task();
|
| 525 |
+
}
|
| 526 |
+
|
| 527 |
+
const behaviorRunners = {
|
| 528 |
+
gomoku: checkGomoku,
|
| 529 |
+
memory_match: checkMemoryMatch,
|
| 530 |
+
tower_defense: checkTowerDefense,
|
| 531 |
+
ludo: checkLudo,
|
| 532 |
+
space_shooter: checkSpaceShooter,
|
| 533 |
+
};
|
| 534 |
+
|
| 535 |
+
async function runContractChecks({ taskDir, mode, contractDir }) {
|
| 536 |
+
const contract = readContract(contractDir || taskDir);
|
| 537 |
+
if (mode === 'semantics' || mode === 'full') {
|
| 538 |
+
const semantic = checkSemantics(contract, taskDir);
|
| 539 |
+
if (semantic.warnings.length) {
|
| 540 |
+
console.log(JSON.stringify({ mode: 'semantics', task_id: contract.task_id, strict: semantic.strictOk, compat: semantic.warnings.length === 0, warnings: semantic.warnings }));
|
| 541 |
+
}
|
| 542 |
+
if (!semantic.strictOk) {
|
| 543 |
+
throw new Error('semantic checks failed: ' + semantic.errors.join(' | '));
|
| 544 |
+
}
|
| 545 |
+
}
|
| 546 |
+
|
| 547 |
+
if (mode === 'browser' || mode === 'full') {
|
| 548 |
+
const browserType = (contract.browser || {}).type;
|
| 549 |
+
const runner = behaviorRunners[browserType];
|
| 550 |
+
if (!runner) throw new Error(`unknown browser behavior type: ${browserType}`);
|
| 551 |
+
await runner(taskDir, contract.browser || {});
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
console.log(JSON.stringify({ mode, task_id: contract.task_id, strict: true, compat: true }));
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
if (require.main === module) {
|
| 558 |
+
(async () => {
|
| 559 |
+
const args = Object.fromEntries(
|
| 560 |
+
process.argv.slice(2).map((arg, idx, all) => {
|
| 561 |
+
if (!arg.startsWith('--')) return null;
|
| 562 |
+
const key = arg.slice(2);
|
| 563 |
+
const value = all[idx + 1] && !all[idx + 1].startsWith('--') ? all[idx + 1] : 'true';
|
| 564 |
+
return [key, value];
|
| 565 |
+
}).filter(Boolean)
|
| 566 |
+
);
|
| 567 |
+
const taskDir = args['task-dir'] ? path.resolve(args['task-dir']) : process.cwd();
|
| 568 |
+
const mode = args.mode || 'full';
|
| 569 |
+
await runContractChecks({ taskDir, mode });
|
| 570 |
+
})().catch((err) => {
|
| 571 |
+
console.error(err && err.stack ? err.stack : String(err));
|
| 572 |
+
process.exit(1);
|
| 573 |
+
});
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
module.exports = { runContractChecks };
|
task_001/tests/_shared/static_enhancer.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Behavioral validators own scoring; no source-length or lexical proxy gates.
|
| 3 |
+
static_enhance_check() { return 0; }
|
task_001/tests/enhancement_cases.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{"case_id":"ENHANCED_CASE_1","instruction_evidence":"请用 HTML、JavaScript 完成15x15 的五子棋游戏","validator":"validate_enhanced_cases.js","behavior":"渲染可玩的15x15棋盘,共225个逻辑落子位置"},
|
| 3 |
+
{"case_id":"ENHANCED_CASE_2","instruction_evidence":"完成15x15 的五子棋游戏","validator":"validate_enhanced_cases.js","behavior":"连续合法落子会改变棋盘,且双方棋子状态交替"},
|
| 4 |
+
{"case_id":"ENHANCED_CASE_3","instruction_evidence":"游戏胜利后显示赢家并放一个彩蛋","validator":"validate_enhanced_cases.js","behavior":"构造五连后显示赢家,并出现胜利后的可见彩蛋变化"}
|
| 5 |
+
]
|
task_001/tests/pixel_changes.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Locate a rendered transition without prescribing an HTML class, fixed device
|
| 2 |
+
// coordinate or even whether it is painted in a canvas.
|
| 3 |
+
async function pixelChanges(page, frames) {
|
| 4 |
+
return page.evaluate(async encoded => {
|
| 5 |
+
const images = await Promise.all(encoded.map(async source => {
|
| 6 |
+
const image = new Image();
|
| 7 |
+
image.src = 'data:image/png;base64,' + source;
|
| 8 |
+
await image.decode();
|
| 9 |
+
return image;
|
| 10 |
+
}));
|
| 11 |
+
const {width, height} = images[0];
|
| 12 |
+
const canvas = document.createElement('canvas');
|
| 13 |
+
canvas.width = width;
|
| 14 |
+
canvas.height = height;
|
| 15 |
+
const context = canvas.getContext('2d', {willReadFrequently: true});
|
| 16 |
+
const pixels = images.map(image => {
|
| 17 |
+
context.clearRect(0, 0, width, height);
|
| 18 |
+
context.drawImage(image, 0, 0);
|
| 19 |
+
return context.getImageData(0, 0, width, height).data;
|
| 20 |
+
});
|
| 21 |
+
const different = (a, b, i) => Math.max(
|
| 22 |
+
Math.abs(a[i] - b[i]), Math.abs(a[i + 1] - b[i + 1]), Math.abs(a[i + 2] - b[i + 2]),
|
| 23 |
+
) >= 16;
|
| 24 |
+
const tile = 8;
|
| 25 |
+
const columns = Math.ceil(width / tile);
|
| 26 |
+
const points = Array.from({length: columns * Math.ceil(height / tile)}, () => [0, 0, 0]);
|
| 27 |
+
let novel = 0;
|
| 28 |
+
for (let y = 0; y < height; y++) {
|
| 29 |
+
for (let x = 0; x < width; x++) {
|
| 30 |
+
const i = (y * width + x) * 4;
|
| 31 |
+
if (!different(pixels[0], pixels[1], i)) continue;
|
| 32 |
+
const bucket = points[Math.floor(y / tile) * columns + Math.floor(x / tile)];
|
| 33 |
+
bucket[0] += 1;
|
| 34 |
+
bucket[1] += x;
|
| 35 |
+
bucket[2] += y;
|
| 36 |
+
if (pixels.length === 4
|
| 37 |
+
&& (!different(pixels[2], pixels[3], i) || different(pixels[1], pixels[3], i))) novel += 1;
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
return {
|
| 41 |
+
points: points.filter(([weight]) => weight > 0)
|
| 42 |
+
.sort(([a], [b]) => b - a).slice(0, 56)
|
| 43 |
+
.map(([weight, x, y]) => ({x: x / weight, y: y / weight})),
|
| 44 |
+
novel,
|
| 45 |
+
};
|
| 46 |
+
}, frames.map(frame => frame.toString('base64')));
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
module.exports = {pixelChanges};
|
task_001/tests/task_contract.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": 1,
|
| 3 |
+
"semantics": {
|
| 4 |
+
"any": ["15", "15x15", "grid-template-columns", "225"],
|
| 5 |
+
"all_groups": [
|
| 6 |
+
["winner", "赢家", "胜利", "赢", "胜"],
|
| 7 |
+
["easter", "彩蛋"],
|
| 8 |
+
["click", "onclick", "addeventlistener", "mousedown", "pointerdown"],
|
| 9 |
+
["board", "棋盘", "grid", "canvas"]
|
| 10 |
+
],
|
| 11 |
+
"compat": {
|
| 12 |
+
"minSourceBytes": 500
|
| 13 |
+
}
|
| 14 |
+
},
|
| 15 |
+
"browser": {
|
| 16 |
+
"type": "gomoku",
|
| 17 |
+
"selectors": {
|
| 18 |
+
"cell": ".cell,[data-r][data-c]",
|
| 19 |
+
"status": "#status",
|
| 20 |
+
"reset": "#reset"
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
}
|
task_001/tests/test.sh
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -uo pipefail
|
| 3 |
+
TEST_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 4 |
+
LOG_DIR=/logs/verifier
|
| 5 |
+
mkdir -p "$LOG_DIR" 2>/dev/null || { LOG_DIR="$PWD/logs/verifier"; mkdir -p "$LOG_DIR"; }
|
| 6 |
+
REWARD_FILE="$LOG_DIR/reward.txt"
|
| 7 |
+
echo 0 > "$REWARD_FILE"
|
| 8 |
+
run() { timeout 90s node "$TEST_DIR/$1"; }
|
| 9 |
+
PASS=1
|
| 10 |
+
run validate_semantics.js || PASS=0
|
| 11 |
+
run validate_browser_smoke.js || PASS=0
|
| 12 |
+
run validate_enhanced_cases.js || PASS=0
|
| 13 |
+
run validate_lines.js || PASS=0
|
| 14 |
+
echo "$PASS" > "$REWARD_FILE"
|
task_001/tests/validate_aaav_dynamic.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs = require('fs');
|
| 2 |
+
const path = require('path');
|
| 3 |
+
const { pathToFileURL } = require('url');
|
| 4 |
+
const { chromium } = require('playwright');
|
| 5 |
+
|
| 6 |
+
const TASK_ID = 1;
|
| 7 |
+
const KIND = "browser";
|
| 8 |
+
const TESTIDS = [];
|
| 9 |
+
const HAS_QUESTION_WORKFLOW = false;
|
| 10 |
+
const SKIP_DIRS = new Set([
|
| 11 |
+
"tests",
|
| 12 |
+
"logs",
|
| 13 |
+
"node_modules",
|
| 14 |
+
".git"
|
| 15 |
+
]);
|
| 16 |
+
|
| 17 |
+
function assert(condition, message) {
|
| 18 |
+
if (!condition) throw new Error(message);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function walk(dir) {
|
| 22 |
+
let out = [];
|
| 23 |
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
| 24 |
+
if (SKIP_DIRS.has(entry.name)) continue;
|
| 25 |
+
const p = path.join(dir, entry.name);
|
| 26 |
+
if (entry.isDirectory()) out = out.concat(walk(p));
|
| 27 |
+
else out.push(p);
|
| 28 |
+
}
|
| 29 |
+
return out;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function findEntry() {
|
| 33 |
+
const files = walk(process.cwd());
|
| 34 |
+
if (KIND === 'svg') return files.find(f => f.toLowerCase().endsWith('.svg'));
|
| 35 |
+
return files.find(f => f.toLowerCase().endsWith('.html')) || files.find(f => f.toLowerCase().endsWith('.svg'));
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
async function snapshot(page) {
|
| 39 |
+
return await page.evaluate(() => JSON.stringify({
|
| 40 |
+
text: document.body?.innerText || '',
|
| 41 |
+
htmlLength: document.body?.innerHTML?.length || 0,
|
| 42 |
+
controls: document.querySelectorAll('button,[role="button"],input,select,textarea,canvas,svg,a[href]').length,
|
| 43 |
+
storage: window.localStorage ? window.localStorage.length : 0,
|
| 44 |
+
canvas: Array.from(document.querySelectorAll('canvas')).map(c => {
|
| 45 |
+
try { return c.toDataURL().slice(0, 80); } catch { return ''; }
|
| 46 |
+
}),
|
| 47 |
+
}));
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
async function runQuestionWorkflow(page) {
|
| 51 |
+
const input = page.locator('[data-testid="question-input"]');
|
| 52 |
+
const upload = page.locator('[data-testid="upload-question"]');
|
| 53 |
+
const items = page.locator('[data-testid="question-item"]');
|
| 54 |
+
const before = await items.count();
|
| 55 |
+
const text = 'AAAV dynamic question ' + Date.now();
|
| 56 |
+
await input.fill(text);
|
| 57 |
+
await upload.click();
|
| 58 |
+
await page.waitForTimeout(150);
|
| 59 |
+
assert(await items.count() > before, 'upload-question should add a question item');
|
| 60 |
+
const first = items.first();
|
| 61 |
+
if (await first.locator('[data-testid="offline-question"]').count()) {
|
| 62 |
+
const oldStatus = await first.getAttribute('data-status');
|
| 63 |
+
await first.locator('[data-testid="offline-question"]').click();
|
| 64 |
+
await page.waitForTimeout(100);
|
| 65 |
+
assert(oldStatus !== await first.getAttribute('data-status'), 'offline-question should toggle data-status');
|
| 66 |
+
}
|
| 67 |
+
if (await first.locator('[data-testid="edit-question"]').count()) {
|
| 68 |
+
await first.locator('[data-testid="edit-question"]').click();
|
| 69 |
+
await page.waitForTimeout(100);
|
| 70 |
+
assert(await first.getAttribute('data-edited') === 'true', 'edit-question should mark item as edited');
|
| 71 |
+
}
|
| 72 |
+
if (await page.locator('[data-testid="role-select"]').count()) {
|
| 73 |
+
await page.locator('[data-testid="role-select"]').selectOption('normal user').catch(() => {});
|
| 74 |
+
await page.waitForTimeout(100);
|
| 75 |
+
assert(!(await page.locator('[data-testid="delete-question"]').first().isVisible().catch(() => false)), 'delete should hide for normal user');
|
| 76 |
+
await page.locator('[data-testid="role-select"]').selectOption('admin').catch(() => {});
|
| 77 |
+
await page.waitForTimeout(100);
|
| 78 |
+
assert(await page.locator('[data-testid="delete-question"]').first().isVisible().catch(() => false), 'delete should show for admin');
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
(async () => {
|
| 83 |
+
const entry = findEntry();
|
| 84 |
+
assert(entry, 'no browser-openable entrypoint found');
|
| 85 |
+
const launchArgs = (process.env.PLAYWRIGHT_LAUNCH_ARGS || process.env.PW_LAUNCH_ARGS || "--no-sandbox --disable-setuid-sandbox --disable-dev-shm-usage").split(/\s+/).filter(Boolean);
|
| 86 |
+
const browser = await chromium.launch({ headless: true, args: launchArgs });
|
| 87 |
+
const page = await browser.newPage({ viewport: { width: 1100, height: 760 } });
|
| 88 |
+
const errors = [];
|
| 89 |
+
page.on('pageerror', err => errors.push(err.message));
|
| 90 |
+
page.on('console', msg => { if (msg.type() === 'error') errors.push(msg.text()); });
|
| 91 |
+
await page.goto(pathToFileURL(entry).href, { waitUntil: 'domcontentloaded' });
|
| 92 |
+
await page.waitForTimeout(500);
|
| 93 |
+
assert(errors.length === 0, 'browser errors on load: ' + errors.join(' | '));
|
| 94 |
+
|
| 95 |
+
if (KIND === 'svg') {
|
| 96 |
+
const stats = await page.evaluate(() => ({
|
| 97 |
+
svg: document.querySelectorAll('svg').length,
|
| 98 |
+
elems: document.querySelectorAll('svg *').length,
|
| 99 |
+
text: (document.body?.innerText || '').trim().length,
|
| 100 |
+
}));
|
| 101 |
+
assert(stats.svg >= 1, 'svg task should render an svg root');
|
| 102 |
+
assert(stats.elems >= 2 || stats.text >= 5, 'svg task should render visible structure');
|
| 103 |
+
} else {
|
| 104 |
+
const stats = await page.evaluate(() => ({
|
| 105 |
+
visible: Array.from(document.querySelectorAll('body *')).filter(el => {
|
| 106 |
+
const r = el.getBoundingClientRect();
|
| 107 |
+
const s = getComputedStyle(el);
|
| 108 |
+
return r.width > 0 && r.height > 0 && s.visibility !== 'hidden' && s.display !== 'none';
|
| 109 |
+
}).length,
|
| 110 |
+
text: (document.body?.innerText || '').trim().length,
|
| 111 |
+
controls: document.querySelectorAll('button,[role="button"],input,select,textarea,canvas,svg,a[href]').length,
|
| 112 |
+
}));
|
| 113 |
+
assert(stats.visible >= 3 || stats.text >= 20, 'page should render meaningful visible content');
|
| 114 |
+
|
| 115 |
+
for (const id of TESTIDS) {
|
| 116 |
+
const count = await page.locator(`[data-testid="${id}"]`).count();
|
| 117 |
+
assert(count > 0, `missing required data-testid: ${id}`);
|
| 118 |
+
}
|
| 119 |
+
if (HAS_QUESTION_WORKFLOW) await runQuestionWorkflow(page);
|
| 120 |
+
|
| 121 |
+
const controls = await page.$$('button,[role="button"],input,select,textarea,canvas,svg,a[href]');
|
| 122 |
+
if (controls.length) {
|
| 123 |
+
const before = await snapshot(page);
|
| 124 |
+
for (const control of controls.slice(0, 6)) {
|
| 125 |
+
const tag = await control.evaluate(el => el.tagName.toLowerCase()).catch(() => '');
|
| 126 |
+
if (tag === 'input' || tag === 'textarea') await control.fill('aaav-dynamic-input').catch(() => {});
|
| 127 |
+
else if (tag === 'select') {
|
| 128 |
+
const value = await control.evaluate(el => Array.from(el.options || [])[1]?.value || Array.from(el.options || [])[0]?.value || '').catch(() => '');
|
| 129 |
+
if (value) await control.selectOption(value).catch(() => {});
|
| 130 |
+
} else {
|
| 131 |
+
await control.click({ force: true }).catch(() => {});
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
await page.keyboard.press('Enter').catch(() => {});
|
| 135 |
+
await page.keyboard.press('Space').catch(() => {});
|
| 136 |
+
await page.waitForTimeout(200);
|
| 137 |
+
await snapshot(page);
|
| 138 |
+
// State changes are informative but not mandatory: static dashboards and
|
| 139 |
+
// diagrams may be valid even when generic clicks do not mutate state.
|
| 140 |
+
void before;
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
assert(errors.length === 0, 'browser errors after interaction: ' + errors.join(' | '));
|
| 144 |
+
await browser.close();
|
| 145 |
+
console.log(`AAAV targeted dynamic test passed for task ${TASK_ID}`);
|
| 146 |
+
})().catch(err => {
|
| 147 |
+
console.error(err && err.stack || err);
|
| 148 |
+
process.exit(1);
|
| 149 |
+
});
|
task_001/tests/validate_browser_smoke.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs=require('fs'),path=require('path'),{pathToFileURL}=require('url'),{chromium}=require('playwright');
|
| 2 |
+
function walk(d){return fs.readdirSync(d,{withFileTypes:true}).filter(e=>!['tests','logs','node_modules','.git'].includes(e.name)).flatMap(e=>e.isDirectory()?walk(path.join(d,e.name)):[path.join(d,e.name)])}
|
| 3 |
+
(async()=>{const entry=walk(process.cwd()).find(f=>/\.(html|svg)$/i.test(f));if(!entry)throw Error('missing browser entry');
|
| 4 |
+
const b=await chromium.launch({headless:true,args:['--no-sandbox','--disable-dev-shm-usage']});try{const p=await b.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));await p.route(/^https?:/,r=>r.abort());await p.goto(pathToFileURL(entry).href,{waitUntil:'load'});
|
| 5 |
+
if(!await p.evaluate(()=>[...document.querySelectorAll('body *,svg')].some(e=>{const r=e.getBoundingClientRect(),s=getComputedStyle(e);return r.width>0&&r.height>0&&s.display!=='none'&&s.visibility!=='hidden'})))throw Error('entry does not render');
|
| 6 |
+
if(errors.length)throw Error(errors.join(' | '));console.log('render smoke passed');}finally{await b.close()}})().catch(e=>{console.error(e);process.exit(1)});
|
task_001/tests/validate_enhanced_cases.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs = require('fs');
|
| 2 |
+
const path = require('path');
|
| 3 |
+
const {pathToFileURL} = require('url');
|
| 4 |
+
const {chromium} = require('playwright');
|
| 5 |
+
const {pixelChanges} = require('./pixel_changes');
|
| 6 |
+
const assert = (value, message) => { if (!value) throw Error(message); };
|
| 7 |
+
const entry = fs.readdirSync(process.cwd()).find(name => name.endsWith('.html'));
|
| 8 |
+
|
| 9 |
+
(async () => {
|
| 10 |
+
assert(entry, 'missing HTML entry');
|
| 11 |
+
const browser = await chromium.launch({headless: true, args: ['--no-sandbox']});
|
| 12 |
+
try {
|
| 13 |
+
const page = await browser.newPage({viewport: {width: 1280, height: 1000}});
|
| 14 |
+
await page.clock.install({time: new Date('2026-01-01T00:00:00Z')});
|
| 15 |
+
await page.clock.pauseAt(new Date('2026-01-01T00:00:01Z'));
|
| 16 |
+
await page.goto(pathToFileURL(path.join(process.cwd(), entry)).href);
|
| 17 |
+
const image = await browser.newPage();
|
| 18 |
+
const state = () => page.evaluate(() => window.gameTest.state());
|
| 19 |
+
const reset = () => page.evaluate(() => window.gameTest.reset());
|
| 20 |
+
const move = (r, c) => page.evaluate(([row, col]) => window.gameTest.move(row, col), [r, c]);
|
| 21 |
+
assert(await page.evaluate(() => !!window.gameTest), 'missing public gameTest API');
|
| 22 |
+
|
| 23 |
+
await reset();
|
| 24 |
+
let initial = await state();
|
| 25 |
+
assert(initial.size === 15 && initial.board.length === 15 && initial.board.every(row => row.length === 15 && row.every(cell => cell === null)), 'reset must create empty 15x15 board');
|
| 26 |
+
assert(!initial.winner && !initial.easterEgg, 'reset must clear winner and easter egg');
|
| 27 |
+
await move(4, 4);
|
| 28 |
+
const oneMove = await state();
|
| 29 |
+
assert(oneMove.board[4][4] !== null && !oneMove.winner && !oneMove.easterEgg, 'one stone cannot win');
|
| 30 |
+
for (const invalid of [[4, 4], [-1, 4], [15, 0], [-1, 15], [1, -1], [0, 15]]) {
|
| 31 |
+
await move(...invalid);
|
| 32 |
+
assert(JSON.stringify(await state()) === JSON.stringify(oneMove), 'occupied or out-of-range move changed state');
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// The test API must operate the visible board, not a hidden parallel
|
| 36 |
+
// state machine. Compare two even-move positions: the same player is to
|
| 37 |
+
// move and any turn label is unchanged, so new stones must alter pixels.
|
| 38 |
+
await reset();
|
| 39 |
+
await move(2, 3); await move(11, 12);
|
| 40 |
+
const twoStones = await page.screenshot({animations: 'disabled'});
|
| 41 |
+
await move(4, 5); await move(9, 10);
|
| 42 |
+
const fourStones = await page.screenshot({animations: 'disabled'});
|
| 43 |
+
assert(!twoStones.equals(fourStones), 'gameTest moves changed internal state but not the visible board');
|
| 44 |
+
|
| 45 |
+
// Recover the click area from the painted stone itself. This also works
|
| 46 |
+
// for canvas boards and does not require a named hook or a fitted grid.
|
| 47 |
+
const frame = async () => {
|
| 48 |
+
await page.clock.runFor(40);
|
| 49 |
+
return page.screenshot({animations: 'disabled'});
|
| 50 |
+
};
|
| 51 |
+
await reset();
|
| 52 |
+
const beforeClick = await frame();
|
| 53 |
+
await move(7, 7);
|
| 54 |
+
const {points} = await pixelChanges(image, [beforeClick, await frame()]);
|
| 55 |
+
let physicalMove = false;
|
| 56 |
+
for (const {x, y} of points) {
|
| 57 |
+
await reset();
|
| 58 |
+
await page.mouse.click(x, y);
|
| 59 |
+
const board = (await state()).board;
|
| 60 |
+
if (board[7][7] !== null && board.flat().filter(cell => cell !== null).length === 1) {
|
| 61 |
+
physicalMove = true;
|
| 62 |
+
break;
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
assert(physicalMove, 'clicking the rendered board must place exactly one stone in its own state');
|
| 66 |
+
await page.mouse.move(0, 0);
|
| 67 |
+
|
| 68 |
+
const play = async (moves, winnerLabel) => {
|
| 69 |
+
await reset();
|
| 70 |
+
for (let i = 0; i < moves.length; i++) {
|
| 71 |
+
await move(...moves[i]);
|
| 72 |
+
const snapshot = await state();
|
| 73 |
+
if (i < moves.length - 1) assert(!snapshot.winner && !snapshot.easterEgg, `${winnerLabel} declared victory early`);
|
| 74 |
+
}
|
| 75 |
+
const finished = await state();
|
| 76 |
+
assert(finished.winner && finished.easterEgg, `${winnerLabel} five-in-a-row not recognized`);
|
| 77 |
+
return finished;
|
| 78 |
+
};
|
| 79 |
+
const winMoves = [[1,1],[9,0],[2,2],[9,2],[3,3],[9,4],[4,4],[9,6],[5,5]];
|
| 80 |
+
const blackDiagonal = await play(winMoves, 'diagonal');
|
| 81 |
+
const whiteHorizontal = await play([[10,0],[0,0],[11,2],[0,1],[12,4],[0,2],[13,6],[0,3],[14,8],[0,4]], 'white horizontal');
|
| 82 |
+
assert(blackDiagonal.winner !== whiteHorizontal.winner, 'both players reported the same winner');
|
| 83 |
+
assert(blackDiagonal.board[1][1] !== blackDiagonal.board[9][0], 'player stones must have distinct values');
|
| 84 |
+
const trace = async moves => {
|
| 85 |
+
await reset();
|
| 86 |
+
for (const position of moves.slice(0, -1)) await move(...position);
|
| 87 |
+
const before = await frame();
|
| 88 |
+
await move(...moves.at(-1));
|
| 89 |
+
await page.clock.runFor(750);
|
| 90 |
+
return [before, await frame()];
|
| 91 |
+
};
|
| 92 |
+
const winning = await trace(winMoves);
|
| 93 |
+
const ordinary = await trace([[1,1],[9,0],[2,2],[9,2],[3,3],[9,4],[4,3],[9,6],[5,5]]);
|
| 94 |
+
assert(!(await state()).winner, 'comparison placement unexpectedly won');
|
| 95 |
+
const {novel} = await pixelChanges(image, [...winning, ...ordinary]);
|
| 96 |
+
assert(novel >= 12, 'victory must alter visible output beyond an ordinary final stone or turn update');
|
| 97 |
+
await reset();
|
| 98 |
+
initial = await state();
|
| 99 |
+
assert(initial.board.every(row => row.every(cell => cell === null)) && !initial.winner && !initial.easterEgg, 'reset after victory did not clear game');
|
| 100 |
+
console.log('Gomoku reset, illegal move, diagonal and both-player win checks passed');
|
| 101 |
+
} finally {
|
| 102 |
+
await browser.close();
|
| 103 |
+
}
|
| 104 |
+
})().catch(error => { console.error(error); process.exit(1); });
|
task_001/tests/validate_lines.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs = require('fs');
|
| 2 |
+
const path = require('path');
|
| 3 |
+
const {pathToFileURL} = require('url');
|
| 4 |
+
const {chromium} = require('playwright');
|
| 5 |
+
const assert = (value, message) => { if (!value) throw Error(message); };
|
| 6 |
+
const OUTPUT = '/logs/verifier/visual';
|
| 7 |
+
|
| 8 |
+
function winningMoves(start, direction, secondPlayer) {
|
| 9 |
+
// Last stone joins two shorter runs, exercising both sides of the new stone.
|
| 10 |
+
const line = [0, 4, 1, 3, 2].map(i => [start[0] + direction[0] * i, start[1] + direction[1] * i]);
|
| 11 |
+
const distractors = [[14, 0], [14, 2], [14, 4], [14, 6], [14, 8]];
|
| 12 |
+
return line.flatMap((point, i) => secondPlayer ? [distractors[i], point]
|
| 13 |
+
: i === line.length - 1 ? [point] : [point, distractors[i]]);
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
(async () => {
|
| 17 |
+
const entry = path.join(process.cwd(), 'index.html');
|
| 18 |
+
assert(fs.existsSync(entry), 'missing public index.html entry');
|
| 19 |
+
const browser = await chromium.launch({headless: true, args: ['--no-sandbox']});
|
| 20 |
+
try {
|
| 21 |
+
fs.mkdirSync(OUTPUT, {recursive: true});
|
| 22 |
+
const page = await browser.newPage({viewport: {width: 1100, height: 900}});
|
| 23 |
+
await page.route(/^https?:/, route => route.abort());
|
| 24 |
+
await page.goto(pathToFileURL(entry).href);
|
| 25 |
+
const state = () => page.evaluate(() => window.gameTest.state());
|
| 26 |
+
const reset = () => page.evaluate(() => window.gameTest.reset());
|
| 27 |
+
const move = (r, c) => page.evaluate(([row, col]) => window.gameTest.move(row, col), [r, c]);
|
| 28 |
+
const capture = name => page.screenshot({path: path.join(OUTPUT, `${name}.png`), animations: 'disabled'});
|
| 29 |
+
await reset();
|
| 30 |
+
const firstPlayer = (await state()).current;
|
| 31 |
+
await capture('01-empty');
|
| 32 |
+
await move(2, 3); await move(11, 12);
|
| 33 |
+
await capture('02-two-stones');
|
| 34 |
+
await move(4, 5); await move(9, 10);
|
| 35 |
+
await capture('03-four-stones');
|
| 36 |
+
const directions = [
|
| 37 |
+
['horizontal', [0, 0], [0, 1]],
|
| 38 |
+
['vertical', [0, 14], [1, 0]],
|
| 39 |
+
['diagonal', [0, 0], [1, 1]],
|
| 40 |
+
['anti-diagonal', [0, 14], [1, -1]],
|
| 41 |
+
['interior-horizontal', [7, 5], [0, 1]],
|
| 42 |
+
['interior-vertical', [5, 7], [1, 0]],
|
| 43 |
+
];
|
| 44 |
+
const winners = [null, null];
|
| 45 |
+
for (const [label, start, direction] of directions) {
|
| 46 |
+
for (const secondPlayer of [false, true]) {
|
| 47 |
+
const moves = winningMoves(start, direction, secondPlayer);
|
| 48 |
+
await reset();
|
| 49 |
+
for (let i = 0; i < moves.length; i++) {
|
| 50 |
+
await move(...moves[i]);
|
| 51 |
+
const snapshot = await state();
|
| 52 |
+
if (i < moves.length - 1) assert(!snapshot.winner && !snapshot.easterEgg,
|
| 53 |
+
`${label}/${secondPlayer}: premature victory`);
|
| 54 |
+
}
|
| 55 |
+
const finished = await state();
|
| 56 |
+
assert(finished.winner && finished.easterEgg, `${label}/${secondPlayer}: missed five-in-a-row`);
|
| 57 |
+
const player = Number(secondPlayer);
|
| 58 |
+
if (winners[player] !== null) assert(winners[player] === finished.winner, 'winner labels must be consistent');
|
| 59 |
+
winners[player] = finished.winner;
|
| 60 |
+
if (label === 'horizontal' && !secondPlayer) await capture('04-first-player-win');
|
| 61 |
+
if (label === 'anti-diagonal' && secondPlayer) await capture('05-second-player-win');
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
assert(winners[0] !== winners[1], 'players reported the same winner');
|
| 65 |
+
for (const points of [
|
| 66 |
+
[[3, 0], [3, 2], [3, 4], [3, 6], [3, 8]],
|
| 67 |
+
[[4, 0], [4, 1], [4, 3], [4, 4], [4, 5]],
|
| 68 |
+
]) {
|
| 69 |
+
await reset();
|
| 70 |
+
for (let i = 0; i < points.length; i++) {
|
| 71 |
+
await move(...points[i]);
|
| 72 |
+
const snapshot = await state();
|
| 73 |
+
assert(!snapshot.winner && !snapshot.easterEgg, 'disconnected stones declared a win');
|
| 74 |
+
if (i < points.length - 1) await move(12, i * 2);
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
await reset();
|
| 78 |
+
const cleared = await state();
|
| 79 |
+
assert(cleared.current === firstPlayer && !cleared.winner && !cleared.easterEgg
|
| 80 |
+
&& cleared.board.every(row => row.every(cell => cell === null)), 'reset must restore initial state');
|
| 81 |
+
await capture('06-reset');
|
| 82 |
+
console.log('All win directions, both players, joined runs, gaps and reset passed');
|
| 83 |
+
} finally {
|
| 84 |
+
await browser.close();
|
| 85 |
+
}
|
| 86 |
+
})().catch(error => { console.error(error); process.exit(1); });
|
task_001/tests/validate_semantics.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs=require('fs'),path=require('path');
|
| 2 |
+
function walk(d){return fs.readdirSync(d,{withFileTypes:true}).filter(e=>!['tests','logs','node_modules','.git'].includes(e.name)).flatMap(e=>e.isDirectory()?walk(path.join(d,e.name)):[path.join(d,e.name)])}
|
| 3 |
+
if(!walk(process.cwd()).some(f=>/\.(html|svg|js|ts|tsx|jsx|md)$/i.test(f)))throw Error('missing candidate output');
|
| 4 |
+
console.log('candidate output present; requirements checked by runtime cases');
|
task_002/acceptance_checklist.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": 2,
|
| 3 |
+
"category": "frontend_development",
|
| 4 |
+
"language": "javascript",
|
| 5 |
+
"acceptance_items": [
|
| 6 |
+
"Implements the user-visible behavior described in the prompt, not only the file structure from a sample trajectory.",
|
| 7 |
+
"Keeps the solution runnable without internet access unless the task explicitly provides dependencies."
|
| 8 |
+
],
|
| 9 |
+
"input_assets": [],
|
| 10 |
+
"expected_outputs": [
|
| 11 |
+
"*.html"
|
| 12 |
+
],
|
| 13 |
+
"risk_notes": [
|
| 14 |
+
"This task came from a multi-turn trajectory; the enhanced instruction preserves all user turns."
|
| 15 |
+
],
|
| 16 |
+
"verifier_style": "deterministic runtime behavior and published artifact/protocol checks",
|
| 17 |
+
"repair_revision": "2026-09-29"
|
| 18 |
+
}
|
task_002/environment/Dockerfile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# syntax=docker/dockerfile:1.7-labs
|
| 2 |
+
FROM mcr.microsoft.com/playwright:v1.52.0-noble@sha256:a021500a801bab0611049217ffad6b9697d827205c15babb86a53bc1a61c02d5
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
COPY ./code /app
|
| 5 |
+
|
| 6 |
+
# Benchmark fix: the mcr/playwright base ships browsers but NOT the `playwright`
|
| 7 |
+
# npm package, so the verifier's require('playwright') threw MODULE_NOT_FOUND.
|
| 8 |
+
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
| 9 |
+
RUN npm install -g playwright@1.52.0
|
| 10 |
+
ENV NODE_PATH=/usr/lib/node_modules
|
task_002/environment/code/.gitkeep
ADDED
|
File without changes
|
task_002/environment/docker-compose.yaml
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
services:
|
| 2 |
+
main:
|
| 3 |
+
build:
|
| 4 |
+
network: host
|
task_002/instruction.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Memory matching game
|
| 2 |
+
|
| 3 |
+
Build a browser game with a 4×4 grid of cards containing eight pairs. Let the player reveal cards with a flip animation and match pairs. Deliver an offline `index.html` at the project root.
|
| 4 |
+
|
| 5 |
+
## Interaction and state interface
|
| 6 |
+
|
| 7 |
+
Expose `window.gameTest` with `reset(deck?)`, `flip(index)`, `advance(milliseconds)`, and `state()`. If supplied, use the 16-item deck in its given order. Return `{cards:[{value, faceUp, matched}, ...], moves, matchedPairs}`. The API operates on the same cards and game logic as clicks. Advancing virtual time only advances the mismatch wait and updates the display.
|
| 8 |
+
|
| 9 |
+
The first eligible flip reveals a card. A second eligible flip counts one move. Matching cards remain face up; mismatches are visible for 300–2000 ms, then both turn face down. No third flip is allowed while a mismatch is pending, and face-up or matched cards cannot be flipped again.
|
| 10 |
+
|
| 11 |
+
## Acceptance Checklist
|
| 12 |
+
|
| 13 |
+
- The offline page renders the cards; flipping reveals the selected value on the same board used by the state interface.
|
| 14 |
+
- A supplied deck keeps its order. The first flip does not count a move; the second counts exactly one. Duplicate flips and flips during the mismatch wait leave state unchanged.
|
| 15 |
+
- A mismatch turns back within the allowed delay without counting another move. All eight pairs can be matched; matched cards stay visible and the counters reflect completed turns and matches.
|
| 16 |
+
- Reset hides and unmatches all cards, clears both counters and cancels any pending mismatch, even if a new pair is played immediately afterward.
|
task_002/quality_notes.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Quality Notes
|
| 2 |
+
|
| 3 |
+
- This task came from a multi-turn trajectory; the enhanced instruction preserves all user turns.
|
task_002/solution/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Reference Solution Policy
|
| 2 |
+
|
| 3 |
+
This closed-suite task reserves `solution/` for benchmark calibration.
|
| 4 |
+
|
| 5 |
+
Before using this task for final scoring, add a known-correct implementation in
|
| 6 |
+
`solution/code/` and a `solution/solve.sh` that copies it into `/app`, then
|
| 7 |
+
verify:
|
| 8 |
+
|
| 9 |
+
- the reference solution receives reward `1`;
|
| 10 |
+
- an empty or stub solution receives reward `0`;
|
| 11 |
+
- the requirements in `instruction.md` are covered by the executable verifier in `tests/`.
|
| 12 |
+
|
| 13 |
+
The reference solution must not be exposed to candidate agents.
|
task_002/solution/code/index.html
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>4x4 Card Memory Match</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { font-family: system-ui, sans-serif; background: #1b2430; color: #fff; text-align: center; margin: 0; padding: 16px; }
|
| 9 |
+
h1 { color: #ffd166; }
|
| 10 |
+
#stats { margin: 8px; font-size: 16px; }
|
| 11 |
+
#grid {
|
| 12 |
+
display: grid;
|
| 13 |
+
grid-template-columns: repeat(4, 90px);
|
| 14 |
+
grid-template-rows: repeat(4, 90px);
|
| 15 |
+
gap: 10px;
|
| 16 |
+
justify-content: center;
|
| 17 |
+
margin: 20px auto;
|
| 18 |
+
}
|
| 19 |
+
.card {
|
| 20 |
+
width: 90px; height: 90px;
|
| 21 |
+
perspective: 600px;
|
| 22 |
+
cursor: pointer;
|
| 23 |
+
background: none; border: none; padding: 0;
|
| 24 |
+
}
|
| 25 |
+
.inner {
|
| 26 |
+
position: relative; width: 100%; height: 100%;
|
| 27 |
+
transition: transform 0.4s; transform-style: preserve-3d;
|
| 28 |
+
}
|
| 29 |
+
.card.flip .inner, .card.matched .inner { transform: rotateY(180deg); }
|
| 30 |
+
.face {
|
| 31 |
+
position: absolute; width: 100%; height: 100%;
|
| 32 |
+
backface-visibility: hidden; border-radius: 10px;
|
| 33 |
+
display: flex; align-items: center; justify-content: center; font-size: 40px;
|
| 34 |
+
}
|
| 35 |
+
.front { background: #3a86ff; }
|
| 36 |
+
.back { background: #ffd166; color: #1b2430; transform: rotateY(180deg); }
|
| 37 |
+
.card.matched .back { background: #06d6a0; }
|
| 38 |
+
button#reset { padding: 8px 18px; font-size: 16px; border: none; border-radius: 6px;
|
| 39 |
+
background: #ef476f; color: #fff; cursor: pointer; }
|
| 40 |
+
</style>
|
| 41 |
+
</head>
|
| 42 |
+
<body>
|
| 43 |
+
<h1>4x4 Card Memory Match</h1>
|
| 44 |
+
<div id="stats">Matched <span id="matched">0</span> / 8 pairs · Moves <span id="moves">0</span></div>
|
| 45 |
+
<div id="grid"></div>
|
| 46 |
+
<button id="reset">Restart</button>
|
| 47 |
+
|
| 48 |
+
<script>
|
| 49 |
+
const SYMBOLS = ['🍎', '🍌', '🍇', '🍑', '🍓', '🍉', '🥝', '🍒']; // 8 pairs -> 4x4 = 16 cards
|
| 50 |
+
const gridEl = document.getElementById('grid');
|
| 51 |
+
const matchedEl = document.getElementById('matched');
|
| 52 |
+
const movesEl = document.getElementById('moves');
|
| 53 |
+
let firstCard = null;
|
| 54 |
+
let lock = false;
|
| 55 |
+
let matchedPairs = 0;
|
| 56 |
+
let moves = 0;
|
| 57 |
+
let pendingMismatch = null;
|
| 58 |
+
|
| 59 |
+
function shuffle(arr) {
|
| 60 |
+
for (let i = arr.length - 1; i > 0; i--) {
|
| 61 |
+
const j = Math.floor(Math.random() * (i + 1));
|
| 62 |
+
[arr[i], arr[j]] = [arr[j], arr[i]];
|
| 63 |
+
}
|
| 64 |
+
return arr;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
function newGame(deckOverride) {
|
| 68 |
+
gridEl.innerHTML = '';
|
| 69 |
+
firstCard = null; lock = false; pendingMismatch = null; matchedPairs = 0; moves = 0;
|
| 70 |
+
matchedEl.textContent = '0';
|
| 71 |
+
movesEl.textContent = '0';
|
| 72 |
+
const deck = deckOverride ? [...deckOverride] : shuffle([...SYMBOLS, ...SYMBOLS]); // 16 cards
|
| 73 |
+
deck.forEach((sym) => {
|
| 74 |
+
const card = document.createElement('button');
|
| 75 |
+
card.className = 'card';
|
| 76 |
+
card.dataset.symbol = sym;
|
| 77 |
+
card.innerHTML = '<div class="inner">' +
|
| 78 |
+
'<div class="face front">❓</div>' +
|
| 79 |
+
'<div class="face back">' + sym + '</div></div>';
|
| 80 |
+
card.addEventListener('click', () => flipCard(card));
|
| 81 |
+
gridEl.appendChild(card);
|
| 82 |
+
});
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function flipCard(card) {
|
| 86 |
+
if (lock || card.classList.contains('flip') || card.classList.contains('matched')) return;
|
| 87 |
+
card.classList.add('flip');
|
| 88 |
+
if (!firstCard) {
|
| 89 |
+
firstCard = card;
|
| 90 |
+
return;
|
| 91 |
+
}
|
| 92 |
+
moves++;
|
| 93 |
+
movesEl.textContent = moves;
|
| 94 |
+
if (firstCard.dataset.symbol === card.dataset.symbol) {
|
| 95 |
+
firstCard.classList.add('matched');
|
| 96 |
+
card.classList.add('matched');
|
| 97 |
+
firstCard = null;
|
| 98 |
+
matchedPairs++;
|
| 99 |
+
matchedEl.textContent = matchedPairs;
|
| 100 |
+
if (matchedPairs === SYMBOLS.length) {
|
| 101 |
+
setTimeout(() => alert('🎉 All pairs matched! Moves: ' + moves), 200);
|
| 102 |
+
}
|
| 103 |
+
} else {
|
| 104 |
+
lock = true;
|
| 105 |
+
const a = firstCard;
|
| 106 |
+
firstCard = null;
|
| 107 |
+
const settle = () => {
|
| 108 |
+
a.classList.remove('flip');
|
| 109 |
+
card.classList.remove('flip');
|
| 110 |
+
lock = false;
|
| 111 |
+
pendingMismatch = null;
|
| 112 |
+
};
|
| 113 |
+
pendingMismatch = { remaining: 700, settle };
|
| 114 |
+
setTimeout(() => { if (pendingMismatch?.settle === settle) settle(); }, 700);
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
document.getElementById('reset').addEventListener('click', () => newGame());
|
| 119 |
+
newGame();
|
| 120 |
+
window.gameTest = {
|
| 121 |
+
reset(deck) { if (deck && deck.length !== 16) throw new Error('deck must contain 16 values'); newGame(deck); },
|
| 122 |
+
flip(index) { gridEl.children[index]?.click(); return this.state(); },
|
| 123 |
+
advance(ms) { if (pendingMismatch) { pendingMismatch.remaining -= ms; if (pendingMismatch.remaining <= 0) pendingMismatch.settle(); } return this.state(); },
|
| 124 |
+
state() { return { cards: [...gridEl.children].map(c => ({ value: c.dataset.symbol, faceUp: c.classList.contains('flip') || c.classList.contains('matched'), matched: c.classList.contains('matched') })), moves, matchedPairs }; }
|
| 125 |
+
};
|
| 126 |
+
</script>
|
| 127 |
+
</body>
|
| 128 |
+
</html>
|
task_002/solution/solve.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 4 |
+
TARGET="${1:-$(pwd)}"
|
| 5 |
+
cp -R "$SCRIPT_DIR/code/." "$TARGET/"
|
task_002/task.toml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "1.0"
|
| 2 |
+
|
| 3 |
+
[metadata]
|
| 4 |
+
|
| 5 |
+
[verifier]
|
| 6 |
+
timeout_sec = 300.0
|
| 7 |
+
|
| 8 |
+
[agent]
|
| 9 |
+
timeout_sec = 3600.0
|
| 10 |
+
|
| 11 |
+
[environment]
|
| 12 |
+
build_timeout_sec = 1200.0
|
| 13 |
+
cpus = 1
|
| 14 |
+
memory_mb = 2048
|
| 15 |
+
storage_mb = 10240
|
| 16 |
+
gpus = 0
|
| 17 |
+
allow_internet = true
|
| 18 |
+
|
| 19 |
+
[verifier.env]
|
| 20 |
+
|
| 21 |
+
[solution.env]
|
task_002/task_meta.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": 2,
|
| 3 |
+
"task_category": "frontend_development",
|
| 4 |
+
"origin_model": "GLM-4.6",
|
| 5 |
+
"sample_count": 5,
|
| 6 |
+
"user_turns": 4,
|
| 7 |
+
"language": "javascript",
|
| 8 |
+
"tool_files_from_selected_trace": [
|
| 9 |
+
"memory-game.html"
|
| 10 |
+
],
|
| 11 |
+
"input_assets": [],
|
| 12 |
+
"expected_outputs": [
|
| 13 |
+
"*.html"
|
| 14 |
+
],
|
| 15 |
+
"source_row_id": 12,
|
| 16 |
+
"repair_revision": "2026-09-29",
|
| 17 |
+
"instruction_sha256": "8ab065d0621c58492f4c34d00d09f4777ab4377cc82aaf5bd404085651992fe5"
|
| 18 |
+
}
|
task_002/tests/_shared/contract_checker.js
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs = require('fs');
|
| 2 |
+
const path = require('path');
|
| 3 |
+
const { chromium } = require('playwright');
|
| 4 |
+
|
| 5 |
+
const DEFAULT_TIMEOUT_MS = 12000;
|
| 6 |
+
|
| 7 |
+
function walk(dir) {
|
| 8 |
+
let out = [];
|
| 9 |
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
| 10 |
+
if (entry.name === 'tests' || entry.name === 'logs' || entry.name === 'node_modules') continue;
|
| 11 |
+
const p = path.join(dir, entry.name);
|
| 12 |
+
if (entry.isDirectory()) out = out.concat(walk(p));
|
| 13 |
+
else out.push(p);
|
| 14 |
+
}
|
| 15 |
+
return out;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
function stripNoisyComments(text) {
|
| 19 |
+
return text
|
| 20 |
+
.replace(/<!--([\s\S]*?)-->/g, ' ')
|
| 21 |
+
.replace(/\/\*([\s\S]*?)\*\//g, ' ')
|
| 22 |
+
.replace(/(^|[^:])\/\/.*$/gm, '$1 ')
|
| 23 |
+
.toLowerCase();
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
function readSourceText(taskDir) {
|
| 27 |
+
const exts = new Set(['.html', '.js', '.jsx', '.ts', '.tsx', '.css']);
|
| 28 |
+
const files = walk(taskDir).filter((file) => exts.has(path.extname(file).toLowerCase()));
|
| 29 |
+
if (files.length === 0) {
|
| 30 |
+
throw new Error('no source files found for semantic validation');
|
| 31 |
+
}
|
| 32 |
+
return files.map((f) => fs.readFileSync(f, 'utf8')).join('\n');
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
function hasAnyIn(text, list) {
|
| 36 |
+
return list.some((t) => text.includes(String(t).toLowerCase()));
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
function hasAll(text, list) {
|
| 40 |
+
return list.every((t) => text.includes(String(t).toLowerCase()));
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function escapedRegExp(token) {
|
| 44 |
+
return String(token).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function readContract(taskDir) {
|
| 48 |
+
const contractPath = path.join(taskDir, 'task_contract.json');
|
| 49 |
+
if (!fs.existsSync(contractPath)) {
|
| 50 |
+
throw new Error(`missing task_contract.json: ${contractPath}`);
|
| 51 |
+
}
|
| 52 |
+
return JSON.parse(fs.readFileSync(contractPath, 'utf8'));
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
function checkSemantics(contract, taskDir) {
|
| 56 |
+
const text = stripNoisyComments(readSourceText(taskDir));
|
| 57 |
+
const rules = contract.semantics || {};
|
| 58 |
+
const errors = [];
|
| 59 |
+
const warnings = [];
|
| 60 |
+
|
| 61 |
+
if (Array.isArray(rules.all) && rules.all.length && !hasAll(text, rules.all)) {
|
| 62 |
+
errors.push(`missing required semantic tokens: ${rules.all.join(', ')}`);
|
| 63 |
+
}
|
| 64 |
+
if (Array.isArray(rules.any) && rules.any.length && !hasAnyIn(text, rules.any)) {
|
| 65 |
+
errors.push(`missing any semantic tokens: ${rules.any.join(' | ')}`);
|
| 66 |
+
}
|
| 67 |
+
if (Array.isArray(rules.all_groups)) {
|
| 68 |
+
for (const group of rules.all_groups) {
|
| 69 |
+
if (!hasAnyIn(text, group)) {
|
| 70 |
+
errors.push(`missing required semantic group: ${group.join(' | ')}`);
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
if (rules.min_tokens && typeof rules.min_tokens === 'object') {
|
| 75 |
+
for (const [token, minCount] of Object.entries(rules.min_tokens)) {
|
| 76 |
+
const count = (text.match(new RegExp(escapedRegExp(token.toLowerCase()), 'g')) || []).length;
|
| 77 |
+
if (count < minCount) {
|
| 78 |
+
errors.push(`token "${token}" count ${count} < ${minCount}`);
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
if (contract.compat && contract.compat.minSourceBytes) {
|
| 83 |
+
// reserve compatibility pass for extremely small outputs
|
| 84 |
+
const files = walk(taskDir);
|
| 85 |
+
let total = 0;
|
| 86 |
+
for (const f of files) {
|
| 87 |
+
const stat = fs.statSync(f);
|
| 88 |
+
if (stat.isFile()) total += stat.size;
|
| 89 |
+
}
|
| 90 |
+
if (total < Number(contract.compat.minSourceBytes)) {
|
| 91 |
+
warnings.push(`source footprint small: ${total} bytes`);
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
return { strictOk: errors.length === 0, warnings, errors };
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
function pick(selectorList) {
|
| 99 |
+
return selectorList.filter(Boolean).join(', ');
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
async function gatherEntry(taskDir) {
|
| 103 |
+
const files = walk(taskDir);
|
| 104 |
+
const html = files.find((f) => f.toLowerCase().endsWith('.html'));
|
| 105 |
+
if (!html) throw new Error('no html entrypoint found');
|
| 106 |
+
return html;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
async function startBrowser(taskDir) {
|
| 110 |
+
const entry = await gatherEntry(taskDir);
|
| 111 |
+
const browser = await chromium.launch({
|
| 112 |
+
headless: true,
|
| 113 |
+
args: [
|
| 114 |
+
'--no-sandbox',
|
| 115 |
+
'--disable-dev-shm-usage',
|
| 116 |
+
'--disable-gpu'
|
| 117 |
+
]
|
| 118 |
+
});
|
| 119 |
+
const page = await browser.newPage({ viewport: { width: 1100, height: 760 } });
|
| 120 |
+
const errors = [];
|
| 121 |
+
page.on('pageerror', (err) => errors.push(err.message || String(err)));
|
| 122 |
+
page.on('console', (msg) => {
|
| 123 |
+
if (msg.type() === 'error') errors.push(msg.text());
|
| 124 |
+
});
|
| 125 |
+
await page.goto(pathToFileUrl(entry), { waitUntil: 'domcontentloaded' });
|
| 126 |
+
await page.waitForTimeout(250);
|
| 127 |
+
if (errors.length) {
|
| 128 |
+
await browser.close();
|
| 129 |
+
throw new Error('browser load errors: ' + errors.join(' | '));
|
| 130 |
+
}
|
| 131 |
+
return { browser, page, errors };
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
function pathToFileUrl(filePath) {
|
| 135 |
+
const abs = path.resolve(filePath);
|
| 136 |
+
return new URL('file://' + abs.replace(/\\/g, '/')).href;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
function assertStateDiff(before, after, message) {
|
| 140 |
+
if (before === after) {
|
| 141 |
+
throw new Error(message);
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
function toNumberText(v) {
|
| 146 |
+
return Number.parseInt(String(v || '0').replace(/[^\d.-]/g, ''), 10) || 0;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
async function checkGomoku(taskDir, config) {
|
| 150 |
+
const sel = config.selectors || {};
|
| 151 |
+
const cellsSel = pick([sel.cell, '.cell', '[data-r][data-c]']);
|
| 152 |
+
const statusSel = sel.status;
|
| 153 |
+
const resetSel = sel.reset;
|
| 154 |
+
|
| 155 |
+
const task = async () => {
|
| 156 |
+
const { browser, page } = await startBrowser(taskDir);
|
| 157 |
+
try {
|
| 158 |
+
const count = await page.locator(cellsSel).count();
|
| 159 |
+
if (count < 40) {
|
| 160 |
+
throw new Error('board-like grid should have at least 40 cells');
|
| 161 |
+
}
|
| 162 |
+
const before = await page.evaluate(({ cellsSel, statusSel }) => {
|
| 163 |
+
const cells = Array.from(document.querySelectorAll(cellsSel));
|
| 164 |
+
const status = statusSel ? (document.querySelector(statusSel)?.innerText || '') : '';
|
| 165 |
+
const occupied = cells.filter((c) => c.children.length > 0 || c.innerText.trim().length > 0).length;
|
| 166 |
+
const marker = cells.slice(0, 6).map((c) => c.className + '|' + c.innerText).join('||');
|
| 167 |
+
return { occupied, marker, status, count };
|
| 168 |
+
}, { cellsSel, statusSel });
|
| 169 |
+
const first = page.locator(cellsSel).nth(0);
|
| 170 |
+
const second = page.locator(cellsSel).nth(1);
|
| 171 |
+
await first.click({ force: true });
|
| 172 |
+
await page.waitForTimeout(120);
|
| 173 |
+
await second.click({ force: true });
|
| 174 |
+
await page.waitForTimeout(200);
|
| 175 |
+
const afterClicks = await page.evaluate(({ cellsSel, statusSel }) => {
|
| 176 |
+
const cells = Array.from(document.querySelectorAll(cellsSel));
|
| 177 |
+
const status = statusSel ? (document.querySelector(statusSel)?.innerText || '') : '';
|
| 178 |
+
const occupied = cells.filter((c) => c.children.length > 0 || c.innerText.trim().length > 0).length;
|
| 179 |
+
const marker = cells.slice(0, 6).map((c) => c.className + '|' + c.innerText).join('||');
|
| 180 |
+
return { occupied, marker, status, count: cells.length };
|
| 181 |
+
}, { cellsSel, statusSel });
|
| 182 |
+
if (before.occupied === afterClicks.occupied && before.marker === afterClicks.marker) {
|
| 183 |
+
throw new Error('clicking board cells does not alter board state');
|
| 184 |
+
}
|
| 185 |
+
if (resetSel) {
|
| 186 |
+
const resetCount = await page.locator(resetSel).count();
|
| 187 |
+
if (resetCount === 0) {
|
| 188 |
+
throw new Error('reset control not found');
|
| 189 |
+
}
|
| 190 |
+
await page.locator(resetSel).first().click({ force: true });
|
| 191 |
+
await page.waitForTimeout(250);
|
| 192 |
+
const afterReset = await page.evaluate(({ cellsSel, statusSel }) => {
|
| 193 |
+
const cells = Array.from(document.querySelectorAll(cellsSel));
|
| 194 |
+
const status = statusSel ? (document.querySelector(statusSel)?.innerText || '') : '';
|
| 195 |
+
const occupied = cells.filter((c) => c.children.length > 0 || c.innerText.trim().length > 0).length;
|
| 196 |
+
const marker = cells.slice(0, 6).map((c) => c.className + '|' + c.innerText).join('||');
|
| 197 |
+
return { occupied, marker, status, count: cells.length };
|
| 198 |
+
}, { cellsSel, statusSel });
|
| 199 |
+
if (afterClicks.occupied === afterReset.occupied && afterReset.marker === afterClicks.marker) {
|
| 200 |
+
throw new Error('reset does not restore board state');
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
await browser.close();
|
| 204 |
+
} catch (err) {
|
| 205 |
+
await browser.close();
|
| 206 |
+
throw err;
|
| 207 |
+
}
|
| 208 |
+
};
|
| 209 |
+
return task();
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
async function checkMemoryMatch(taskDir, config) {
|
| 213 |
+
const sel = config.selectors || {};
|
| 214 |
+
const cardSel = pick([sel.card, '.card', '[data-card]']);
|
| 215 |
+
const task = async () => {
|
| 216 |
+
const { browser, page } = await startBrowser(taskDir);
|
| 217 |
+
try {
|
| 218 |
+
const count = await page.locator(cardSel).count();
|
| 219 |
+
if (count < 8) {
|
| 220 |
+
throw new Error('not enough cards rendered');
|
| 221 |
+
}
|
| 222 |
+
const before = await page.evaluate((cardSel) => {
|
| 223 |
+
const cards = Array.from(document.querySelectorAll(cardSel));
|
| 224 |
+
return {
|
| 225 |
+
flipCount: cards.filter((c) => c.classList.contains('flip')).length,
|
| 226 |
+
matchedCount: cards.filter((c) => c.classList.contains('matched')).length,
|
| 227 |
+
moveText: (document.querySelector('#moves,#stats') || document.querySelector('body')).innerText,
|
| 228 |
+
};
|
| 229 |
+
}, cardSel);
|
| 230 |
+
|
| 231 |
+
// Read each card's symbol so we can drive a guaranteed-equal and a
|
| 232 |
+
// guaranteed-different pair instead of relying on the (shuffled) order.
|
| 233 |
+
const symbolAttr = sel.symbolAttr || 'data-symbol';
|
| 234 |
+
const symbols = await page.evaluate(({ cardSel, symbolAttr }) => {
|
| 235 |
+
return Array.from(document.querySelectorAll(cardSel)).map((c) => c.getAttribute(symbolAttr));
|
| 236 |
+
}, { cardSel, symbolAttr });
|
| 237 |
+
|
| 238 |
+
if (symbols.every((s) => s != null && s !== '')) {
|
| 239 |
+
// find a matching pair (same symbol) and a mismatching pair (different symbols)
|
| 240 |
+
let matchPair = null;
|
| 241 |
+
for (let i = 0; i < symbols.length && !matchPair; i++) {
|
| 242 |
+
for (let j = i + 1; j < symbols.length; j++) {
|
| 243 |
+
if (symbols[i] === symbols[j]) { matchPair = [i, j]; break; }
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
let diffPair = null;
|
| 247 |
+
for (let i = 0; i < symbols.length && !diffPair; i++) {
|
| 248 |
+
for (let j = i + 1; j < symbols.length; j++) {
|
| 249 |
+
if (symbols[i] !== symbols[j]) { diffPair = [i, j]; break; }
|
| 250 |
+
}
|
| 251 |
+
}
|
| 252 |
+
if (matchPair) {
|
| 253 |
+
await page.locator(cardSel).nth(matchPair[0]).click({ force: true });
|
| 254 |
+
await page.waitForTimeout(120);
|
| 255 |
+
await page.locator(cardSel).nth(matchPair[1]).click({ force: true });
|
| 256 |
+
await page.waitForTimeout(900);
|
| 257 |
+
const matchedOk = await page.evaluate(({ cardSel, pair }) => {
|
| 258 |
+
const cards = Array.from(document.querySelectorAll(cardSel));
|
| 259 |
+
return cards[pair[0]].classList.contains('matched') && cards[pair[1]].classList.contains('matched');
|
| 260 |
+
}, { cardSel, pair: matchPair });
|
| 261 |
+
if (!matchedOk) {
|
| 262 |
+
throw new Error('two equal-symbol cards should both gain the matched class');
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
// Fresh game for the mismatch trial: reload the page so card state is
|
| 266 |
+
// clean regardless of whether (or how) a reset control is implemented
|
| 267 |
+
// (the instruction never mandates a reset button or its id). If a reset
|
| 268 |
+
// control happens to exist, click it too as a best-effort re-init.
|
| 269 |
+
const resetSel = pick([
|
| 270 |
+
sel.reset,
|
| 271 |
+
'#reset',
|
| 272 |
+
'#restart',
|
| 273 |
+
'[data-testid="reset"]',
|
| 274 |
+
'[data-testid="restart"]',
|
| 275 |
+
]);
|
| 276 |
+
if (await page.locator(resetSel).count()) {
|
| 277 |
+
await page.locator(resetSel).first().click({ force: true }).catch(() => {});
|
| 278 |
+
await page.waitForTimeout(150);
|
| 279 |
+
}
|
| 280 |
+
await page.reload({ waitUntil: 'domcontentloaded' });
|
| 281 |
+
await page.waitForTimeout(350);
|
| 282 |
+
const symbols2 = await page.evaluate(({ cardSel, symbolAttr }) => {
|
| 283 |
+
return Array.from(document.querySelectorAll(cardSel)).map((c) => c.getAttribute(symbolAttr));
|
| 284 |
+
}, { cardSel, symbolAttr });
|
| 285 |
+
let diffPair2 = null;
|
| 286 |
+
for (let i = 0; i < symbols2.length && !diffPair2; i++) {
|
| 287 |
+
for (let j = i + 1; j < symbols2.length; j++) {
|
| 288 |
+
if (symbols2[i] !== symbols2[j]) { diffPair2 = [i, j]; break; }
|
| 289 |
+
}
|
| 290 |
+
}
|
| 291 |
+
const usePair = diffPair2 || diffPair;
|
| 292 |
+
if (usePair) {
|
| 293 |
+
await page.locator(cardSel).nth(usePair[0]).click({ force: true });
|
| 294 |
+
await page.waitForTimeout(120);
|
| 295 |
+
await page.locator(cardSel).nth(usePair[1]).click({ force: true });
|
| 296 |
+
await page.waitForTimeout(1100); // wait past the mismatch unflip delay
|
| 297 |
+
const mismatchOk = await page.evaluate(({ cardSel, pair }) => {
|
| 298 |
+
const cards = Array.from(document.querySelectorAll(cardSel));
|
| 299 |
+
return !cards[pair[0]].classList.contains('matched') && !cards[pair[1]].classList.contains('matched');
|
| 300 |
+
}, { cardSel, pair: usePair });
|
| 301 |
+
if (!mismatchOk) {
|
| 302 |
+
throw new Error('two different-symbol cards should not retain the matched class');
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
await browser.close();
|
| 306 |
+
return;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
// Fallback (no per-card symbol attr): generic "interaction changes state".
|
| 310 |
+
const first = page.locator(cardSel).nth(0);
|
| 311 |
+
const second = page.locator(cardSel).nth(1);
|
| 312 |
+
await first.click({ force: true });
|
| 313 |
+
await page.waitForTimeout(120);
|
| 314 |
+
await second.click({ force: true });
|
| 315 |
+
await page.waitForTimeout(700);
|
| 316 |
+
const after = await page.evaluate((cardSel) => {
|
| 317 |
+
const cards = Array.from(document.querySelectorAll(cardSel));
|
| 318 |
+
return {
|
| 319 |
+
flipCount: cards.filter((c) => c.classList.contains('flip')).length,
|
| 320 |
+
matchedCount: cards.filter((c) => c.classList.contains('matched')).length,
|
| 321 |
+
moveText: (document.querySelector('#moves,#stats') || document.querySelector('body')).innerText,
|
| 322 |
+
};
|
| 323 |
+
}, cardSel);
|
| 324 |
+
if (before.flipCount === after.flipCount && before.matchedCount === after.matchedCount && before.moveText === after.moveText) {
|
| 325 |
+
throw new Error('card interaction is not reflected in UI state');
|
| 326 |
+
}
|
| 327 |
+
await browser.close();
|
| 328 |
+
} catch (err) {
|
| 329 |
+
await browser.close();
|
| 330 |
+
throw err;
|
| 331 |
+
}
|
| 332 |
+
};
|
| 333 |
+
return task();
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
async function checkTowerDefense(taskDir, config) {
|
| 337 |
+
const sel = config.selectors || {};
|
| 338 |
+
const canvasSel = pick([sel.canvas, 'canvas', '#game']);
|
| 339 |
+
const spawnSel = pick([sel.spawn, '#spawn']);
|
| 340 |
+
const resetSel = pick([sel.reset, '#reset']);
|
| 341 |
+
const task = async () => {
|
| 342 |
+
const { browser, page } = await startBrowser(taskDir);
|
| 343 |
+
try {
|
| 344 |
+
const before = await page.evaluate((canvasSel) => {
|
| 345 |
+
const canvas = document.querySelector(canvasSel);
|
| 346 |
+
if (!canvas) return null;
|
| 347 |
+
let canvasSample = '';
|
| 348 |
+
try {
|
| 349 |
+
canvasSample = canvas.toDataURL().slice(0, 120);
|
| 350 |
+
} catch {
|
| 351 |
+
canvasSample = '';
|
| 352 |
+
}
|
| 353 |
+
return {
|
| 354 |
+
canvasSample,
|
| 355 |
+
hud: document.body ? document.body.innerText.replace(/\s+/g, ' ').trim() : '',
|
| 356 |
+
};
|
| 357 |
+
}, canvasSel);
|
| 358 |
+
if (!before) throw new Error('canvas not found');
|
| 359 |
+
const spawnCount = await page.locator(spawnSel).count();
|
| 360 |
+
if (spawnCount === 0) throw new Error('spawn control not found');
|
| 361 |
+
await page.locator(spawnSel).first().click({ force: true });
|
| 362 |
+
await page.waitForTimeout(900);
|
| 363 |
+
const afterSpawn = await page.evaluate((canvasSel) => {
|
| 364 |
+
const canvas = document.querySelector(canvasSel);
|
| 365 |
+
let canvasSample = '';
|
| 366 |
+
try {
|
| 367 |
+
canvasSample = canvas?.toDataURL().slice(0, 120) || '';
|
| 368 |
+
} catch {
|
| 369 |
+
canvasSample = '';
|
| 370 |
+
}
|
| 371 |
+
return {
|
| 372 |
+
canvasSample,
|
| 373 |
+
hud: document.body ? document.body.innerText.replace(/\s+/g, ' ').trim() : '',
|
| 374 |
+
};
|
| 375 |
+
}, canvasSel);
|
| 376 |
+
if (before.canvasSample === afterSpawn.canvasSample && before.hud === afterSpawn.hud) {
|
| 377 |
+
throw new Error('spawn action has no observable effect');
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
const canvas = page.locator(canvasSel);
|
| 381 |
+
const box = await canvas.boundingBox();
|
| 382 |
+
if (box) {
|
| 383 |
+
await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
| 384 |
+
await page.waitForTimeout(500);
|
| 385 |
+
}
|
| 386 |
+
const afterPlace = await page.evaluate((canvasSel) => {
|
| 387 |
+
const canvas = document.querySelector(canvasSel);
|
| 388 |
+
let canvasSample = '';
|
| 389 |
+
try {
|
| 390 |
+
canvasSample = canvas?.toDataURL().slice(0, 120) || '';
|
| 391 |
+
} catch {
|
| 392 |
+
canvasSample = '';
|
| 393 |
+
}
|
| 394 |
+
return {
|
| 395 |
+
canvasSample,
|
| 396 |
+
hud: document.body ? document.body.innerText.replace(/\s+/g, ' ').trim() : '',
|
| 397 |
+
};
|
| 398 |
+
}, canvasSel);
|
| 399 |
+
if (afterSpawn.canvasSample === afterPlace.canvasSample && afterSpawn.hud === afterPlace.hud) {
|
| 400 |
+
throw new Error('placing tower on canvas has no observable effect');
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
if (resetSel) {
|
| 404 |
+
const resetCount = await page.locator(resetSel).count();
|
| 405 |
+
if (resetCount > 0) {
|
| 406 |
+
await page.locator(resetSel).first().click({ force: true });
|
| 407 |
+
await page.waitForTimeout(250);
|
| 408 |
+
}
|
| 409 |
+
}
|
| 410 |
+
await browser.close();
|
| 411 |
+
} catch (err) {
|
| 412 |
+
await browser.close();
|
| 413 |
+
throw err;
|
| 414 |
+
}
|
| 415 |
+
};
|
| 416 |
+
return task();
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
async function checkLudo(taskDir, config) {
|
| 420 |
+
const sel = config.selectors || {};
|
| 421 |
+
const rollSel = pick([sel.roll, '#roll, button']);
|
| 422 |
+
const statusSel = sel.status || '#status';
|
| 423 |
+
const diceSel = sel.dice || '#dice';
|
| 424 |
+
const task = async () => {
|
| 425 |
+
const { browser, page } = await startBrowser(taskDir);
|
| 426 |
+
try {
|
| 427 |
+
const before = await page.evaluate(({ statusSel, diceSel }) => {
|
| 428 |
+
return {
|
| 429 |
+
status: statusSel ? (document.querySelector(statusSel)?.innerText || '') : '',
|
| 430 |
+
dice: diceSel ? (document.querySelector(diceSel)?.innerText || '') : '',
|
| 431 |
+
boardText: document.body ? document.body.innerText.replace(/\s+/g, ' ').trim() : '',
|
| 432 |
+
};
|
| 433 |
+
}, { statusSel, diceSel });
|
| 434 |
+
|
| 435 |
+
const rollCount = await page.locator(rollSel).count();
|
| 436 |
+
if (rollCount === 0) throw new Error('roll control not found');
|
| 437 |
+
for (let i = 0; i < 4; i++) {
|
| 438 |
+
await page.locator(rollSel).first().click({ force: true });
|
| 439 |
+
await page.waitForTimeout(220);
|
| 440 |
+
}
|
| 441 |
+
const after = await page.evaluate(({ statusSel, diceSel }) => {
|
| 442 |
+
return {
|
| 443 |
+
status: statusSel ? (document.querySelector(statusSel)?.innerText || '') : '',
|
| 444 |
+
dice: diceSel ? (document.querySelector(diceSel)?.innerText || '') : '',
|
| 445 |
+
boardText: document.body ? document.body.innerText.replace(/\s+/g, ' ').trim() : '',
|
| 446 |
+
};
|
| 447 |
+
}, { statusSel, diceSel });
|
| 448 |
+
if (before.status === after.status && before.dice === after.dice && before.boardText === after.boardText) {
|
| 449 |
+
throw new Error('turn + dice workflow has no state change');
|
| 450 |
+
}
|
| 451 |
+
await browser.close();
|
| 452 |
+
} catch (err) {
|
| 453 |
+
await browser.close();
|
| 454 |
+
throw err;
|
| 455 |
+
}
|
| 456 |
+
};
|
| 457 |
+
return task();
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
async function checkSpaceShooter(taskDir, config) {
|
| 461 |
+
const sel = config.selectors || {};
|
| 462 |
+
const canvasSel = pick([sel.canvas, 'canvas', '#space']);
|
| 463 |
+
const restartSel = pick([sel.restart, '#restart']);
|
| 464 |
+
const scoreSel = sel.score || '#score';
|
| 465 |
+
const hpSel = sel.hp || '#hp';
|
| 466 |
+
const task = async () => {
|
| 467 |
+
const { browser, page } = await startBrowser(taskDir);
|
| 468 |
+
try {
|
| 469 |
+
const before = await page.evaluate(({ canvasSel, scoreSel, hpSel }) => {
|
| 470 |
+
const canvas = document.querySelector(canvasSel);
|
| 471 |
+
if (!canvas) return null;
|
| 472 |
+
let canvasSample = '';
|
| 473 |
+
try {
|
| 474 |
+
canvasSample = canvas.toDataURL().slice(0, 140);
|
| 475 |
+
} catch {
|
| 476 |
+
canvasSample = '';
|
| 477 |
+
}
|
| 478 |
+
const scoreEl = document.querySelector(scoreSel);
|
| 479 |
+
const hpEl = document.querySelector(hpSel);
|
| 480 |
+
return {
|
| 481 |
+
canvasSample,
|
| 482 |
+
scoreText: scoreEl ? scoreEl.innerText : '',
|
| 483 |
+
hpText: hpEl ? hpEl.innerText : '',
|
| 484 |
+
};
|
| 485 |
+
}, { canvasSel, scoreSel, hpSel });
|
| 486 |
+
if (!before) throw new Error('canvas not found');
|
| 487 |
+
const canvas = page.locator(canvasSel).first();
|
| 488 |
+
await canvas.click({ force: true });
|
| 489 |
+
await page.keyboard.press('Space');
|
| 490 |
+
await page.keyboard.press('Space');
|
| 491 |
+
await page.keyboard.press('Space');
|
| 492 |
+
await page.waitForTimeout(500);
|
| 493 |
+
const after = await page.evaluate(({ canvasSel, scoreSel, hpSel }) => {
|
| 494 |
+
const canvas = document.querySelector(canvasSel);
|
| 495 |
+
let canvasSample = '';
|
| 496 |
+
try {
|
| 497 |
+
canvasSample = canvas?.toDataURL().slice(0, 140) || '';
|
| 498 |
+
} catch {
|
| 499 |
+
canvasSample = '';
|
| 500 |
+
}
|
| 501 |
+
const scoreEl = document.querySelector(scoreSel);
|
| 502 |
+
const hpEl = document.querySelector(hpSel);
|
| 503 |
+
return {
|
| 504 |
+
canvasSample,
|
| 505 |
+
scoreText: scoreEl ? scoreEl.innerText : '',
|
| 506 |
+
hpText: hpEl ? hpEl.innerText : '',
|
| 507 |
+
};
|
| 508 |
+
}, { canvasSel, scoreSel, hpSel });
|
| 509 |
+
if (before.canvasSample === after.canvasSample && before.scoreText === after.scoreText && before.hpText === after.hpText) {
|
| 510 |
+
throw new Error('shooting key interaction has no observable effect');
|
| 511 |
+
}
|
| 512 |
+
if (restartSel) {
|
| 513 |
+
const restartCount = await page.locator(restartSel).count();
|
| 514 |
+
if (restartCount > 0) {
|
| 515 |
+
await page.locator(restartSel).first().click({ force: true });
|
| 516 |
+
await page.waitForTimeout(250);
|
| 517 |
+
}
|
| 518 |
+
}
|
| 519 |
+
await browser.close();
|
| 520 |
+
} catch (err) {
|
| 521 |
+
await browser.close();
|
| 522 |
+
throw err;
|
| 523 |
+
}
|
| 524 |
+
};
|
| 525 |
+
return task();
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
const behaviorRunners = {
|
| 529 |
+
gomoku: checkGomoku,
|
| 530 |
+
memory_match: checkMemoryMatch,
|
| 531 |
+
tower_defense: checkTowerDefense,
|
| 532 |
+
ludo: checkLudo,
|
| 533 |
+
space_shooter: checkSpaceShooter,
|
| 534 |
+
};
|
| 535 |
+
|
| 536 |
+
async function runContractChecks({ taskDir, mode, contractDir }) {
|
| 537 |
+
const contract = readContract(contractDir || taskDir);
|
| 538 |
+
if (mode === 'semantics' || mode === 'full') {
|
| 539 |
+
const semantic = checkSemantics(contract, taskDir);
|
| 540 |
+
if (semantic.warnings.length) {
|
| 541 |
+
console.log(JSON.stringify({ mode: 'semantics', task_id: contract.task_id, strict: semantic.strictOk, compat: semantic.warnings.length === 0, warnings: semantic.warnings }));
|
| 542 |
+
}
|
| 543 |
+
if (!semantic.strictOk) {
|
| 544 |
+
throw new Error('semantic checks failed: ' + semantic.errors.join(' | '));
|
| 545 |
+
}
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
if (mode === 'browser' || mode === 'full') {
|
| 549 |
+
const browserType = (contract.browser || {}).type;
|
| 550 |
+
const runner = behaviorRunners[browserType];
|
| 551 |
+
if (!runner) throw new Error(`unknown browser behavior type: ${browserType}`);
|
| 552 |
+
await runner(taskDir, contract.browser || {});
|
| 553 |
+
}
|
| 554 |
+
|
| 555 |
+
console.log(JSON.stringify({ mode, task_id: contract.task_id, strict: true, compat: true }));
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
if (require.main === module) {
|
| 559 |
+
(async () => {
|
| 560 |
+
const args = Object.fromEntries(
|
| 561 |
+
process.argv.slice(2).map((arg, idx, all) => {
|
| 562 |
+
if (!arg.startsWith('--')) return null;
|
| 563 |
+
const key = arg.slice(2);
|
| 564 |
+
const value = all[idx + 1] && !all[idx + 1].startsWith('--') ? all[idx + 1] : 'true';
|
| 565 |
+
return [key, value];
|
| 566 |
+
}).filter(Boolean)
|
| 567 |
+
);
|
| 568 |
+
const taskDir = args['task-dir'] ? path.resolve(args['task-dir']) : process.cwd();
|
| 569 |
+
const mode = args.mode || 'full';
|
| 570 |
+
await runContractChecks({ taskDir, mode });
|
| 571 |
+
})().catch((err) => {
|
| 572 |
+
console.error(err && err.stack ? err.stack : String(err));
|
| 573 |
+
process.exit(1);
|
| 574 |
+
});
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
module.exports = { runContractChecks };
|
task_002/tests/_shared/static_enhancer.sh
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# Behavioral validators own scoring; no source-length or lexical proxy gates.
|
| 3 |
+
static_enhance_check() { return 0; }
|
task_002/tests/enhancement_cases.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{"case_id":"ENHANCED_CASE_1","instruction_evidence":"用4x4的卡牌网格","validator":"validate_enhanced_cases.js","behavior":"页面提供恰好16张可交互卡牌"},
|
| 3 |
+
{"case_id":"ENHANCED_CASE_2","instruction_evidence":"实现卡牌翻转动画","validator":"validate_enhanced_cases.js","behavior":"点击背面卡牌产生可见翻转状态"},
|
| 4 |
+
{"case_id":"ENHANCED_CASE_3","instruction_evidence":"基本匹配逻辑","validator":"validate_enhanced_cases.js","behavior":"两张同面卡牌配对后保持已匹配可见状态"}
|
| 5 |
+
]
|
task_002/tests/pixel_changes.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Locate a rendered transition without prescribing an HTML class, fixed device
|
| 2 |
+
// coordinate or even whether it is painted in a canvas.
|
| 3 |
+
async function pixelChanges(page, frames) {
|
| 4 |
+
return page.evaluate(async encoded => {
|
| 5 |
+
const images = await Promise.all(encoded.map(async source => {
|
| 6 |
+
const image = new Image();
|
| 7 |
+
image.src = 'data:image/png;base64,' + source;
|
| 8 |
+
await image.decode();
|
| 9 |
+
return image;
|
| 10 |
+
}));
|
| 11 |
+
const {width, height} = images[0];
|
| 12 |
+
const canvas = document.createElement('canvas');
|
| 13 |
+
canvas.width = width;
|
| 14 |
+
canvas.height = height;
|
| 15 |
+
const context = canvas.getContext('2d', {willReadFrequently: true});
|
| 16 |
+
const pixels = images.map(image => {
|
| 17 |
+
context.clearRect(0, 0, width, height);
|
| 18 |
+
context.drawImage(image, 0, 0);
|
| 19 |
+
return context.getImageData(0, 0, width, height).data;
|
| 20 |
+
});
|
| 21 |
+
const different = (a, b, i) => Math.max(
|
| 22 |
+
Math.abs(a[i] - b[i]), Math.abs(a[i + 1] - b[i + 1]), Math.abs(a[i + 2] - b[i + 2]),
|
| 23 |
+
) >= 16;
|
| 24 |
+
const tile = 8;
|
| 25 |
+
const columns = Math.ceil(width / tile);
|
| 26 |
+
const points = Array.from({length: columns * Math.ceil(height / tile)}, () => [0, 0, 0]);
|
| 27 |
+
let novel = 0;
|
| 28 |
+
for (let y = 0; y < height; y++) {
|
| 29 |
+
for (let x = 0; x < width; x++) {
|
| 30 |
+
const i = (y * width + x) * 4;
|
| 31 |
+
if (!different(pixels[0], pixels[1], i)) continue;
|
| 32 |
+
const bucket = points[Math.floor(y / tile) * columns + Math.floor(x / tile)];
|
| 33 |
+
bucket[0] += 1;
|
| 34 |
+
bucket[1] += x;
|
| 35 |
+
bucket[2] += y;
|
| 36 |
+
if (pixels.length === 4
|
| 37 |
+
&& (!different(pixels[2], pixels[3], i) || different(pixels[1], pixels[3], i))) novel += 1;
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
return {
|
| 41 |
+
points: points.filter(([weight]) => weight > 0)
|
| 42 |
+
.sort(([a], [b]) => b - a).slice(0, 56)
|
| 43 |
+
.map(([weight, x, y]) => ({x: x / weight, y: y / weight})),
|
| 44 |
+
novel,
|
| 45 |
+
};
|
| 46 |
+
}, frames.map(frame => frame.toString('base64')));
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
module.exports = {pixelChanges};
|
task_002/tests/task_contract.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": 2,
|
| 3 |
+
"semantics": {
|
| 4 |
+
"all": ["flip", "match", "card"],
|
| 5 |
+
"any": ["4x4", "16", "grid-template-columns"],
|
| 6 |
+
"all_groups": [["match", "flip"], ["card", "cards"], ["button", "addEventListener", "onclick"]],
|
| 7 |
+
"min_tokens": {
|
| 8 |
+
"card": 1
|
| 9 |
+
},
|
| 10 |
+
"compat": {
|
| 11 |
+
"minSourceBytes": 500
|
| 12 |
+
}
|
| 13 |
+
},
|
| 14 |
+
"browser": {
|
| 15 |
+
"type": "memory_match",
|
| 16 |
+
"selectors": {
|
| 17 |
+
"card": ".card",
|
| 18 |
+
"reset": "#reset"
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
}
|
task_002/tests/test.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -uo pipefail
|
| 3 |
+
TEST_DIR="$(cd "$(dirname "$0")" && pwd)"
|
| 4 |
+
LOG_DIR=/logs/verifier
|
| 5 |
+
mkdir -p "$LOG_DIR" 2>/dev/null || { LOG_DIR="$PWD/logs/verifier"; mkdir -p "$LOG_DIR"; }
|
| 6 |
+
REWARD_FILE="$LOG_DIR/reward.txt"
|
| 7 |
+
echo 0 > "$REWARD_FILE"
|
| 8 |
+
run() { timeout 90s node "$TEST_DIR/$1"; }
|
| 9 |
+
PASS=1
|
| 10 |
+
run validate_semantics.js || PASS=0
|
| 11 |
+
run validate_browser_smoke.js || PASS=0
|
| 12 |
+
run validate_enhanced_cases.js || PASS=0
|
| 13 |
+
echo "$PASS" > "$REWARD_FILE"
|
task_002/tests/validate_aaav_dynamic.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs = require('fs');
|
| 2 |
+
const path = require('path');
|
| 3 |
+
const { pathToFileURL } = require('url');
|
| 4 |
+
const { chromium } = require('playwright');
|
| 5 |
+
|
| 6 |
+
const TASK_ID = 2;
|
| 7 |
+
const KIND = "browser";
|
| 8 |
+
const TESTIDS = [];
|
| 9 |
+
const HAS_QUESTION_WORKFLOW = false;
|
| 10 |
+
const SKIP_DIRS = new Set([
|
| 11 |
+
"tests",
|
| 12 |
+
"logs",
|
| 13 |
+
"node_modules",
|
| 14 |
+
".git"
|
| 15 |
+
]);
|
| 16 |
+
|
| 17 |
+
function assert(condition, message) {
|
| 18 |
+
if (!condition) throw new Error(message);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
function walk(dir) {
|
| 22 |
+
let out = [];
|
| 23 |
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
| 24 |
+
if (SKIP_DIRS.has(entry.name)) continue;
|
| 25 |
+
const p = path.join(dir, entry.name);
|
| 26 |
+
if (entry.isDirectory()) out = out.concat(walk(p));
|
| 27 |
+
else out.push(p);
|
| 28 |
+
}
|
| 29 |
+
return out;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
function findEntry() {
|
| 33 |
+
const files = walk(process.cwd());
|
| 34 |
+
if (KIND === 'svg') return files.find(f => f.toLowerCase().endsWith('.svg'));
|
| 35 |
+
return files.find(f => f.toLowerCase().endsWith('.html')) || files.find(f => f.toLowerCase().endsWith('.svg'));
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
async function snapshot(page) {
|
| 39 |
+
return await page.evaluate(() => JSON.stringify({
|
| 40 |
+
text: document.body?.innerText || '',
|
| 41 |
+
htmlLength: document.body?.innerHTML?.length || 0,
|
| 42 |
+
controls: document.querySelectorAll('button,[role="button"],input,select,textarea,canvas,svg,a[href]').length,
|
| 43 |
+
storage: window.localStorage ? window.localStorage.length : 0,
|
| 44 |
+
canvas: Array.from(document.querySelectorAll('canvas')).map(c => {
|
| 45 |
+
try { return c.toDataURL().slice(0, 80); } catch { return ''; }
|
| 46 |
+
}),
|
| 47 |
+
}));
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
async function runQuestionWorkflow(page) {
|
| 51 |
+
const input = page.locator('[data-testid="question-input"]');
|
| 52 |
+
const upload = page.locator('[data-testid="upload-question"]');
|
| 53 |
+
const items = page.locator('[data-testid="question-item"]');
|
| 54 |
+
const before = await items.count();
|
| 55 |
+
const text = 'AAAV dynamic question ' + Date.now();
|
| 56 |
+
await input.fill(text);
|
| 57 |
+
await upload.click();
|
| 58 |
+
await page.waitForTimeout(150);
|
| 59 |
+
assert(await items.count() > before, 'upload-question should add a question item');
|
| 60 |
+
const first = items.first();
|
| 61 |
+
if (await first.locator('[data-testid="offline-question"]').count()) {
|
| 62 |
+
const oldStatus = await first.getAttribute('data-status');
|
| 63 |
+
await first.locator('[data-testid="offline-question"]').click();
|
| 64 |
+
await page.waitForTimeout(100);
|
| 65 |
+
assert(oldStatus !== await first.getAttribute('data-status'), 'offline-question should toggle data-status');
|
| 66 |
+
}
|
| 67 |
+
if (await first.locator('[data-testid="edit-question"]').count()) {
|
| 68 |
+
await first.locator('[data-testid="edit-question"]').click();
|
| 69 |
+
await page.waitForTimeout(100);
|
| 70 |
+
assert(await first.getAttribute('data-edited') === 'true', 'edit-question should mark item as edited');
|
| 71 |
+
}
|
| 72 |
+
if (await page.locator('[data-testid="role-select"]').count()) {
|
| 73 |
+
await page.locator('[data-testid="role-select"]').selectOption('normal user').catch(() => {});
|
| 74 |
+
await page.waitForTimeout(100);
|
| 75 |
+
assert(!(await page.locator('[data-testid="delete-question"]').first().isVisible().catch(() => false)), 'delete should hide for normal user');
|
| 76 |
+
await page.locator('[data-testid="role-select"]').selectOption('admin').catch(() => {});
|
| 77 |
+
await page.waitForTimeout(100);
|
| 78 |
+
assert(await page.locator('[data-testid="delete-question"]').first().isVisible().catch(() => false), 'delete should show for admin');
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
(async () => {
|
| 83 |
+
const entry = findEntry();
|
| 84 |
+
assert(entry, 'no browser-openable entrypoint found');
|
| 85 |
+
const launchArgs = (process.env.PLAYWRIGHT_LAUNCH_ARGS || process.env.PW_LAUNCH_ARGS || "--no-sandbox --disable-setuid-sandbox --disable-dev-shm-usage").split(/\s+/).filter(Boolean);
|
| 86 |
+
const browser = await chromium.launch({ headless: true, args: launchArgs });
|
| 87 |
+
const page = await browser.newPage({ viewport: { width: 1100, height: 760 } });
|
| 88 |
+
const errors = [];
|
| 89 |
+
page.on('pageerror', err => errors.push(err.message));
|
| 90 |
+
page.on('console', msg => { if (msg.type() === 'error') errors.push(msg.text()); });
|
| 91 |
+
await page.goto(pathToFileURL(entry).href, { waitUntil: 'domcontentloaded' });
|
| 92 |
+
await page.waitForTimeout(500);
|
| 93 |
+
assert(errors.length === 0, 'browser errors on load: ' + errors.join(' | '));
|
| 94 |
+
|
| 95 |
+
if (KIND === 'svg') {
|
| 96 |
+
const stats = await page.evaluate(() => ({
|
| 97 |
+
svg: document.querySelectorAll('svg').length,
|
| 98 |
+
elems: document.querySelectorAll('svg *').length,
|
| 99 |
+
text: (document.body?.innerText || '').trim().length,
|
| 100 |
+
}));
|
| 101 |
+
assert(stats.svg >= 1, 'svg task should render an svg root');
|
| 102 |
+
assert(stats.elems >= 2 || stats.text >= 5, 'svg task should render visible structure');
|
| 103 |
+
} else {
|
| 104 |
+
const stats = await page.evaluate(() => ({
|
| 105 |
+
visible: Array.from(document.querySelectorAll('body *')).filter(el => {
|
| 106 |
+
const r = el.getBoundingClientRect();
|
| 107 |
+
const s = getComputedStyle(el);
|
| 108 |
+
return r.width > 0 && r.height > 0 && s.visibility !== 'hidden' && s.display !== 'none';
|
| 109 |
+
}).length,
|
| 110 |
+
text: (document.body?.innerText || '').trim().length,
|
| 111 |
+
controls: document.querySelectorAll('button,[role="button"],input,select,textarea,canvas,svg,a[href]').length,
|
| 112 |
+
}));
|
| 113 |
+
assert(stats.visible >= 3 || stats.text >= 20, 'page should render meaningful visible content');
|
| 114 |
+
|
| 115 |
+
for (const id of TESTIDS) {
|
| 116 |
+
const count = await page.locator(`[data-testid="${id}"]`).count();
|
| 117 |
+
assert(count > 0, `missing required data-testid: ${id}`);
|
| 118 |
+
}
|
| 119 |
+
if (HAS_QUESTION_WORKFLOW) await runQuestionWorkflow(page);
|
| 120 |
+
|
| 121 |
+
const controls = await page.$$('button,[role="button"],input,select,textarea,canvas,svg,a[href]');
|
| 122 |
+
if (controls.length) {
|
| 123 |
+
const before = await snapshot(page);
|
| 124 |
+
for (const control of controls.slice(0, 6)) {
|
| 125 |
+
const tag = await control.evaluate(el => el.tagName.toLowerCase()).catch(() => '');
|
| 126 |
+
if (tag === 'input' || tag === 'textarea') await control.fill('aaav-dynamic-input').catch(() => {});
|
| 127 |
+
else if (tag === 'select') {
|
| 128 |
+
const value = await control.evaluate(el => Array.from(el.options || [])[1]?.value || Array.from(el.options || [])[0]?.value || '').catch(() => '');
|
| 129 |
+
if (value) await control.selectOption(value).catch(() => {});
|
| 130 |
+
} else {
|
| 131 |
+
await control.click({ force: true }).catch(() => {});
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
await page.keyboard.press('Enter').catch(() => {});
|
| 135 |
+
await page.keyboard.press('Space').catch(() => {});
|
| 136 |
+
await page.waitForTimeout(200);
|
| 137 |
+
await snapshot(page);
|
| 138 |
+
// State changes are informative but not mandatory: static dashboards and
|
| 139 |
+
// diagrams may be valid even when generic clicks do not mutate state.
|
| 140 |
+
void before;
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
assert(errors.length === 0, 'browser errors after interaction: ' + errors.join(' | '));
|
| 144 |
+
await browser.close();
|
| 145 |
+
console.log(`AAAV targeted dynamic test passed for task ${TASK_ID}`);
|
| 146 |
+
})().catch(err => {
|
| 147 |
+
console.error(err && err.stack || err);
|
| 148 |
+
process.exit(1);
|
| 149 |
+
});
|
task_002/tests/validate_browser_smoke.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs=require('fs'),path=require('path'),{pathToFileURL}=require('url'),{chromium}=require('playwright');
|
| 2 |
+
function walk(d){return fs.readdirSync(d,{withFileTypes:true}).filter(e=>!['tests','logs','node_modules','.git'].includes(e.name)).flatMap(e=>e.isDirectory()?walk(path.join(d,e.name)):[path.join(d,e.name)])}
|
| 3 |
+
(async()=>{const entry=walk(process.cwd()).find(f=>/\.(html|svg)$/i.test(f));if(!entry)throw Error('missing browser entry');
|
| 4 |
+
const b=await chromium.launch({headless:true,args:['--no-sandbox','--disable-dev-shm-usage']});try{const p=await b.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));await p.route(/^https?:/,r=>r.abort());await p.goto(pathToFileURL(entry).href,{waitUntil:'load'});
|
| 5 |
+
if(!await p.evaluate(()=>[...document.querySelectorAll('body *,svg')].some(e=>{const r=e.getBoundingClientRect(),s=getComputedStyle(e);return r.width>0&&r.height>0&&s.display!=='none'&&s.visibility!=='hidden'})))throw Error('entry does not render');
|
| 6 |
+
if(errors.length)throw Error(errors.join(' | '));console.log('render smoke passed');}finally{await b.close()}})().catch(e=>{console.error(e);process.exit(1)});
|
task_002/tests/validate_enhanced_cases.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs = require('fs');
|
| 2 |
+
const path = require('path');
|
| 3 |
+
const {pathToFileURL} = require('url');
|
| 4 |
+
const {chromium} = require('playwright');
|
| 5 |
+
const {pixelChanges} = require('./pixel_changes');
|
| 6 |
+
const assert = (value, message) => { if (!value) throw Error(message); };
|
| 7 |
+
const entry = 'index.html';
|
| 8 |
+
|
| 9 |
+
(async () => {
|
| 10 |
+
assert(fs.existsSync(entry), 'missing public index.html entry');
|
| 11 |
+
const browser = await chromium.launch({headless: true, args: ['--no-sandbox']});
|
| 12 |
+
try {
|
| 13 |
+
const page = await browser.newPage({viewport: {width: 1280, height: 1000}});
|
| 14 |
+
const image = await browser.newPage();
|
| 15 |
+
await page.clock.install({time: new Date('2026-01-01T00:00:00Z')});
|
| 16 |
+
await page.clock.pauseAt(new Date('2026-01-01T00:00:01Z'));
|
| 17 |
+
await page.goto(pathToFileURL(path.join(process.cwd(), entry)).href);
|
| 18 |
+
const deck = ['A','B','A','B','C','C','D','D','E','E','F','F','G','G','H','H'];
|
| 19 |
+
const state = () => page.evaluate(() => gameTest.state());
|
| 20 |
+
const flip = index => page.evaluate(i => gameTest.flip(i), index);
|
| 21 |
+
const advance = ms => page.evaluate(t => gameTest.advance(t), ms);
|
| 22 |
+
await page.evaluate(d => gameTest.reset(d), deck);
|
| 23 |
+
let current = await state();
|
| 24 |
+
assert(current.cards.length === 16 && current.cards.every((card, index) => card.value === deck[index] && !card.faceUp && !card.matched), 'reset must preserve deck order and hide all cards');
|
| 25 |
+
assert(current.moves === 0 && current.matchedPairs === 0, 'reset counters must be zero');
|
| 26 |
+
|
| 27 |
+
// Two one-card states have the same counters and selected position but
|
| 28 |
+
// different underlying values. A highlight-only "flip" cannot pass.
|
| 29 |
+
const covered = await page.screenshot({animations: 'disabled'});
|
| 30 |
+
await flip(0); await page.waitForTimeout(450);
|
| 31 |
+
const firstFace = await page.screenshot({animations: 'disabled'});
|
| 32 |
+
const swapped = [...deck]; [swapped[0], swapped[1]] = [swapped[1], swapped[0]];
|
| 33 |
+
await page.evaluate(d => gameTest.reset(d), swapped);
|
| 34 |
+
await flip(0); await page.waitForTimeout(450);
|
| 35 |
+
const secondFace = await page.screenshot({animations: 'disabled'});
|
| 36 |
+
assert(!firstFace.equals(secondFace), 'logical card flips did not reveal the card value');
|
| 37 |
+
const {points} = await pixelChanges(image, [covered, firstFace]);
|
| 38 |
+
let userFlip = false;
|
| 39 |
+
let animated = false;
|
| 40 |
+
for (const {x, y} of points) {
|
| 41 |
+
await page.evaluate(d => gameTest.reset(d), deck);
|
| 42 |
+
await page.mouse.move(x, y);
|
| 43 |
+
const clip = {x: Math.max(0, Math.floor(x) - 20), y: Math.max(0, Math.floor(y) - 20),
|
| 44 |
+
width: 40, height: 40};
|
| 45 |
+
const beforeMotion = await page.evaluateHandle(({x, y}) => {
|
| 46 |
+
const current = new Set(document.getAnimations().filter(animation => {
|
| 47 |
+
const bounds = animation.effect?.target?.getBoundingClientRect();
|
| 48 |
+
return animation.playState === 'running' && bounds && x >= bounds.left && x <= bounds.right
|
| 49 |
+
&& y >= bounds.top && y <= bounds.bottom;
|
| 50 |
+
}));
|
| 51 |
+
for (const animation of current) animation.pause();
|
| 52 |
+
return current;
|
| 53 |
+
}, {x, y});
|
| 54 |
+
const before = await page.screenshot({clip, animations: 'allow'});
|
| 55 |
+
await page.mouse.click(x, y);
|
| 56 |
+
const clicked = await state();
|
| 57 |
+
if (!clicked.cards[0].faceUp || clicked.cards.filter(card => card.faceUp).length !== 1) {
|
| 58 |
+
await beforeMotion.evaluate(previous => { for (const animation of previous) animation.play(); });
|
| 59 |
+
await beforeMotion.dispose();
|
| 60 |
+
continue;
|
| 61 |
+
}
|
| 62 |
+
userFlip = true;
|
| 63 |
+
animated = await page.evaluate(({x, y, previous}) => document.getAnimations().some(animation => {
|
| 64 |
+
const bounds = animation.effect?.target?.getBoundingClientRect();
|
| 65 |
+
return !previous.has(animation) && animation.playState === 'running' && bounds && x >= bounds.left && x <= bounds.right
|
| 66 |
+
&& y >= bounds.top && y <= bounds.bottom;
|
| 67 |
+
}), {x, y, previous: beforeMotion});
|
| 68 |
+
await beforeMotion.dispose();
|
| 69 |
+
if (!animated) {
|
| 70 |
+
const during = [];
|
| 71 |
+
for (const elapsed of [0, 16, 32, 64, 128, 256, 512]) {
|
| 72 |
+
await page.clock.runFor(elapsed);
|
| 73 |
+
during.push(await page.screenshot({clip, animations: 'allow'}));
|
| 74 |
+
}
|
| 75 |
+
const after = during.at(-1);
|
| 76 |
+
animated = during.some(frame => !frame.equals(before) && !frame.equals(after));
|
| 77 |
+
}
|
| 78 |
+
break;
|
| 79 |
+
}
|
| 80 |
+
assert(userFlip, 'clicking the rendered card must flip the same card tracked by the game');
|
| 81 |
+
assert(animated, 'user flips must produce an observable card animation');
|
| 82 |
+
await page.evaluate(d => gameTest.reset(d), deck);
|
| 83 |
+
|
| 84 |
+
await flip(0);
|
| 85 |
+
current = await state();
|
| 86 |
+
assert(current.cards[0].faceUp && current.moves === 0, 'first flip must not count a move');
|
| 87 |
+
await flip(0);
|
| 88 |
+
assert(JSON.stringify(await state()) === JSON.stringify(current), 're-flipping same card changed state');
|
| 89 |
+
await flip(1);
|
| 90 |
+
current = await state();
|
| 91 |
+
assert(current.cards[0].faceUp && current.cards[1].faceUp && current.moves === 1 && current.matchedPairs === 0, 'mismatch must stay visible and count one move');
|
| 92 |
+
await flip(4);
|
| 93 |
+
assert(JSON.stringify(await state()) === JSON.stringify(current), 'third card flipped during mismatch lock');
|
| 94 |
+
await advance(299);
|
| 95 |
+
current = await state();
|
| 96 |
+
assert(current.cards[0].faceUp && current.cards[1].faceUp, 'mismatch delay was shorter than 300ms');
|
| 97 |
+
await advance(1701);
|
| 98 |
+
current = await state();
|
| 99 |
+
assert(!current.cards[0].faceUp && !current.cards[1].faceUp && current.moves === 1, 'mismatch did not flip back without extra move');
|
| 100 |
+
|
| 101 |
+
await flip(0);
|
| 102 |
+
await flip(2);
|
| 103 |
+
await advance(1000);
|
| 104 |
+
current = await state();
|
| 105 |
+
assert(current.cards[0].matched && current.cards[2].matched && current.cards[0].faceUp && current.cards[2].faceUp, 'match must remain face up');
|
| 106 |
+
assert(current.moves === 2 && current.matchedPairs === 1, 'match counters wrong');
|
| 107 |
+
await flip(0);
|
| 108 |
+
assert(JSON.stringify(await state()) === JSON.stringify(current), 'matched card was flipped again');
|
| 109 |
+
await flip(1);
|
| 110 |
+
await flip(3);
|
| 111 |
+
current = await state();
|
| 112 |
+
assert(current.matchedPairs === 2 && current.moves === 3, 'second pair counters wrong');
|
| 113 |
+
for (let i = 4; i < 16; i += 2) {
|
| 114 |
+
await flip(i); await flip(i + 1);
|
| 115 |
+
}
|
| 116 |
+
current = await state();
|
| 117 |
+
assert(current.matchedPairs === 8 && current.moves === 9
|
| 118 |
+
&& current.cards.every(card => card.faceUp && card.matched), 'all eight pairs must be matchable');
|
| 119 |
+
await page.evaluate(d => gameTest.reset(d), deck);
|
| 120 |
+
current = await state();
|
| 121 |
+
assert(current.moves === 0 && current.matchedPairs === 0 && current.cards.every(card => !card.faceUp && !card.matched), 'reset after matches did not clear state');
|
| 122 |
+
await flip(0); await flip(1);
|
| 123 |
+
await page.evaluate(d => gameTest.reset(d), deck);
|
| 124 |
+
await flip(4); await flip(5);
|
| 125 |
+
await advance(2500);
|
| 126 |
+
current = await state();
|
| 127 |
+
assert(current.moves === 1 && current.matchedPairs === 1
|
| 128 |
+
&& current.cards[4].faceUp && current.cards[5].faceUp,
|
| 129 |
+
'stale mismatch state affected the new game');
|
| 130 |
+
console.log('memory-game deck, mismatch lock, time and counter checks passed');
|
| 131 |
+
} finally {
|
| 132 |
+
await browser.close();
|
| 133 |
+
}
|
| 134 |
+
})().catch(error => { console.error(error); process.exit(1); });
|
task_002/tests/validate_semantics.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const fs=require('fs'),path=require('path');
|
| 2 |
+
function walk(d){return fs.readdirSync(d,{withFileTypes:true}).filter(e=>!['tests','logs','node_modules','.git'].includes(e.name)).flatMap(e=>e.isDirectory()?walk(path.join(d,e.name)):[path.join(d,e.name)])}
|
| 3 |
+
if(!walk(process.cwd()).some(f=>/\.(html|svg|js|ts|tsx|jsx|md)$/i.test(f)))throw Error('missing candidate output');
|
| 4 |
+
console.log('candidate output present; requirements checked by runtime cases');
|
task_003/acceptance_checklist.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"task_id": 3,
|
| 3 |
+
"category": "frontend_development",
|
| 4 |
+
"language": "javascript",
|
| 5 |
+
"acceptance_items": [
|
| 6 |
+
"Implements the user-visible behavior described in the prompt, not only the file structure from a sample trajectory.",
|
| 7 |
+
"Keeps the solution runnable without internet access unless the task explicitly provides dependencies."
|
| 8 |
+
],
|
| 9 |
+
"input_assets": [],
|
| 10 |
+
"expected_outputs": [
|
| 11 |
+
"*.html"
|
| 12 |
+
],
|
| 13 |
+
"risk_notes": [
|
| 14 |
+
"This task came from a multi-turn trajectory; the enhanced instruction preserves all user turns."
|
| 15 |
+
],
|
| 16 |
+
"verifier_style": "deterministic runtime behavior and published artifact/protocol checks",
|
| 17 |
+
"repair_revision": "2026-09-29"
|
| 18 |
+
}
|
task_003/environment/Dockerfile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# syntax=docker/dockerfile:1.7-labs
|
| 2 |
+
FROM mcr.microsoft.com/playwright:v1.52.0-noble@sha256:a021500a801bab0611049217ffad6b9697d827205c15babb86a53bc1a61c02d5
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
COPY ./code /app
|
| 5 |
+
|
| 6 |
+
# Benchmark fix: the mcr/playwright base ships browsers but NOT the `playwright`
|
| 7 |
+
# npm package, so the verifier's require('playwright') threw MODULE_NOT_FOUND.
|
| 8 |
+
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
| 9 |
+
RUN npm install -g playwright@1.52.0
|
| 10 |
+
ENV NODE_PATH=/usr/lib/node_modules
|
task_003/environment/code/.gitkeep
ADDED
|
File without changes
|