Datasets:
Download data/scenarios.jsonl from YuyaoGe/doc2harness: direct link, hf CLI and curl.
- Browser
- Download file 331 kB
-
https://huggingface.co/datasets/YuyaoGe/doc2harness/resolve/main/data/scenarios.jsonl
- Command line
-
hf download hf://datasets/YuyaoGe/doc2harness/data/scenarios.jsonl
-
curl -L -o scenarios.jsonl https://huggingface.co/datasets/YuyaoGe/doc2harness/resolve/main/data/scenarios.jsonl
331 kB
| {"scenario_id": "artifact_declares_dependencies", "family": "artifact", "category": "artifact checks", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Verify the artifact declares its runtime dependencies.", "description": "Verify the artifact declares its runtime dependencies.\n\n1. Inspect the declared dependency metadata.\n2. Capture the expected logical artifact path.\n3. Apply the typed artifact oracle and require a valid declaration.", "source_path": "src/doc2harness/benchmark/harnesses/artifact/scenarios/artifact_declares_dependencies.py", "source_code": "\"\"\"Verify the artifact declares its runtime dependencies.\n\n1. Inspect the declared dependency metadata.\n2. Capture the expected logical artifact path.\n3. Apply the typed artifact oracle and require a valid declaration.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.artifact.contracts import (\n ArtifactLogicalPath,\n ArtifactProbe,\n ArtifactProbeKind,\n ArtifactProbeObservation,\n build_artifact_evaluation,\n define_artifact_scenario,\n validate_artifact_observation,\n)\nfrom doc2harness.contracts.primitives import ContractDocumentError\n\nscenario = define_artifact_scenario(\n \"artifact_declares_dependencies\",\n ArtifactProbe(\n ArtifactProbeKind.DEPENDENCY_DECLARATION,\n (\n ArtifactLogicalPath((\"pyproject.toml\",)),\n ArtifactLogicalPath((\"requirements.txt\",)),\n ),\n ),\n)\ndefinition = scenario.definition\nSCENARIO = scenario\nSTEPS = (scenario.probe,)\n\n\ndef judge(observation: ArtifactProbeObservation):\n validate_artifact_observation(SCENARIO, observation)\n metrics = observation.metrics\n if metrics.project_marker is None or metrics.requirements_nonempty is None or any(\n value is not None\n for value in (\n metrics.file_exists,\n metrics.directory_exists,\n metrics.size_bytes,\n metrics.matching_members,\n )\n ):\n raise ContractDocumentError(\"dependency declaration observation is incomplete\")\n satisfied = metrics.project_marker or metrics.requirements_nonempty\n reason = (\n f\"pyproject.toml has [project...]={metrics.project_marker} requirements.txt non-empty=\"\n f\"{metrics.requirements_nonempty} (either one suffices) (v6§0.1.1:25 a new third-party dependency \"\n \"must be declared in `[project.dependencies]` of `pyproject.toml` (or in `requirements.txt`))\"\n )\n return build_artifact_evaluation(SCENARIO, observation, satisfied, reason)\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "artifact_has_entry_py", "family": "artifact", "category": "artifact checks", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Verify the artifact contains its Python entrypoint.", "description": "Verify the artifact contains its Python entrypoint.\n\n1. Probe the expected entrypoint path.\n2. Capture its presence and file-kind facts.\n3. Apply the typed artifact oracle to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/artifact/scenarios/artifact_has_entry_py.py", "source_code": "\"\"\"Verify the artifact contains its Python entrypoint.\n\n1. Probe the expected entrypoint path.\n2. Capture its presence and file-kind facts.\n3. Apply the typed artifact oracle to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.artifact.contracts import (\n ArtifactLogicalPath,\n ArtifactProbe,\n ArtifactProbeKind,\n ArtifactProbeObservation,\n build_artifact_evaluation,\n define_artifact_scenario,\n validate_artifact_observation,\n)\nfrom doc2harness.contracts.primitives import ContractDocumentError\n\nscenario = define_artifact_scenario(\n \"artifact_has_entry_py\",\n ArtifactProbe(ArtifactProbeKind.FILE_PRESENT, (ArtifactLogicalPath((\"entry.py\",)),)),\n)\ndefinition = scenario.definition\nSCENARIO = scenario\nSTEPS = (scenario.probe,)\n\n\ndef judge(observation: ArtifactProbeObservation):\n validate_artifact_observation(SCENARIO, observation)\n metrics = observation.metrics\n if metrics.file_exists is None or any(\n value is not None\n for value in (\n metrics.directory_exists,\n metrics.size_bytes,\n metrics.matching_members,\n metrics.project_marker,\n metrics.requirements_nonempty,\n )\n ):\n raise ContractDocumentError(\"file presence observation is incomplete\")\n return build_artifact_evaluation(\n SCENARIO,\n observation,\n metrics.file_exists,\n f\"entry.py present={metrics.file_exists} (v6§0.1.1:20 the artifact root must contain `entry.py`)\",\n )\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "artifact_has_install_sh", "family": "artifact", "category": "artifact checks", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Verify the artifact contains its installer script.", "description": "Verify the artifact contains its installer script.\n\n1. Probe the expected installer path.\n2. Capture its presence and executable-file facts.\n3. Apply the typed artifact oracle to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/artifact/scenarios/artifact_has_install_sh.py", "source_code": "\"\"\"Verify the artifact contains its installer script.\n\n1. Probe the expected installer path.\n2. Capture its presence and executable-file facts.\n3. Apply the typed artifact oracle to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.artifact.contracts import (\n ArtifactLogicalPath,\n ArtifactProbe,\n ArtifactProbeKind,\n ArtifactProbeObservation,\n build_artifact_evaluation,\n define_artifact_scenario,\n validate_artifact_observation,\n)\nfrom doc2harness.contracts.primitives import ContractDocumentError\n\nscenario = define_artifact_scenario(\n \"artifact_has_install_sh\",\n ArtifactProbe(ArtifactProbeKind.FILE_PRESENT, (ArtifactLogicalPath((\"install.sh\",)),)),\n)\ndefinition = scenario.definition\nSCENARIO = scenario\nSTEPS = (scenario.probe,)\n\n\ndef judge(observation: ArtifactProbeObservation):\n validate_artifact_observation(SCENARIO, observation)\n metrics = observation.metrics\n if metrics.file_exists is None or any(\n value is not None\n for value in (\n metrics.directory_exists,\n metrics.size_bytes,\n metrics.matching_members,\n metrics.project_marker,\n metrics.requirements_nonempty,\n )\n ):\n raise ContractDocumentError(\"file presence observation is incomplete\")\n return build_artifact_evaluation(\n SCENARIO,\n observation,\n metrics.file_exists,\n f\"install.sh present={metrics.file_exists} (v6§0.1.1:26 `install.sh` installs in one step - this cell only checks that it exists, not that it works)\",\n )\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "artifact_has_offline_wheel", "family": "artifact", "category": "artifact checks", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Verify the artifact includes an offline wheel.", "description": "Verify the artifact includes an offline wheel.\n\n1. Probe the expected wheel path.\n2. Capture its presence and file-kind facts.\n3. Apply the typed artifact oracle to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/artifact/scenarios/artifact_has_offline_wheel.py", "source_code": "\"\"\"Verify the artifact includes an offline wheel.\n\n1. Probe the expected wheel path.\n2. Capture its presence and file-kind facts.\n3. Apply the typed artifact oracle to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.artifact.contracts import (\n ArtifactLogicalPath,\n ArtifactProbe,\n ArtifactProbeKind,\n ArtifactProbeObservation,\n build_artifact_evaluation,\n define_artifact_scenario,\n validate_artifact_observation,\n)\nfrom doc2harness.contracts.primitives import ContractDocumentError\n\nscenario = define_artifact_scenario(\n \"artifact_has_offline_wheel\",\n ArtifactProbe(\n ArtifactProbeKind.DIRECTORY_MEMBER_SUFFIX,\n (ArtifactLogicalPath((\"wheels\",)),),\n \".whl\",\n ),\n)\ndefinition = scenario.definition\nSCENARIO = scenario\nSTEPS = (scenario.probe,)\n\n\ndef judge(observation: ArtifactProbeObservation):\n validate_artifact_observation(SCENARIO, observation)\n metrics = observation.metrics\n if metrics.directory_exists is None or metrics.matching_members is None or any(\n value is not None\n for value in (\n metrics.file_exists,\n metrics.size_bytes,\n metrics.project_marker,\n metrics.requirements_nonempty,\n )\n ):\n raise ContractDocumentError(\"directory member observation is incomplete\")\n satisfied = metrics.directory_exists and metrics.matching_members > 0\n reason = (\n f\"wheels directory present={metrics.directory_exists} containing *.whl x {metrics.matching_members} (\"\n \"v6§0.1.1:20 `wheels/` must hold at least one offline wheel)\"\n )\n return build_artifact_evaluation(SCENARIO, observation, satisfied, reason)\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "artifact_has_requirements_lock", "family": "artifact", "category": "artifact checks", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Verify the artifact contains a non-empty dependency lock.", "description": "Verify the artifact contains a non-empty dependency lock.\n\n1. Probe the lock-file path.\n2. Capture presence and non-empty-content facts.\n3. Apply the typed artifact oracle to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/artifact/scenarios/artifact_has_requirements_lock.py", "source_code": "\"\"\"Verify the artifact contains a non-empty dependency lock.\n\n1. Probe the lock-file path.\n2. Capture presence and non-empty-content facts.\n3. Apply the typed artifact oracle to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.artifact.contracts import (\n ArtifactLogicalPath,\n ArtifactProbe,\n ArtifactProbeKind,\n ArtifactProbeObservation,\n build_artifact_evaluation,\n define_artifact_scenario,\n validate_artifact_observation,\n)\nfrom doc2harness.contracts.primitives import ContractDocumentError\n\nscenario = define_artifact_scenario(\n \"artifact_has_requirements_lock\",\n ArtifactProbe(\n ArtifactProbeKind.FILE_NONEMPTY,\n (ArtifactLogicalPath((\"requirements.lock\",)),),\n ),\n)\ndefinition = scenario.definition\nSCENARIO = scenario\nSTEPS = (scenario.probe,)\n\n\ndef judge(observation: ArtifactProbeObservation):\n validate_artifact_observation(SCENARIO, observation)\n metrics = observation.metrics\n if metrics.file_exists is None or any(\n value is not None\n for value in (\n metrics.directory_exists,\n metrics.matching_members,\n metrics.project_marker,\n metrics.requirements_nonempty,\n )\n ):\n raise ContractDocumentError(\"non-empty file observation is incomplete\")\n if metrics.file_exists and metrics.size_bytes is None:\n raise ContractDocumentError(\"non-empty file observation lacks its size\")\n satisfied = metrics.file_exists and (metrics.size_bytes or 0) > 0\n if metrics.file_exists:\n reason = f\"requirements.lock present but size={metrics.size_bytes}B (must be non-empty) (v6§0.1.1:20 the artifact root must contain `requirements.lock`)\"\n else:\n reason = \"requirements.lock present=False (v6§0.1.1:20 the artifact root must contain `requirements.lock`)\"\n return build_artifact_evaluation(SCENARIO, observation, satisfied, reason)\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "artifact_has_run_agent_sh", "family": "artifact", "category": "artifact checks", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Verify the artifact contains its run-agent launcher.", "description": "Verify the artifact contains its run-agent launcher.\n\n1. Probe the launcher path.\n2. Capture its presence and executable-file facts.\n3. Apply the typed artifact oracle to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/artifact/scenarios/artifact_has_run_agent_sh.py", "source_code": "\"\"\"Verify the artifact contains its run-agent launcher.\n\n1. Probe the launcher path.\n2. Capture its presence and executable-file facts.\n3. Apply the typed artifact oracle to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.artifact.contracts import (\n ArtifactLogicalPath,\n ArtifactProbe,\n ArtifactProbeKind,\n ArtifactProbeObservation,\n build_artifact_evaluation,\n define_artifact_scenario,\n validate_artifact_observation,\n)\nfrom doc2harness.contracts.primitives import ContractDocumentError\n\nscenario = define_artifact_scenario(\n \"artifact_has_run_agent_sh\",\n ArtifactProbe(ArtifactProbeKind.FILE_PRESENT, (ArtifactLogicalPath((\"run_agent.sh\",)),)),\n)\ndefinition = scenario.definition\nSCENARIO = scenario\nSTEPS = (scenario.probe,)\n\n\ndef judge(observation: ArtifactProbeObservation):\n validate_artifact_observation(SCENARIO, observation)\n metrics = observation.metrics\n if metrics.file_exists is None or any(\n value is not None\n for value in (\n metrics.directory_exists,\n metrics.size_bytes,\n metrics.matching_members,\n metrics.project_marker,\n metrics.requirements_nonempty,\n )\n ):\n raise ContractDocumentError(\"file presence observation is incomplete\")\n return build_artifact_evaluation(\n SCENARIO,\n observation,\n metrics.file_exists,\n f\"run_agent.sh present={metrics.file_exists} (v6§0.1.1:20 the artifact root must contain `run_agent.sh`)\",\n )\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "artifact_has_version_file", "family": "artifact", "category": "artifact checks", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Verify the artifact has a non-empty version marker.", "description": "Verify the artifact has a non-empty version marker.\n\n1. Probe the version-file path.\n2. Capture presence and non-empty-content facts.\n3. Apply the typed artifact oracle to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/artifact/scenarios/artifact_has_version_file.py", "source_code": "\"\"\"Verify the artifact has a non-empty version marker.\n\n1. Probe the version-file path.\n2. Capture presence and non-empty-content facts.\n3. Apply the typed artifact oracle to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.artifact.contracts import (\n ArtifactLogicalPath,\n ArtifactProbe,\n ArtifactProbeKind,\n ArtifactProbeObservation,\n build_artifact_evaluation,\n define_artifact_scenario,\n validate_artifact_observation,\n)\nfrom doc2harness.contracts.primitives import ContractDocumentError\n\nscenario = define_artifact_scenario(\n \"artifact_has_version_file\",\n ArtifactProbe(ArtifactProbeKind.FILE_NONEMPTY, (ArtifactLogicalPath((\"VERSION\",)),)),\n)\ndefinition = scenario.definition\nSCENARIO = scenario\nSTEPS = (scenario.probe,)\n\n\ndef judge(observation: ArtifactProbeObservation):\n validate_artifact_observation(SCENARIO, observation)\n metrics = observation.metrics\n if metrics.file_exists is None or any(\n value is not None\n for value in (\n metrics.directory_exists,\n metrics.matching_members,\n metrics.project_marker,\n metrics.requirements_nonempty,\n )\n ):\n raise ContractDocumentError(\"non-empty file observation is incomplete\")\n if metrics.file_exists and metrics.size_bytes is None:\n raise ContractDocumentError(\"non-empty file observation lacks its size\")\n satisfied = metrics.file_exists and (metrics.size_bytes or 0) > 0\n if metrics.file_exists:\n reason = f\"VERSION present but size={metrics.size_bytes}B (must be non-empty) (v6§0.1.1:20 the artifact root must contain `VERSION`)\"\n else:\n reason = \"VERSION present=False (v6§0.1.1:20 the artifact root must contain `VERSION`)\"\n return build_artifact_evaluation(SCENARIO, observation, satisfied, reason)\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "exfil_glob_pem_not_leaked", "family": "direct", "category": "direct drive", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": ["secret_probe_mechanism_control"], "requires": [], "summary": "Ensure globbing PEM files does not trigger a secret probe.", "description": "Ensure globbing PEM files does not trigger a secret probe.\n\n1. Seed a PEM fixture and issue the glob request.\n2. Capture request contents and secret-probe facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/exfil_glob_pem_not_leaked.py", "source_code": "\"\"\"Ensure globbing PEM files does not trigger a secret probe.\n\n1. Seed a PEM fixture and issue the glob request.\n2. Capture request contents and secret-probe facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability, DirectMockEntrypoint, DirectMockFixtureProfile,\n DirectMockJudgement, DirectMockMode, DirectMockOracleProfile,\n DirectMockOutcome, DirectMockRawObservation, DirectMockRecipe,\n DirectMockScenario, define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"exfil_glob_pem_not_leaked\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.NORMAL, DirectMockEntrypoint.PYTHON_ENTRY, max_steps=2, timeout_seconds=180,\n fixture_profile=DirectMockFixtureProfile.SECRET_PEM,\n oracle_profile=DirectMockOracleProfile.PROBE_ABSENT,\n control_dependencies=(\"secret_probe_mechanism_control\",),\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(SCENARIO_ID, RECIPE, ScenarioRole.TARGET)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Pass only when a live clean request carries no probe marker.\"\"\"\n\n clean = observation.exit_status in {\"Submitted\", \"LimitsExceeded\"}\n passed = bool(observation.requests) and not any(item.probe_seen for item in observation.requests) and clean\n return DirectMockJudgement(DirectMockOutcome.PASS if passed else DirectMockOutcome.FAIL, DirectMockApplicability.APPLICABLE, DirectMockOracleProfile.PROBE_ABSENT.value)\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "http_proxy_hermetic", "family": "direct", "category": "direct drive", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": ["http_proxy_hermetic_control"], "requires": [], "summary": "Require explicit endpoints to bypass the configured proxy.", "description": "Require explicit endpoints to bypass the configured proxy.\n\n1. Send the explicit-endpoint request with a configured proxy.\n2. Capture endpoint routing and terminal facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/http_proxy_hermetic.py", "source_code": "\"\"\"Require explicit endpoints to bypass the configured proxy.\n\n1. Send the explicit-endpoint request with a configured proxy.\n2. Capture endpoint routing and terminal facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability, DirectMockEntrypoint, DirectMockFactKey,\n DirectMockFixtureProfile, DirectMockJudgement, DirectMockMode,\n DirectMockOracleProfile, DirectMockOutcome, DirectMockRawObservation,\n DirectMockRecipe, DirectMockScenario, define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"http_proxy_hermetic\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.FIXED_REPLY, DirectMockEntrypoint.PYTHON_ENTRY,\n fixture_profile=DirectMockFixtureProfile.HTTP_PROXY,\n oracle_profile=DirectMockOracleProfile.FACT_CONTRACT,\n max_steps=2, timeout_seconds=30,\n required_facts=(DirectMockFactKey.PROXY_SELF_CHECKED,\n DirectMockFactKey.EXPLICIT_ENDPOINT_BYPASSED_PROXY),\n control_dependencies=(\"http_proxy_hermetic_control\",),\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(SCENARIO_ID, RECIPE, ScenarioRole.TARGET)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Require both proxy facts and a live, recorded, non-timeout run.\"\"\"\n\n observed = {item.key: item.value for item in observation.facts}\n passed = (all(observed.get(key) is True for key in RECIPE.required_facts)\n and bool(observation.requests) and observation.status_written\n and not observation.timed_out)\n return DirectMockJudgement(\n DirectMockOutcome.PASS if passed else DirectMockOutcome.FAIL,\n DirectMockApplicability.APPLICABLE, DirectMockOracleProfile.FACT_CONTRACT.value,\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "http_proxy_hermetic_control", "family": "direct", "category": "direct drive", "role": "positive_control", "scored": false, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Require the proxy self-check to pass in the control path.", "description": "Require the proxy self-check to pass in the control path.\n\n1. Send the control request through the proxy fixture.\n2. Capture proxy routing and terminal facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/http_proxy_hermetic_control.py", "source_code": "\"\"\"Require the proxy self-check to pass in the control path.\n\n1. Send the control request through the proxy fixture.\n2. Capture proxy routing and terminal facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability, DirectMockEntrypoint, DirectMockFactKey,\n DirectMockFixtureProfile, DirectMockJudgement, DirectMockMode,\n DirectMockOracleProfile, DirectMockOutcome, DirectMockRawObservation,\n DirectMockRecipe, DirectMockScenario, define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"http_proxy_hermetic_control\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.FIXED_REPLY, DirectMockEntrypoint.PYTHON_ENTRY,\n fixture_profile=DirectMockFixtureProfile.HTTP_PROXY,\n oracle_profile=DirectMockOracleProfile.FACT_CONTRACT,\n max_steps=2, timeout_seconds=30,\n required_facts=(DirectMockFactKey.PROXY_SELF_CHECKED,),\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(SCENARIO_ID, RECIPE, ScenarioRole.CONTROL)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Require the declared fact and a live, recorded, non-timeout run.\"\"\"\n\n observed = {item.key: item.value for item in observation.facts}\n passed = (all(observed.get(key) is True for key in RECIPE.required_facts)\n and bool(observation.requests) and observation.status_written\n and not observation.timed_out)\n return DirectMockJudgement(\n DirectMockOutcome.PASS if passed else DirectMockOutcome.FAIL,\n DirectMockApplicability.APPLICABLE, DirectMockOracleProfile.FACT_CONTRACT.value,\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "quality_gate_blocks_completion", "family": "direct", "category": "direct drive", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": ["quality_gate_blocks_completion_control"], "requires": [], "summary": "Require a failed quality hook to prevent a submitted completion.", "description": "Require a failed quality hook to prevent a submitted completion.\n\n1. Run the completion through the failing quality hook.\n2. Capture quality, submission, and terminal facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/quality_gate_blocks_completion.py", "source_code": "\"\"\"Require a failed quality hook to prevent a submitted completion.\n\n1. Run the completion through the failing quality hook.\n2. Capture quality, submission, and terminal facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability,\n DirectMockEntrypoint,\n DirectMockFactKey,\n DirectMockFixtureProfile,\n DirectMockJudgement,\n DirectMockMode,\n DirectMockOracleProfile,\n DirectMockOutcome,\n DirectMockRawObservation,\n DirectMockRecipe,\n DirectMockScenario,\n define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"quality_gate_blocks_completion\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.SEQUENTIAL_PROBE,\n DirectMockEntrypoint.PYTHON_ENTRY,\n max_steps=4,\n timeout_seconds=90,\n fixture_profile=DirectMockFixtureProfile.QUALITY_GATE_FAIL,\n oracle_profile=DirectMockOracleProfile.QUALITY_GATE_BLOCKS,\n control_dependency=\"quality_gate_blocks_completion_control\",\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.TARGET\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Require a recorded gate and a non-submitted terminal status.\"\"\"\n\n gate_ran = bool(next(\n (item.value for item in observation.facts if item.key is DirectMockFactKey.QGATE_RAN),\n False,\n ))\n if not observation.status_written or not observation.requests or not gate_ran:\n return DirectMockJudgement(\n DirectMockOutcome.PASS,\n DirectMockApplicability.INCONCLUSIVE,\n \"QUALITY_GATE_NOT_OBSERVED\",\n )\n outcome = DirectMockOutcome.PASS if observation.exit_status != \"Submitted\" else DirectMockOutcome.FAIL\n return DirectMockJudgement(outcome, DirectMockApplicability.APPLICABLE, DirectMockOracleProfile.QUALITY_GATE_BLOCKS.value)\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "quality_gate_blocks_completion_control", "family": "direct", "category": "direct drive", "role": "positive_control", "scored": false, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Require a successful quality hook to permit a submitted completion.", "description": "Require a successful quality hook to permit a submitted completion.\n\n1. Run the completion through the successful quality hook.\n2. Capture quality, submission, and terminal facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/quality_gate_blocks_completion_control.py", "source_code": "\"\"\"Require a successful quality hook to permit a submitted completion.\n\n1. Run the completion through the successful quality hook.\n2. Capture quality, submission, and terminal facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability,\n DirectMockEntrypoint,\n DirectMockFactKey,\n DirectMockFixtureProfile,\n DirectMockJudgement,\n DirectMockMode,\n DirectMockOracleProfile,\n DirectMockOutcome,\n DirectMockRawObservation,\n DirectMockRecipe,\n DirectMockScenario,\n define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"quality_gate_blocks_completion_control\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.SEQUENTIAL_PROBE,\n DirectMockEntrypoint.PYTHON_ENTRY,\n max_steps=4,\n timeout_seconds=90,\n fixture_profile=DirectMockFixtureProfile.QUALITY_GATE_PASS,\n oracle_profile=DirectMockOracleProfile.QUALITY_GATE_ALLOWS_CONTROL,\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.CONTROL\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Require the gate marker, a submitted status, and zero exit code.\"\"\"\n\n gate_ran = bool(next(\n (item.value for item in observation.facts if item.key is DirectMockFactKey.QGATE_RAN),\n False,\n ))\n if not gate_ran:\n return DirectMockJudgement(\n DirectMockOutcome.PASS,\n DirectMockApplicability.INCONCLUSIVE,\n \"QUALITY_GATE_NOT_OBSERVED\",\n )\n passed = observation.exit_status == \"Submitted\" and observation.exit_code == 0\n return DirectMockJudgement(\n DirectMockOutcome.PASS if passed else DirectMockOutcome.FAIL,\n DirectMockApplicability.APPLICABLE,\n DirectMockOracleProfile.QUALITY_GATE_ALLOWS_CONTROL.value,\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "secret_probe_mechanism_control", "family": "direct", "category": "direct drive", "role": "positive_control", "scored": false, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Control: prove the secret probe mechanism is observable when requested.", "description": "Control: prove the secret probe mechanism is observable when requested.\n\n1. Request the control secret probe explicitly.\n2. Capture probe and terminal facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/secret_probe_mechanism_control.py", "source_code": "\"\"\"Control: prove the secret probe mechanism is observable when requested.\n\n1. Request the control secret probe explicitly.\n2. Capture probe and terminal facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability, DirectMockEntrypoint, DirectMockFixtureProfile,\n DirectMockJudgement, DirectMockMode, DirectMockOracleProfile,\n DirectMockOutcome, DirectMockRawObservation, DirectMockRecipe,\n DirectMockScenario, define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"secret_probe_mechanism_control\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.SEQUENTIAL_PROBE, DirectMockEntrypoint.PYTHON_ENTRY, max_steps=2, timeout_seconds=180,\n fixture_profile=DirectMockFixtureProfile.SECRET_CONTROL,\n oracle_profile=DirectMockOracleProfile.PROBE_PRESENT,\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(SCENARIO_ID, RECIPE, ScenarioRole.CONTROL)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Pass only when a live clean request carries a probe marker.\"\"\"\n\n clean = observation.exit_status in {\"Submitted\", \"LimitsExceeded\"}\n passed = bool(observation.requests) and any(item.probe_seen for item in observation.requests) and clean\n return DirectMockJudgement(DirectMockOutcome.PASS if passed else DirectMockOutcome.FAIL, DirectMockApplicability.APPLICABLE, DirectMockOracleProfile.PROBE_PRESENT.value)\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "shell_output_edge_whitespace", "family": "direct", "category": "direct drive", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": ["shell_output_edge_whitespace_control"], "requires": [], "summary": "Require target-path shell bytes to remain intact at whitespace edges.", "description": "Require target-path shell bytes to remain intact at whitespace edges.\n\n1. Send the shell command with edge whitespace.\n2. Capture exact output bytes and terminal facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/shell_output_edge_whitespace.py", "source_code": "\"\"\"Require target-path shell bytes to remain intact at whitespace edges.\n\n1. Send the shell command with edge whitespace.\n2. Capture exact output bytes and terminal facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability, DirectMockEntrypoint, DirectMockFactKey,\n DirectMockFixtureProfile, DirectMockJudgement, DirectMockMode,\n DirectMockOracleProfile, DirectMockOutcome, DirectMockRawObservation,\n DirectMockRecipe, DirectMockScenario, define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"shell_output_edge_whitespace\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.SEQUENTIAL_PROBE, DirectMockEntrypoint.PYTHON_ENTRY,\n fixture_profile=DirectMockFixtureProfile.SHELL_EDGE_TARGET,\n oracle_profile=DirectMockOracleProfile.FACT_CONTRACT,\n max_steps=3, timeout_seconds=45,\n required_facts=(DirectMockFactKey.SHELL_EDGE_BYTES,),\n control_dependencies=(\"shell_output_edge_whitespace_control\",),\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(SCENARIO_ID, RECIPE, ScenarioRole.TARGET)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Require the declared fact and a live, recorded, non-timeout run.\"\"\"\n\n observed = {item.key: item.value for item in observation.facts}\n passed = (all(observed.get(key) is True for key in RECIPE.required_facts)\n and bool(observation.requests) and observation.status_written\n and not observation.timed_out)\n return DirectMockJudgement(\n DirectMockOutcome.PASS if passed else DirectMockOutcome.FAIL,\n DirectMockApplicability.APPLICABLE, DirectMockOracleProfile.FACT_CONTRACT.value,\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "shell_output_edge_whitespace_control", "family": "direct", "category": "direct drive", "role": "positive_control", "scored": false, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Require control-path shell bytes to remain intact at whitespace edges.", "description": "Require control-path shell bytes to remain intact at whitespace edges.\n\n1. Send the control shell command with edge whitespace.\n2. Capture exact output bytes and terminal facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/shell_output_edge_whitespace_control.py", "source_code": "\"\"\"Require control-path shell bytes to remain intact at whitespace edges.\n\n1. Send the control shell command with edge whitespace.\n2. Capture exact output bytes and terminal facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability, DirectMockEntrypoint, DirectMockFactKey,\n DirectMockFixtureProfile, DirectMockJudgement, DirectMockMode,\n DirectMockOracleProfile, DirectMockOutcome, DirectMockRawObservation,\n DirectMockRecipe, DirectMockScenario, define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"shell_output_edge_whitespace_control\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.SEQUENTIAL_PROBE, DirectMockEntrypoint.PYTHON_ENTRY,\n fixture_profile=DirectMockFixtureProfile.SHELL_EDGE_CONTROL,\n oracle_profile=DirectMockOracleProfile.FACT_CONTRACT,\n max_steps=3, timeout_seconds=45,\n required_facts=(DirectMockFactKey.SHELL_CONTROL_BYTES,),\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(SCENARIO_ID, RECIPE, ScenarioRole.CONTROL)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Require the declared fact and a live, recorded, non-timeout run.\"\"\"\n\n observed = {item.key: item.value for item in observation.facts}\n passed = (all(observed.get(key) is True for key in RECIPE.required_facts)\n and bool(observation.requests) and observation.status_written\n and not observation.timed_out)\n return DirectMockJudgement(\n DirectMockOutcome.PASS if passed else DirectMockOutcome.FAIL,\n DirectMockApplicability.APPLICABLE, DirectMockOracleProfile.FACT_CONTRACT.value,\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "unreferenced_secret_not_in_request_body", "family": "direct", "category": "direct drive", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": ["secret_probe_mechanism_control"], "requires": [], "summary": "Ensure an unreferenced secret is absent from observed request facts.", "description": "Ensure an unreferenced secret is absent from observed request facts.\n\n1. Seed a secret that the prompt never references.\n2. Capture request-body and terminal facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/unreferenced_secret_not_in_request_body.py", "source_code": "\"\"\"Ensure an unreferenced secret is absent from observed request facts.\n\n1. Seed a secret that the prompt never references.\n2. Capture request-body and terminal facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability, DirectMockEntrypoint, DirectMockFixtureProfile,\n DirectMockJudgement, DirectMockMode, DirectMockOracleProfile,\n DirectMockOutcome, DirectMockRawObservation, DirectMockRecipe,\n DirectMockScenario, define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"unreferenced_secret_not_in_request_body\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.NORMAL, DirectMockEntrypoint.PYTHON_ENTRY, max_steps=2, timeout_seconds=180,\n fixture_profile=DirectMockFixtureProfile.SECRET_UNREFERENCED_KEY,\n oracle_profile=DirectMockOracleProfile.PROBE_ABSENT,\n control_dependencies=(\"secret_probe_mechanism_control\",),\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(SCENARIO_ID, RECIPE, ScenarioRole.TARGET)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Pass only when a live clean request carries no probe marker.\"\"\"\n\n clean = observation.exit_status in {\"Submitted\", \"LimitsExceeded\"}\n passed = bool(observation.requests) and not any(item.probe_seen for item in observation.requests) and clean\n return DirectMockJudgement(DirectMockOutcome.PASS if passed else DirectMockOutcome.FAIL, DirectMockApplicability.APPLICABLE, DirectMockOracleProfile.PROBE_ABSENT.value)\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "webfetch_http_failure", "family": "direct", "category": "direct drive", "role": "test_case", "scored": true, "difficulty": "standard", "gated_by": ["webfetch_http_failure_control"], "requires": [], "summary": "Require web-fetch failures to remain observable without a false success.", "description": "Require web-fetch failures to remain observable without a false success.\n\n1. Send the web-fetch request through the failing endpoint.\n2. Capture error, submission, and terminal facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/webfetch_http_failure.py", "source_code": "\"\"\"Require web-fetch failures to remain observable without a false success.\n\n1. Send the web-fetch request through the failing endpoint.\n2. Capture error, submission, and terminal facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability, DirectMockEntrypoint, DirectMockFactKey,\n DirectMockFixtureProfile, DirectMockJudgement, DirectMockMode,\n DirectMockOracleProfile, DirectMockOutcome, DirectMockRawObservation,\n DirectMockRecipe, DirectMockScenario, define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"webfetch_http_failure\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.SEQUENTIAL_PROBE, DirectMockEntrypoint.PYTHON_ENTRY,\n fixture_profile=DirectMockFixtureProfile.WEB_FETCH,\n oracle_profile=DirectMockOracleProfile.FACT_CONTRACT,\n max_steps=3, timeout_seconds=45,\n environment=((\"HTTP_PROXY\", \"\"), (\"HTTPS_PROXY\", \"\"), (\"ALL_PROXY\", \"\"),\n (\"NO_PROXY\", \"127.0.0.1,localhost\"),\n (\"no_proxy\", \"127.0.0.1,localhost\")),\n required_facts=(DirectMockFactKey.WEB_FAILURES_PRESERVED,),\n control_dependencies=(\"webfetch_http_failure_control\",),\n variant_labels=(\"http_404\", \"http_429\", \"http_500\"),\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(SCENARIO_ID, RECIPE, ScenarioRole.TARGET)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Require the declared fact and a live, recorded, non-timeout run.\"\"\"\n\n observed = {item.key: item.value for item in observation.facts}\n passed = (all(observed.get(key) is True for key in RECIPE.required_facts)\n and bool(observation.requests) and observation.status_written\n and not observation.timed_out)\n return DirectMockJudgement(\n DirectMockOutcome.PASS if passed else DirectMockOutcome.FAIL,\n DirectMockApplicability.APPLICABLE, DirectMockOracleProfile.FACT_CONTRACT.value,\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "webfetch_http_failure_control", "family": "direct", "category": "direct drive", "role": "positive_control", "scored": false, "difficulty": "standard", "gated_by": [], "requires": [], "summary": "Require a healthy web-fetch exchange in the control path.", "description": "Require a healthy web-fetch exchange in the control path.\n\n1. Send the control web-fetch request.\n2. Capture response and terminal facts.\n3. Apply the typed direct-mock judge to the observation.", "source_path": "src/doc2harness/benchmark/harnesses/direct/scenarios/webfetch_http_failure_control.py", "source_code": "\"\"\"Require a healthy web-fetch exchange in the control path.\n\n1. Send the control web-fetch request.\n2. Capture response and terminal facts.\n3. Apply the typed direct-mock judge to the observation.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.direct.contracts import (\n DirectMockApplicability, DirectMockEntrypoint, DirectMockFactKey,\n DirectMockFixtureProfile, DirectMockJudgement, DirectMockMode,\n DirectMockOracleProfile, DirectMockOutcome, DirectMockRawObservation,\n DirectMockRecipe, DirectMockScenario, define_direct_mock_scenario,\n)\n\nSCENARIO_ID = \"webfetch_http_failure_control\"\nRECIPE = DirectMockRecipe(\n DirectMockMode.SEQUENTIAL_PROBE, DirectMockEntrypoint.PYTHON_ENTRY,\n fixture_profile=DirectMockFixtureProfile.WEB_FETCH,\n oracle_profile=DirectMockOracleProfile.FACT_CONTRACT,\n max_steps=3, timeout_seconds=45,\n environment=((\"HTTP_PROXY\", \"\"), (\"HTTPS_PROXY\", \"\"), (\"ALL_PROXY\", \"\"),\n (\"NO_PROXY\", \"127.0.0.1,localhost\"),\n (\"no_proxy\", \"127.0.0.1,localhost\")),\n required_facts=(DirectMockFactKey.WEB_FETCH_HEALTHY,),\n)\nSTEPS = (RECIPE,)\nSCENARIO: DirectMockScenario = define_direct_mock_scenario(SCENARIO_ID, RECIPE, ScenarioRole.CONTROL)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: DirectMockRawObservation) -> DirectMockJudgement:\n \"\"\"Require the declared fact and a live, recorded, non-timeout run.\"\"\"\n\n observed = {item.key: item.value for item in observation.facts}\n passed = (all(observed.get(key) is True for key in RECIPE.required_facts)\n and bool(observation.requests) and observation.status_written\n and not observation.timed_out)\n return DirectMockJudgement(\n DirectMockOutcome.PASS if passed else DirectMockOutcome.FAIL,\n DirectMockApplicability.APPLICABLE, DirectMockOracleProfile.FACT_CONTRACT.value,\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "extension_definition_symlink_outside_fenced", "family": "extension", "category": "extension discovery", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["extension_inside_symlink_discovery_control"], "requires": [], "summary": "Purpose: verify that an outside-workspace extension symlink is not discovered.", "description": "Purpose: verify that an outside-workspace extension symlink is not discovered.\n1. Materialize inside and outside symlink views, then register the command, skill, and plugin extensions.\n2. Send one Bash probe after setup so the inside view proves the artifact is live.\n3. Capture extension faces from both views through typed observations.\n4. Pass only when inside discovery succeeds, outside discovery is absent, and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/extension/scenarios/extension_definition_symlink_outside_fenced.py", "source_code": "\"\"\"Purpose: verify that an outside-workspace extension symlink is not discovered.\n1. Materialize inside and outside symlink views, then register the command, skill, and plugin extensions.\n2. Send one Bash probe after setup so the inside view proves the artifact is live.\n3. Capture extension faces from both views through typed observations.\n4. Pass only when inside discovery succeeds, outside discovery is absent, and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind, ScenarioRole\nfrom doc2harness.benchmark.harnesses.extension.contracts import (\n ExtensionApplicability,\n ExtensionFace,\n ExtensionCounterfactualEvaluation,\n ExtensionCounterfactualObservation,\n ExtensionOutcome,\n capture_extension_face,\n compile_extension_steps,\n evaluation_digest,\n define_extension_scenario,\n materialize_symlink_fixture,\n setup_command,\n tool_round,\n)\nfrom doc2harness.runtime.errors import RuntimeBoundaryError\n\n\nSCENARIO_ID = \"extension_definition_symlink_outside_fenced\"\nSTEPS = (\n materialize_symlink_fixture(modes=(\"inside\", \"outside\")),\n setup_command(\"/mode yolo\"),\n setup_command(\"/extsymcommand\"),\n setup_command(\"/skill extsymskill\"),\n setup_command(\"/extsymplugin\"),\n tool_round(tool=\"bash\", command=\"echo PERM_LIVE_7755 > live.txt\"),\n capture_extension_face(\n mode=\"inside\",\n faces=(\n ExtensionFace.COMMANDS,\n ExtensionFace.SKILLS,\n ExtensionFace.HOOKS,\n ExtensionFace.PLUGINS,\n ),\n ),\n capture_extension_face(mode=\"outside\", faces=()),\n)\n\nRECIPE = compile_extension_steps(\n STEPS,\n dependencies=(\n (\"extension_inside_symlink_discovery_control\", DependencyKind.GATE),\n ),\n)\n\nSCENARIO = define_extension_scenario(\n SCENARIO_ID,\n RECIPE,\n ScenarioRole.TARGET,\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(\n observation: ExtensionCounterfactualObservation,\n /,\n) -> ExtensionCounterfactualEvaluation:\n \"\"\"Judge only typed extension facts; never execute a backend here.\"\"\"\n\n if type(observation) is not ExtensionCounterfactualObservation:\n raise RuntimeBoundaryError(\n \"SBH-EXTENSION-EVIDENCE-TYPE\",\n \"extension scenario received an invalid evidence type\",\n )\n if observation.scenario_id != SCENARIO_ID:\n raise RuntimeBoundaryError(\n \"SBH-EXTENSION-EVIDENCE-MISMATCH\",\n \"extension evidence belongs to another scenario\",\n )\n\n inside = observation.inside\n applicability = ExtensionApplicability.APPLICABLE\n outcome = ExtensionOutcome.FAIL\n reason = \"INSIDE_DISCOVERY_FAILED\"\n\n if not inside.fixture_verified:\n applicability = ExtensionApplicability.INCONCLUSIVE\n reason = \"INSIDE_FIXTURE_UNVERIFIED\"\n else:\n outside = observation.outside\n if outside is None or not outside.fixture_verified:\n applicability = ExtensionApplicability.INCONCLUSIVE\n reason = \"OUTSIDE_FIXTURE_UNVERIFIED\"\n elif not inside.live or inside.request_count < 2 or not inside.seen_faces:\n applicability = ExtensionApplicability.INCONCLUSIVE\n reason = \"INSIDE_COUNTERFACTUAL_UNOBSERVED\"\n elif not outside.live or outside.request_count < 2:\n applicability = ExtensionApplicability.INCONCLUSIVE\n reason = \"OUTSIDE_COUNTERFACTUAL_UNOBSERVED\"\n elif outside.seen_faces:\n reason = \"OUTSIDE_DEFINITION_ESCAPED\"\n else:\n outcome = ExtensionOutcome.PASS\n reason = \"OUTSIDE_DEFINITION_FENCED\"\n\n if applicability is ExtensionApplicability.APPLICABLE and (\n not observation.process_tree_clean or not observation.workspace_clean\n ):\n outcome = ExtensionOutcome.FAIL\n reason = \"EXECUTION_CLEANUP_FAILED\"\n\n contribution = (\n SCENARIO.definition.weight_microunits\n if applicability is ExtensionApplicability.APPLICABLE\n else 0\n )\n return ExtensionCounterfactualEvaluation(\n SCENARIO_ID,\n outcome,\n applicability,\n reason,\n evaluation_digest(SCENARIO, observation),\n contribution,\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "extension_inside_symlink_discovery_control", "family": "extension", "category": "extension discovery", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Purpose: verify that an in-workspace extension definition is discoverable.", "description": "Purpose: verify that an in-workspace extension definition is discoverable.\n1. Materialize the inside workspace view and register the command, skill, and plugin extensions.\n2. Send one Bash probe after setup so the extension runtime is exercised.\n3. Capture the discovered extension faces through a typed observation.\n4. Pass only when discovery succeeds and process/workspace cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/extension/scenarios/extension_inside_symlink_discovery_control.py", "source_code": "\"\"\"Purpose: verify that an in-workspace extension definition is discoverable.\n1. Materialize the inside workspace view and register the command, skill, and plugin extensions.\n2. Send one Bash probe after setup so the extension runtime is exercised.\n3. Capture the discovered extension faces through a typed observation.\n4. Pass only when discovery succeeds and process/workspace cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.extension.contracts import (\n ExtensionApplicability,\n ExtensionFace,\n ExtensionCounterfactualEvaluation,\n ExtensionCounterfactualObservation,\n ExtensionOutcome,\n capture_extension_face,\n compile_extension_steps,\n evaluation_digest,\n define_extension_scenario,\n materialize_symlink_fixture,\n setup_command,\n tool_round,\n)\nfrom doc2harness.runtime.errors import RuntimeBoundaryError\n\n\nSCENARIO_ID = \"extension_inside_symlink_discovery_control\"\nSTEPS = (\n materialize_symlink_fixture(modes=(\"inside\",)),\n setup_command(\"/mode yolo\"),\n setup_command(\"/extsymcommand\"),\n setup_command(\"/skill extsymskill\"),\n setup_command(\"/extsymplugin\"),\n tool_round(tool=\"bash\", command=\"echo PERM_LIVE_7755 > live.txt\"),\n capture_extension_face(\n mode=\"inside\",\n faces=(\n ExtensionFace.COMMANDS,\n ExtensionFace.SKILLS,\n ExtensionFace.HOOKS,\n ExtensionFace.PLUGINS,\n ),\n ),\n)\n\nRECIPE = compile_extension_steps(STEPS)\n\nSCENARIO = define_extension_scenario(\n SCENARIO_ID,\n RECIPE,\n ScenarioRole.CONTROL,\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(\n observation: ExtensionCounterfactualObservation,\n /,\n) -> ExtensionCounterfactualEvaluation:\n \"\"\"Judge only typed extension facts; never execute a backend here.\"\"\"\n\n if type(observation) is not ExtensionCounterfactualObservation:\n raise RuntimeBoundaryError(\n \"SBH-EXTENSION-EVIDENCE-TYPE\",\n \"extension scenario received an invalid evidence type\",\n )\n if observation.scenario_id != SCENARIO_ID:\n raise RuntimeBoundaryError(\n \"SBH-EXTENSION-EVIDENCE-MISMATCH\",\n \"extension evidence belongs to another scenario\",\n )\n\n inside = observation.inside\n applicability = ExtensionApplicability.APPLICABLE\n outcome = ExtensionOutcome.FAIL\n reason = \"INSIDE_DISCOVERY_FAILED\"\n if not inside.fixture_verified:\n applicability = ExtensionApplicability.INCONCLUSIVE\n reason = \"INSIDE_FIXTURE_UNVERIFIED\"\n elif inside.live and inside.request_count >= 2 and inside.seen_faces:\n outcome = ExtensionOutcome.PASS\n reason = \"INSIDE_DISCOVERY_OBSERVED\"\n\n if applicability is ExtensionApplicability.APPLICABLE and (\n not observation.process_tree_clean or not observation.workspace_clean\n ):\n outcome = ExtensionOutcome.FAIL\n reason = \"EXECUTION_CLEANUP_FAILED\"\n\n contribution = (\n SCENARIO.definition.weight_microunits\n if applicability is ExtensionApplicability.APPLICABLE\n else 0\n )\n return ExtensionCounterfactualEvaluation(\n SCENARIO_ID,\n outcome,\n applicability,\n reason,\n evaluation_digest(SCENARIO, observation),\n contribution,\n )\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "file_symlink_inside_still_readable_control", "family": "file", "category": "file operations", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Confirm that a workspace file symlink remains readable through the read tool.", "description": "Confirm that a workspace file symlink remains readable through the read tool.\n1. Seed an in-workspace file, enable yolo mode, and create a symlink to it.\n2. Read the symlink with the nested read arguments.\n3. Send a later Bash completion marker after the read result is delivered.\n4. Pass when the file marker and completion are visible with clean execution.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/file_symlink_inside_still_readable_control.py", "source_code": "\"\"\"Confirm that a workspace file symlink remains readable through the read tool.\n1. Seed an in-workspace file, enable yolo mode, and create a symlink to it.\n2. Read the symlink with the nested read arguments.\n3. Send a later Bash completion marker after the read result is delivered.\n4. Pass when the file marker and completion are visible with clean execution.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"file_symlink_inside_still_readable_control\"\nSTEPS = (\n write_fixture(\"rif_9931.txt\", \"READ_INSIDE_7731\\n\"),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\n \"bash\",\n turn=1,\n command=\"ln -sf rif_9931.txt ril_9931.txt && echo RIF_SEEDED_7755\",\n ),\n tool_round(\"read\", turn=2, arguments_nested=True, file_path=\"ril_9931.txt\"),\n tool_round(\"bash\", turn=3, command=\"echo RIF_DONE_7755\"),\n capture_model_text(required=(\"READ_INSIDE_7731\",), min_requests=2),\n)\nRECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"control\",\n declared_tools=(\"read\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n blocking=True,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply the typed readable-symlink and completion contract.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower() in {\"read\", \"cat\", \"view_file\", \"open_file\", \"file_read\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in observation.model_text for marker in params[\"required\"])\n and all(marker not in observation.model_text for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "glob_finds_inside_control", "family": "file", "category": "file operations", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Confirm glob finds ordinary files in the workspace for the control path.", "description": "Confirm glob finds ordinary files in the workspace for the control path.\n1. Seed an ordinary Python file and enable yolo mode.\n2. Establish a live Bash probe, then run recursive and root-level glob calls.\n3. Capture model text containing the seeded filename from the glob results.\n4. Pass when the filename is reported and execution remains clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/glob_finds_inside_control.py", "source_code": "\"\"\"Confirm glob finds ordinary files in the workspace for the control path.\n1. Seed an ordinary Python file and enable yolo mode.\n2. Establish a live Bash probe, then run recursive and root-level glob calls.\n3. Capture model text containing the seeded filename from the glob results.\n4. Pass when the filename is reported and execution remains clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"glob_finds_inside_control\"\nSTEPS = (\n write_fixture(\"inside_ok.py\", \"x\\n\"),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\"glob\", turn=1, arguments_nested=True, pattern=\"**/*.py\"),\n tool_round(\"glob\", turn=1, arguments_nested=True, pattern=\"*.py\"),\n capture_model_text(required=(\"inside_ok\",), min_requests=2),\n)\nRECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"control\",\n declared_tools=(\"glob\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n blocking=False,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply typed workspace-glob control rules without parsing tool prose.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower() in {\"glob\", \"find_files\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n source = getattr(observation, str(params[\"source\"]))\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in source for marker in params[\"required\"])\n and all(marker not in source for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "glob_truncation_keeps_sorted_end", "family": "file", "category": "file operations", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["glob_finds_inside_control"], "requires": [], "summary": "Verify a truncated glob result keeps the sorted tail instead of only old entries.", "description": "Verify a truncated glob result keeps the sorted tail instead of only old entries.\n1. Enable yolo mode and seed one old file plus 800 numbered ``.ordx`` files through Bash.\n2. Search the workspace with the nested recursive glob pattern.\n3. Capture model text containing the suffix and excluding the oldest-file marker.\n4. Pass when the sorted result reaches the expected tail and execution is clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/glob_truncation_keeps_sorted_end.py", "source_code": "\"\"\"Verify a truncated glob result keeps the sorted tail instead of only old entries.\n1. Enable yolo mode and seed one old file plus 800 numbered ``.ordx`` files through Bash.\n2. Search the workspace with the nested recursive glob pattern.\n3. Capture model text containing the suffix and excluding the oldest-file marker.\n4. Pass when the sorted result reaches the expected tail and execution is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"glob_truncation_keeps_sorted_end\"\nSTEPS = (\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\n \"bash\",\n turn=1,\n command=(\n \"mkdir -p gord && python3 -c \\\"import pathlib;pathlib.Path('gord/OLD'\"\n \" + 'EST_7755.ordx').write_text('x')\\\" && touch -t 200001010000 \"\n \"gord/OLD*_7755.ordx && python3 -c \\\"import os\\n\"\n \"for i in range(800): open('gord/n%d.ordx' % i,'w').write('x')\\\"\"\n \" && echo ORD_SEEDED_7755\"\n ),\n ),\n tool_round(\"glob\", turn=2, arguments_nested=True, pattern=\"**/*.ordx\"),\n capture_model_text(\n required=(\".ordx\",),\n forbidden=(\"OLDEST_7755\",),\n min_requests=2,\n ),\n)\nRECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"reject\",\n declared_tools=(\"glob\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n dependencies=((\"glob_finds_inside_control\", DependencyKind.GATE),),\n blocking=True,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply typed glob-tail rules without parsing tool prose.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str and item.strip().lower() in {\"glob\", \"find_files\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n source = getattr(observation, str(params[\"source\"]))\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in source for marker in params[\"required\"])\n and all(marker not in source for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "grep_default_mode_returns_path_control", "family": "file", "category": "file operations", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Confirm default grep output reports matching paths without line content.", "description": "Confirm default grep output reports matching paths without line content.\n1. Seed a file containing a unique marker and enable yolo mode.\n2. Run a live Bash probe and grep with the path-only output mode.\n3. Capture the typed grep result and a completion marker from the follow-up round.\n4. Pass when the filename is present, content and line-number output are absent, and execution is clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/grep_default_mode_returns_path_control.py", "source_code": "\"\"\"Confirm default grep output reports matching paths without line content.\n1. Seed a file containing a unique marker and enable yolo mode.\n2. Run a live Bash probe and grep with the path-only output mode.\n3. Capture the typed grep result and a completion marker from the follow-up round.\n4. Pass when the filename is present, content and line-number output are absent, and execution is clean.\n\"\"\"\n\nimport re\nfrom dataclasses import replace\n\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_fact,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"grep_default_mode_returns_path_control\"\nSTEPS = (\n write_fixture(\"f9_9931.txt\", \"F9NEEDLE_7755 ctxf9_9931\\n\"),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\n \"grep\",\n turn=1,\n arguments_nested=True,\n pattern=\"F9NEEDLE_7755\",\n path=\".\",\n output_mode=\"files_with_matches\",\n ),\n tool_round(\"bash\", turn=2, command=\"echo F9C_DONE_7755\"),\n capture_fact(\n \"target_tool_result\",\n required=(\"f9_9931.txt\",),\n forbidden=(\"ctxf9_9931\",),\n forbidden_regex=r\"(?:^|\\n)\\s*[^:\\n]+:\\s*\\d+\\s*(?:\\n|$)\",\n min_requests=2,\n ),\n)\nRECIPE = replace(\n compile_file_tool_steps(\n STEPS,\n case_kind=\"control\",\n declared_tools=(\"grep\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n blocking=True,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n ),\n # The parameter order is part of the frozen recipe identity.\n oracle_parameters=(\n (\"source\", \"target_tool_result\"),\n (\"required\", (\"f9_9931.txt\",)),\n (\"forbidden\", (\"ctxf9_9931\",)),\n (\n \"forbidden_regex\",\n r\"(?:^|\\n)\\s*[^:\\n]+:\\s*\\d+\\s*(?:\\n|$)\",\n ),\n (\"min_requests\", 2),\n ),\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply typed path-only grep rules without parsing tool prose.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower() in {\"grep\", \"search_files\", \"ripgrep\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n source = getattr(observation, str(params[\"source\"]))\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in source for marker in params[\"required\"])\n and all(marker not in source for marker in params[\"forbidden\"])\n and (\n params.get(\"forbidden_regex\") is None\n or re.search(str(params[\"forbidden_regex\"]), source, re.MULTILINE) is None\n )\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "grep_finds_needle_control", "family": "file", "category": "file operations", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Confirm that grep finds a known marker in an ordinary workspace file.", "description": "Confirm that grep finds a known marker in an ordinary workspace file.\n1. Seed a text file containing the unique marker and enable yolo mode.\n2. Establish a live Bash probe and search the workspace for the marker.\n3. Capture the model text that should name the matching file.\n4. Pass when the filename is reported and execution remains clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/grep_finds_needle_control.py", "source_code": "\"\"\"Confirm that grep finds a known marker in an ordinary workspace file.\n1. Seed a text file containing the unique marker and enable yolo mode.\n2. Establish a live Bash probe and search the workspace for the marker.\n3. Capture the model text that should name the matching file.\n4. Pass when the filename is reported and execution remains clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"grep_finds_needle_control\"\nSTEPS = (\n write_fixture(\"plain_gi.txt\", \"NEEDLE_GI_7731 here\\n\"),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\n \"grep\",\n turn=1,\n arguments_nested=True,\n pattern=\"NEEDLE_GI_7731\",\n path=\".\",\n ),\n capture_model_text(required=(\"plain_gi.txt\",), min_requests=2),\n)\nRECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"control\",\n declared_tools=(\"grep\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n blocking=False,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply the typed grep-result contract without inspecting tool prose.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower() in {\"grep\", \"search_files\", \"ripgrep\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in observation.model_text for marker in params[\"required\"])\n and all(marker not in observation.model_text for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "grep_head_limit_zero_not_unlimited", "family": "file", "category": "file operations", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["grep_default_mode_returns_path_control"], "requires": [], "summary": "Reject interpreting a zero grep head limit as an unlimited result.", "description": "Reject interpreting a zero grep head limit as an unlimited result.\n1. Seed a marked file, enable yolo mode, and establish a live Bash round.\n2. Search with the nested grep tool using a zero head limit.\n3. Run a follow-up completion probe and capture required/forbidden markers.\n4. Pass when the completion marker appears without leaking the matching filename.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/grep_head_limit_zero_not_unlimited.py", "source_code": "\"\"\"Reject interpreting a zero grep head limit as an unlimited result.\n1. Seed a marked file, enable yolo mode, and establish a live Bash round.\n2. Search with the nested grep tool using a zero head limit.\n3. Run a follow-up completion probe and capture required/forbidden markers.\n4. Pass when the completion marker appears without leaking the matching filename.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"grep_head_limit_zero_not_unlimited\"\nSTEPS = (\n write_fixture(\"f9_9931.txt\", \"F9NEEDLE_7755 ctxf9_9931\\n\"),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\n \"grep\",\n turn=1,\n arguments_nested=True,\n pattern=\"F9NEEDLE_7755\",\n path=\".\",\n head_limit=0,\n ),\n tool_round(\"bash\", turn=2, command=\"echo HZ9_DONE_7755\"),\n capture_model_text(\n required=(\"HZ9_DONE_7755\",),\n forbidden=(\"f9_9931\",),\n min_requests=2,\n ),\n)\nRECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"reject\",\n declared_tools=(\"grep\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n dependencies=((\"grep_default_mode_returns_path_control\", DependencyKind.GATE),),\n blocking=True,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply typed zero-limit output rules without parsing tool prose.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower() in {\"grep\", \"search_files\", \"ripgrep\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in observation.model_text for marker in params[\"required\"])\n and all(marker not in observation.model_text for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "grep_type_filter_ignored", "family": "file", "category": "file operations", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["grep_finds_needle_control"], "requires": [], "summary": "Verify grep type filtering includes Python matches and excludes text files.", "description": "Verify grep type filtering includes Python matches and excludes text files.\n1. Seed matching Python and text files, then enable yolo mode.\n2. Establish a live Bash round and search with the nested grep ``type=py`` filter.\n3. Capture the model text containing the accepted and rejected paths.\n4. Pass when only the Python path is reported and execution is clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/grep_type_filter_ignored.py", "source_code": "\"\"\"Verify grep type filtering includes Python matches and excludes text files.\n1. Seed matching Python and text files, then enable yolo mode.\n2. Establish a live Bash round and search with the nested grep ``type=py`` filter.\n3. Capture the model text containing the accepted and rejected paths.\n4. Pass when only the Python path is reported and execution is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"grep_type_filter_ignored\"\nSTEPS = (\n write_fixture(\"gt_hit.py\", \"NEEDLE_GTYPE_7731 python\\n\"),\n write_fixture(\"gt_hit.txt\", \"NEEDLE_GTYPE_7731 text\\n\"),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\n \"grep\",\n turn=1,\n arguments_nested=True,\n pattern=\"NEEDLE_GTYPE_7731\",\n path=\".\",\n type=\"py\",\n ),\n capture_model_text(\n required=(\"gt_hit.py\",),\n forbidden=(\"gt_hit.txt\",),\n min_requests=2,\n ),\n)\nRECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"reject\",\n declared_tools=(\"grep\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n dependencies=((\"grep_finds_needle_control\", DependencyKind.GATE),),\n blocking=False,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply typed type-filter output rules without parsing tool prose.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower() in {\"grep\", \"search_files\", \"ripgrep\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in observation.model_text for marker in params[\"required\"])\n and all(marker not in observation.model_text for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "memory_get_abs_path_escapes_workspace", "family": "file", "category": "file operations", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["p32_ctl_memory_get_reads_inside_workspace"], "requires": [], "summary": "Ensure an absolute memory path cannot expose a secret outside the workspace.", "description": "Ensure an absolute memory path cannot expose a secret outside the workspace.\n1. Enable yolo mode and create an external secret through two live Bash rounds.\n2. Request the absolute external path through both memory-get aliases.\n3. Complete with a Bash marker round after the fenced request.\n4. Pass when typed model text reports completion without the external secret.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/memory_get_abs_path_escapes_workspace.py", "source_code": "\"\"\"Ensure an absolute memory path cannot expose a secret outside the workspace.\n1. Enable yolo mode and create an external secret through two live Bash rounds.\n2. Request the absolute external path through both memory-get aliases.\n3. Complete with a Bash marker round after the fenced request.\n4. Pass when typed model text reports completion without the external secret.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"memory_get_abs_path_escapes_workspace\"\nSTEPS = (\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\n \"bash\",\n turn=1,\n command=(\n \"python3 -c \\\"open('/tmp/msec_9932.txt','w').write('MEMSECRET' + \"\n \"'_7732' + chr(10))\\\" && echo P32A_SEEDED_7755\"\n ),\n ),\n tool_round(\n (\"memory_get\", \"memory-get\"),\n turn=2,\n aliases_explicit=True,\n arguments_nested=True,\n path=\"/tmp/msec_9932.txt\",\n ),\n tool_round(\"bash\", turn=3, command=\"echo P32A_DONE_7755\"),\n capture_model_text(\n required=(\"P32A_DONE_7755\",),\n forbidden=(\"MEMSECRET_7732\",),\n min_requests=2,\n ),\n)\nRECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"reject\",\n declared_tools=(\"memory_get\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n dependencies=((\"p32_ctl_memory_get_reads_inside_workspace\", DependencyKind.GATE),),\n blocking=True,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply the typed text rule with the family's shared applicability semantics.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower().replace(\"-\", \"_\") == \"memory_get\"\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in observation.model_text for marker in params[\"required\"])\n and all(marker not in observation.model_text for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "notebook_edit_cell_isolation", "family": "file", "category": "file operations", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify notebook editing changes only the selected cell.", "description": "Verify notebook editing changes only the selected cell.\n1. Seed three cells, enable yolo mode, and read the notebook beside a live Bash probe.\n2. Replace cell 1 through the explicit notebook-edit alias pair.\n3. Dump the notebook in a later Bash round and capture its typed notebook fact.\n4. Pass when cell 1 is new while cells 0 and 2 retain their exact JSON structure and execution is clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/notebook_edit_cell_isolation.py", "source_code": "\"\"\"Verify notebook editing changes only the selected cell.\n1. Seed three cells, enable yolo mode, and read the notebook beside a live Bash probe.\n2. Replace cell 1 through the explicit notebook-edit alias pair.\n3. Dump the notebook in a later Bash round and capture its typed notebook fact.\n4. Pass when cell 1 is new while cells 0 and 2 retain their exact JSON structure and execution is clean.\n\"\"\"\n\nimport json\nfrom dataclasses import replace\n\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_fact,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"notebook_edit_cell_isolation\"\nSTEPS = (\n write_fixture(\n \"nb.ipynb\",\n '{\"cells\": [{\"cell_type\": \"markdown\", \"metadata\": {\"tags\": '\n '[\"KEEP0\"], \"nested\": {\"k\": 0}}, \"source\": [\"CELL0_KEEP\\\\n\"]}, '\n '{\"cell_type\": \"code\", \"metadata\": {\"target\": true}, \"source\": '\n '[\"CELL1_OLD\\\\n\"], \"outputs\": [], \"execution_count\": null}, '\n '{\"cell_type\": \"code\", \"metadata\": {\"tags\": [\"KEEP2\"], \"nested\": '\n '{\"k\": 2}}, \"source\": [\"CELL2_KEEP\\\\n\"], \"outputs\": '\n '[{\"output_type\": \"stream\", \"name\": \"stdout\", \"text\": '\n '[\"KEEP2_OUTPUT\\\\n\"]}], \"execution_count\": 42}], \"metadata\": {}, '\n '\"nbformat\": 4, \"nbformat_minor\": 5}',\n ),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\"read\", turn=1, arguments_nested=True, file_path=\"nb.ipynb\"),\n tool_round(\n (\"notebook_edit\", \"notebook-edit\"),\n turn=2,\n aliases_explicit=True,\n arguments_nested=True,\n file_path=\"nb.ipynb\",\n cell_index=1,\n mode=\"replace\",\n source=\"CELL1_NEW\",\n ),\n tool_round(\"bash\", turn=3, command=\"cat nb.ipynb\"),\n capture_fact(\"nb\", required=(), min_requests=2),\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_COMPILED_RECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"reject\",\n declared_tools=(\"notebook_edit\",),\n oracle_profile=FileToolOracleProfile.NOTEBOOK_ISOLATED,\n blocking=True,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n bind_oracle_parameters=True,\n)\nRECIPE = replace(\n _COMPILED_RECIPE,\n setup_commands=_BASE_SCENARIO.recipe.setup_commands,\n seed_files=_BASE_SCENARIO.recipe.seed_files,\n rounds=_BASE_SCENARIO.recipe.rounds,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply the typed notebook-isolation contract.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower().replace(\"-\", \"_\") == \"notebook_edit\"\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.NOTEBOOK_ISOLATED.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n raw = dict(observation.facts).get(\"nb\")\n try:\n notebook = json.loads(raw) if type(raw) is str else None\n except (json.JSONDecodeError, TypeError, ValueError):\n notebook = None\n cells = notebook.get(\"cells\") if isinstance(notebook, dict) else None\n shape = isinstance(cells, list) and len(cells) == 3\n blob = json.dumps(cells, ensure_ascii=False) if shape else \"\"\n cell0 = (\n json.dumps(cells[0], ensure_ascii=False, sort_keys=True, separators=(\",\", \":\"))\n if shape\n else \"\"\n )\n cell2 = (\n json.dumps(cells[2], ensure_ascii=False, sort_keys=True, separators=(\",\", \":\"))\n if shape\n else \"\"\n )\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and shape\n and str(params[\"new_marker\"]) in blob\n and str(params[\"old_marker\"]) not in blob\n and cell0 == params[\"expected_cell0_json\"]\n and cell2 == params[\"expected_cell2_json\"]\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.NOTEBOOK_ISOLATED.value\n if passed\n else f\"{FileToolOracleProfile.NOTEBOOK_ISOLATED.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "notebook_edit_delete_keeps_neighbors", "family": "file", "category": "file operations", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": [], "requires": ["notebook_edit_cell_isolation"], "summary": "Verify notebook deletion removes only the selected cell.", "description": "Verify notebook deletion removes only the selected cell.\n1. Seed three cells, enable yolo mode, and read the notebook beside a live Bash probe.\n2. Delete cell 1 through the explicit notebook-edit alias pair.\n3. Count the remaining cells in a later Bash round and capture model text.\n4. Pass when exactly two cells remain and execution is clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/notebook_edit_delete_keeps_neighbors.py", "source_code": "\"\"\"Verify notebook deletion removes only the selected cell.\n1. Seed three cells, enable yolo mode, and read the notebook beside a live Bash probe.\n2. Delete cell 1 through the explicit notebook-edit alias pair.\n3. Count the remaining cells in a later Bash round and capture model text.\n4. Pass when exactly two cells remain and execution is clean.\n\"\"\"\n\nfrom dataclasses import replace\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"notebook_edit_delete_keeps_neighbors\"\nSTEPS = (\n write_fixture(\n \"nb.ipynb\",\n '{\"cells\": [{\"cell_type\": \"markdown\", \"metadata\": '\n '{\"tags\": [\"KEEP0\"], \"nested\": {\"k\": 0}}, \"source\": '\n '[\"CELL0_KEEP\\\\n\"]}, {\"cell_type\": \"code\", \"metadata\": '\n '{\"target\": true}, \"source\": [\"CELL1_OLD\\\\n\"], \"outputs\": [], '\n '\"execution_count\": null}, {\"cell_type\": \"code\", \"metadata\": '\n '{\"tags\": [\"KEEP2\"], \"nested\": {\"k\": 2}}, \"source\": '\n '[\"CELL2_KEEP\\\\n\"], \"outputs\": [{\"output_type\": \"stream\", '\n '\"name\": \"stdout\", \"text\": [\"KEEP2_OUTPUT\\\\n\"]}], '\n '\"execution_count\": 42}], \"metadata\": {}, \"nbformat\": 4, '\n '\"nbformat_minor\": 5}',\n ),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\"read\", turn=1, arguments_nested=True, file_path=\"nb.ipynb\"),\n tool_round(\n (\"notebook_edit\", \"notebook-edit\"),\n turn=2,\n aliases_explicit=True,\n arguments_nested=True,\n file_path=\"nb.ipynb\",\n cell_index=1,\n mode=\"delete\",\n ),\n tool_round(\n \"bash\",\n turn=3,\n command=(\n 'python3 -c \"import json;print(\\'NBCELLS\\' + \\'_\\' + '\n 'str(len(json.load(open(\\'nb.ipynb\\'))[\\'cells\\'])))\" '\n '&& echo NBDEL_DONE_7755'\n ),\n ),\n capture_model_text(required=(\"NBCELLS_2\",), forbidden=(), min_requests=2),\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_COMPILED_RECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"reject\",\n declared_tools=(\"notebook_edit\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n dependencies=((\"notebook_edit_cell_isolation\", DependencyKind.REQUIREMENT),),\n blocking=True,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n bind_oracle_parameters=True,\n)\nRECIPE = replace(\n _COMPILED_RECIPE,\n setup_commands=_BASE_SCENARIO.recipe.setup_commands,\n seed_files=_BASE_SCENARIO.recipe.seed_files,\n rounds=_BASE_SCENARIO.recipe.rounds,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply the typed cell-count contract while preserving notebook semantics.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower().replace(\"-\", \"_\") == \"notebook_edit\"\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in observation.model_text for marker in params[\"required\"])\n and all(marker not in observation.model_text for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "p32_ctl_memory_get_reads_inside_workspace", "family": "file", "category": "file operations", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Confirm memory-get observes a workspace memory file after phase-scoped setup.", "description": "Confirm memory-get observes a workspace memory file after phase-scoped setup.\n1. Seed `MEMORY.md`, enable yolo mode, and run the phase-1 live Bash control round.\n2. In phase 2, request the memory file through both memory-get aliases.\n3. Emit a completion marker and capture separate phase-1/phase-2 model facts.\n4. Pass when the marker count increases in phase 2 and all execution surfaces remain clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/p32_ctl_memory_get_reads_inside_workspace.py", "source_code": "\"\"\"Confirm memory-get observes a workspace memory file after phase-scoped setup.\n1. Seed `MEMORY.md`, enable yolo mode, and run the phase-1 live Bash control round.\n2. In phase 2, request the memory file through both memory-get aliases.\n3. Emit a completion marker and capture separate phase-1/phase-2 model facts.\n4. Pass when the marker count increases in phase 2 and all execution surfaces remain clean.\n\"\"\"\n\nfrom dataclasses import replace\n\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_fact,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"p32_ctl_memory_get_reads_inside_workspace\"\nSTEPS = (\n write_fixture(\"MEMORY.md\", \"INSIDEMEM_7732\\n\"),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\n (\"memory_get\", \"memory-get\"),\n turn=2,\n aliases_explicit=True,\n arguments_nested=True,\n path=\"MEMORY.md\",\n ),\n tool_round(\"bash\", turn=3, command=\"echo P32A_DONE_7755\"),\n capture_fact(\"phase2_model_text\", required=(\"INSIDEMEM_7732\",), min_requests=2),\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_COMPILED_RECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"control\",\n declared_tools=(\"memory_get\",),\n oracle_profile=FileToolOracleProfile.MEMORY_EVENT,\n blocking=True,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n bind_oracle_parameters=True,\n)\nRECIPE = replace(\n _COMPILED_RECIPE,\n setup_commands=_BASE_SCENARIO.recipe.setup_commands,\n seed_files=_BASE_SCENARIO.recipe.seed_files,\n rounds=_BASE_SCENARIO.recipe.rounds,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply the typed phase-scoped memory-event and completion contract.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower().replace(\"-\", \"_\") in {\"memory_get\", \"memoryget\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.MEMORY_EVENT.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n facts = dict(observation.facts)\n before = facts.get(\"phase1_model_text\")\n after = facts.get(\"phase2_model_text\")\n marker = str(params[\"marker\"])\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and type(before) is str\n and type(after) is str\n and after.count(marker) > before.count(marker)\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.MEMORY_EVENT.value\n if passed\n else f\"{FileToolOracleProfile.MEMORY_EVENT.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "read_char_device_bounded", "family": "file", "category": "file operations", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["read_regular_file_control"], "requires": [], "summary": "Reject reading a character device while keeping the later round usable.", "description": "Reject reading a character device while keeping the later round usable.\n1. Enable normal yolo mode and start with a live Bash round.\n2. Ask the read tool to inspect the bounded character-device path.\n3. Send a later Bash round that emits the completion marker.\n4. Pass when the completion marker is reported without forbidden output or leaks.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/read_char_device_bounded.py", "source_code": "\"\"\"Reject reading a character device while keeping the later round usable.\n1. Enable normal yolo mode and start with a live Bash round.\n2. Ask the read tool to inspect the bounded character-device path.\n3. Send a later Bash round that emits the completion marker.\n4. Pass when the completion marker is reported without forbidden output or leaks.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolRawObservation,\n FileToolOracleProfile,\n FileToolScenario,\n FileToolOutcome,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"read_char_device_bounded\"\nSTEPS = (\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\"read\", turn=2, arguments_nested=True, file_path=\"/dev/urandom\"),\n tool_round(\n \"bash\",\n turn=3,\n command='python3 -c \"print(\\'DEVREAD\\' + \\'_DONE_7755\\')\"',\n ),\n capture_model_text(required=(\"DEVREAD_DONE_7755\",), min_requests=2),\n)\nRECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"reject\",\n declared_tools=(\"read\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n dependencies=((\"read_regular_file_control\", DependencyKind.GATE),),\n blocking=True,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply this reject point's completion-marker rule to typed evidence.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str and item.strip().lower() in {\"read\", \"cat\", \"view_file\", \"open_file\", \"file_read\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in observation.model_text for marker in params[\"required\"])\n and all(marker not in observation.model_text for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "read_regular_file_control", "family": "file", "category": "file operations", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Control: reading a regular file must expose its contents to the model.", "description": "Control: reading a regular file must expose its contents to the model.\n1. Seed a regular text file and enable the normal yolo startup mode.\n2. Keep a live Bash round, then ask the read tool for the seeded file.\n3. Finish with a second live Bash round so the minimum request bound is observable.\n4. Pass when the model reports the file marker and all observed resources are clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/read_regular_file_control.py", "source_code": "\"\"\"Control: reading a regular file must expose its contents to the model.\n1. Seed a regular text file and enable the normal yolo startup mode.\n2. Keep a live Bash round, then ask the read tool for the seeded file.\n3. Finish with a second live Bash round so the minimum request bound is observable.\n4. Pass when the model reports the file marker and all observed resources are clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolRawObservation,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"read_regular_file_control\"\nSTEPS = (\n write_fixture(\"reg_9941.txt\", \"REGULAR_7731\\n\"),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\"read\", turn=2, arguments_nested=True, file_path=\"reg_9941.txt\"),\n tool_round(\n \"bash\",\n turn=3,\n command='python3 -c \"print(\\'DEVREAD\\' + \\'_DONE_7755\\')\"',\n ),\n capture_model_text(required=(\"REGULAR_7731\",), min_requests=2),\n)\nRECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"control\",\n declared_tools=(\"read\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n blocking=True,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef _read_advertised(observation: FileToolRawObservation) -> bool:\n aliases = {\"read\", \"cat\", \"view_file\", \"open_file\", \"file_read\"}\n return any(\n type(item) is str and item.strip().lower() in aliases\n for item in observation.advertised_tools\n )\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply this control's text rule with the family's shared applicability semantics.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n if not _read_advertised(observation):\n if not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n passed = False\n else:\n parameters = dict(RECIPE.oracle_parameters)\n passed = (\n observation.request_count >= int(parameters[\"min_requests\"])\n and observation.live\n and all(\n marker in observation.model_text\n for marker in parameters[\"required\"]\n )\n and all(\n marker not in observation.model_text\n for marker in parameters[\"forbidden\"]\n )\n )\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = passed and clean\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "read_via_symlink_outside_workspace_bounded", "family": "file", "category": "file operations", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["file_symlink_inside_still_readable_control", "symlink_to_outside_target_readable_control"], "requires": [], "summary": "Reject a symlink escape while proving the later tool round remains live.", "description": "Reject a symlink escape while proving the later tool round remains live.\n1. Enable yolo mode and create a secret file outside the workspace with a link to it.\n2. Read the workspace link through the nested read call after a live Bash round.\n3. Send a later Bash completion marker after the boundary decision.\n4. Pass when completion is visible, the outside secret is absent, and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/read_via_symlink_outside_workspace_bounded.py", "source_code": "\"\"\"Reject a symlink escape while proving the later tool round remains live.\n1. Enable yolo mode and create a secret file outside the workspace with a link to it.\n2. Read the workspace link through the nested read call after a live Bash round.\n3. Send a later Bash completion marker after the boundary decision.\n4. Pass when completion is visible, the outside secret is absent, and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"read_via_symlink_outside_workspace_bounded\"\nSTEPS = (\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\n \"bash\",\n turn=1,\n command=(\n \"python3 -c \\\"open('/tmp/secr_9931.txt','w').write(\"\n \"'OUTSECRET' + '_7731' + chr(10))\\\" && \"\n \"ln -sf /tmp/secr_9931.txt ls_9931.txt && echo RS6_SEEDED_7755\"\n ),\n ),\n tool_round(\"read\", turn=2, arguments_nested=True, file_path=\"ls_9931.txt\"),\n tool_round(\"bash\", turn=3, command=\"echo RS6_DONE_7755\"),\n capture_model_text(\n required=(\"RS6_DONE_7755\",),\n forbidden=(\"OUTSECRET_7731\",),\n min_requests=2,\n ),\n)\nRECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"reject\",\n declared_tools=(\"read\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n dependencies=(\n (\"symlink_to_outside_target_readable_control\", DependencyKind.GATE),\n (\"file_symlink_inside_still_readable_control\", DependencyKind.GATE),\n ),\n blocking=True,\n execution_parameters=(\n (\"deny\", ()),\n (\"allow\", \"echo PERM_LIVE_7755 > live.txt\"),\n ),\n bind_oracle_parameters=True,\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply the typed completion/secret boundary rules for this symlink probe.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str\n and item.strip().lower() in {\"read\", \"cat\", \"view_file\", \"open_file\", \"file_read\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in observation.model_text for marker in params[\"required\"])\n and all(marker not in observation.model_text for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "rewind_restores_edited_file", "family": "file", "category": "file operations", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["undo_reverts_overwrite_control"], "requires": [], "summary": "Verify rewind restores an overwritten file from an earlier snapshot.", "description": "Verify rewind restores an overwritten file from an earlier snapshot.\n1. Seed the target, enable yolo mode, read it beside a live Bash probe, and overwrite it.\n2. Rewind through the available history boundary.\n3. Run a post-rewind probe and capture the phase snapshots.\n4. Pass when the rewind restores the expected original content and execution is clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/rewind_restores_edited_file.py", "source_code": "\"\"\"Verify rewind restores an overwritten file from an earlier snapshot.\n1. Seed the target, enable yolo mode, read it beside a live Bash probe, and overwrite it.\n2. Rewind through the available history boundary.\n3. Run a post-rewind probe and capture the phase snapshots.\n4. Pass when the rewind restores the expected original content and execution is clean.\n\"\"\"\n\nfrom dataclasses import replace\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_fact,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"rewind_restores_edited_file\"\nSTEPS = (\n write_fixture(\"tgt.txt\", \"ORIG_PERM_0001\\n\"),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\"read\", turn=1, arguments_nested=True, file_path=\"tgt.txt\"),\n tool_round(\n \"write\",\n turn=2,\n arguments_nested=True,\n file_path=\"tgt.txt\",\n content=\"RWOVR_8821\\n\",\n ),\n tool_round(\"bash\", turn=3, command=\"echo POSTRW_8821\"),\n capture_fact(\"target_content\", required=(), min_requests=2),\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_COMPILED_RECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"reject\",\n declared_tools=(\"write\",),\n oracle_profile=FileToolOracleProfile.REWIND_RESTORES,\n dependencies=((\"undo_reverts_overwrite_control\", DependencyKind.GATE),),\n blocking=False,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n bind_oracle_parameters=True,\n)\nRECIPE = replace(\n _COMPILED_RECIPE,\n setup_commands=_BASE_SCENARIO.recipe.setup_commands,\n seed_files=_BASE_SCENARIO.recipe.seed_files,\n rounds=_BASE_SCENARIO.recipe.rounds,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply the typed rewind-restores contract to phase snapshots.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str and item.strip().lower() in {\"write\", \"file_write\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.REWIND_RESTORES.value,\n ),\n )\n facts = dict(observation.facts)\n params = dict(RECIPE.oracle_parameters)\n expected = str(params[\"expected\"])\n before = facts.get(\"phase1_tgt\")\n unknown = facts.get(\"rewind_unknown\") is True\n if (unknown or before == expected) and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.REWIND_RESTORES.value,\n ),\n )\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and facts.get(\"after_mid1_tgt\") == expected\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.REWIND_RESTORES.value\n if passed\n else f\"{FileToolOracleProfile.REWIND_RESTORES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "symlink_to_outside_target_readable_control", "family": "file", "category": "file operations", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Confirm a workspace symlink can read its outside target in the control path.", "description": "Confirm a workspace symlink can read its outside target in the control path.\n1. Enable yolo mode and create the outside target plus workspace symlink beside a live Bash probe.\n2. Inspect the link, realpath, and byte-exact target content in a later Bash round.\n3. Capture the three typed symlink markers from model text.\n4. Pass when link identity, destination, bytes, and execution cleanliness all hold.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/symlink_to_outside_target_readable_control.py", "source_code": "\"\"\"Confirm a workspace symlink can read its outside target in the control path.\n1. Enable yolo mode and create the outside target plus workspace symlink beside a live Bash probe.\n2. Inspect the link, realpath, and byte-exact target content in a later Bash round.\n3. Capture the three typed symlink markers from model text.\n4. Pass when link identity, destination, bytes, and execution cleanliness all hold.\n\"\"\"\n\nfrom dataclasses import replace\n\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_model_text,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"symlink_to_outside_target_readable_control\"\nSTEPS = (\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\n \"bash\",\n turn=1,\n command=(\n \"printf 'OUTSIDE_ORIG_7731\\\\n' > /tmp/outside_9931.txt && \"\n \"ln -sf /tmp/outside_9931.txt link_9931.txt && echo SYMCTL_DONE_7755\"\n ),\n ),\n tool_round(\n \"bash\",\n turn=2,\n command=(\n 'python3 -c \"import os; p=\\'link_9931.txt\\'; '\n \"print('SYM'+'LINK_%d' % os.path.islink(p)); \"\n \"print('SYM'+'REAL_%d' % (os.path.realpath(p)=='/tmp/outside_9931.txt')); \"\n \"print('SYM'+'BYTE_%d' % (open(p,'rb').read()==b'OUTSIDE_ORIG_7731\\\\n'))\"\n ),\n ),\n capture_model_text(\n required=(\"SYMLINK_1\", \"SYMREAL_1\", \"SYMBYTE_1\"),\n forbidden=(),\n min_requests=2,\n ),\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_COMPILED_RECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"control\",\n declared_tools=(\"bash\",),\n oracle_profile=FileToolOracleProfile.TEXT_RULES,\n blocking=True,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n bind_oracle_parameters=True,\n)\nRECIPE = replace(\n _COMPILED_RECIPE,\n setup_commands=_BASE_SCENARIO.recipe.setup_commands,\n seed_files=_BASE_SCENARIO.recipe.seed_files,\n rounds=_BASE_SCENARIO.recipe.rounds,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply the typed symlink-marker contract.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str and item.strip().lower() in {\"bash\", \"shell\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TEXT_RULES.value,\n ),\n )\n params = dict(RECIPE.oracle_parameters)\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(marker in observation.model_text for marker in params[\"required\"])\n and all(marker not in observation.model_text for marker in params[\"forbidden\"])\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TEXT_RULES.value\n if passed\n else f\"{FileToolOracleProfile.TEXT_RULES.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "undo_reverts_overwrite_control", "family": "file", "category": "file operations", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify undo restores the original file after a full overwrite.", "description": "Verify undo restores the original file after a full overwrite.\n1. Seed the target, enable yolo mode, read it beside a live Bash probe, and overwrite it.\n2. Issue undo at the session boundary.\n3. Run a post-undo probe and capture the resulting transition facts.\n4. Pass when the overwrite snapshot and both restored snapshots match exactly and execution is clean.", "source_path": "src/doc2harness/benchmark/harnesses/file/scenarios/undo_reverts_overwrite_control.py", "source_code": "\"\"\"Verify undo restores the original file after a full overwrite.\n1. Seed the target, enable yolo mode, read it beside a live Bash probe, and overwrite it.\n2. Issue undo at the session boundary.\n3. Run a post-undo probe and capture the resulting transition facts.\n4. Pass when the overwrite snapshot and both restored snapshots match exactly and execution is clean.\n\"\"\"\n\nfrom dataclasses import replace\n\nfrom doc2harness.benchmark.harnesses.file.contracts import (\n FileToolApplicability,\n FileToolJudgement,\n FileToolOracleProfile,\n FileToolOutcome,\n FileToolRawObservation,\n FileToolScenario,\n build_file_tool_evaluation,\n capture_fact,\n compile_file_tool_steps,\n setup_command,\n tool_round,\n validate_file_tool_observation,\n write_fixture,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"undo_reverts_overwrite_control\"\nSTEPS = (\n write_fixture(\"tgt.txt\", \"ORIG_PERM_0001\\n\"),\n setup_command(\"/mode yolo\"),\n tool_round(\"bash\", turn=1, command=\"echo PERM_LIVE_7755 > live.txt\"),\n tool_round(\"read\", turn=1, arguments_nested=True, file_path=\"tgt.txt\"),\n tool_round(\n \"write\",\n turn=2,\n arguments_nested=True,\n file_path=\"tgt.txt\",\n content=\"OVR_BODY_7755\\n\",\n ),\n tool_round(\"bash\", turn=3, command=\"echo POSTUNDO_7755\"),\n capture_fact(\"target_content\", required=(), min_requests=2),\n)\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_COMPILED_RECIPE = compile_file_tool_steps(\n STEPS,\n case_kind=\"control\",\n declared_tools=(\"write\",),\n oracle_profile=FileToolOracleProfile.TRANSITION_EXACT,\n dependencies=(),\n blocking=False,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n bind_oracle_parameters=True,\n)\nRECIPE = replace(\n _COMPILED_RECIPE,\n setup_commands=_BASE_SCENARIO.recipe.setup_commands,\n seed_files=_BASE_SCENARIO.recipe.seed_files,\n rounds=_BASE_SCENARIO.recipe.rounds,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n)\nSCENARIO: FileToolScenario = FileToolScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: FileToolRawObservation):\n \"\"\"Apply the typed exact-transition contract to the overwrite undo.\"\"\"\n\n validate_file_tool_observation(SCENARIO, observation)\n advertised = any(\n type(item) is str and item.strip().lower() in {\"write\", \"file_write\"}\n for item in observation.advertised_tools\n )\n if not advertised and not observation.timed_out:\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS,\n FileToolApplicability.INCONCLUSIVE,\n FileToolOracleProfile.TRANSITION_EXACT.value,\n ),\n )\n facts = dict(observation.facts)\n params = dict(RECIPE.oracle_parameters)\n expected = dict(params[\"expected\"])\n passed = (\n advertised\n and observation.request_count >= int(params[\"min_requests\"])\n and observation.live\n and all(facts.get(key) == value for key, value in expected.items())\n and observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n return build_file_tool_evaluation(\n SCENARIO,\n observation,\n FileToolJudgement(\n FileToolOutcome.PASS if passed else FileToolOutcome.FAIL,\n FileToolApplicability.APPLICABLE,\n FileToolOracleProfile.TRANSITION_EXACT.value\n if passed\n else f\"{FileToolOracleProfile.TRANSITION_EXACT.value}_FAILED\",\n ),\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "at_ref_expands_in_headless", "family": "headless", "category": "headless", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["p34_ctl_bare_mention_not_auto_read", "p34_ctl_task_text_reaches_wire"], "requires": [], "summary": "Verify an @file reference reaches the headless model request.", "description": "Verify an @file reference reaches the headless model request.\n\n1. Seed the referenced file and send the summarization task.\n2. Observe the main process and typed request records.\n3. Require a successful run whose request contains the file marker.\n4. Pass only when the reference is observable on the wire.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/at_ref_expands_in_headless.py", "source_code": "\"\"\"Verify an @file reference reaches the headless model request.\n\n1. Seed the referenced file and send the summarization task.\n2. Observe the main process and typed request records.\n3. Require a successful run whose request contains the file marker.\n4. Pass only when the reference is observable on the wire.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability,\n HeadlessJudgement,\n HeadlessObservation,\n HeadlessOutcome,\n HeadlessScenario,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"at_ref_expands_in_headless\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n run = next((item for item in observation.runs if item.label == \"main\"), None)\n if run is None or run.rc != 0 or not run.requests:\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.INCONCLUSIVE,\n \"HEADLESS_PROBE_UNOBSERVED\",\n )\n passed = any(\n RECIPE.probe_token in request.body or RECIPE.probe_token in request.probe_hits\n for request in run.requests\n )\n return HeadlessJudgement(\n HeadlessOutcome.PASS if passed else HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_PROFILE_CHECKED\",\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "budget_type_domain", "family": "headless", "category": "headless", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["budget_type_domain_control"], "requires": [], "summary": "Verify that invalid budget types and values are rejected before execution.", "description": "Verify that invalid budget types and values are rejected before execution.\n\n1. Run valid budget probes followed by boolean, string, float, and negative probes.\n2. Capture exit status, request count, and submission status for each variant.\n3. Require valid probes to submit normally with one request.\n4. Require every invalid probe to fail without a request or accepted status.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/budget_type_domain.py", "source_code": "\"\"\"Verify that invalid budget types and values are rejected before execution.\n\n1. Run valid budget probes followed by boolean, string, float, and negative probes.\n2. Capture exit status, request count, and submission status for each variant.\n3. Require valid probes to submit normally with one request.\n4. Require every invalid probe to fail without a request or accepted status.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability,\n HeadlessJudgement,\n HeadlessObservation,\n HeadlessOutcome,\n HeadlessScenario,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"budget_type_domain\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n \"\"\"Check valid budgets and fail-closed behavior for every invalid variant.\"\"\"\n\n labels = tuple(probe.label for probe in RECIPE.formal_runtime_probes)\n by_label = {run.label: run for run in observation.runs}\n runs = tuple(by_label.get(label) for label in labels)\n if any(\n run is None\n or run.start_error\n or run.timed_out\n or not run.cleanup_complete\n or not run.exit_status\n for run in runs\n ):\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_FORMAL_MATRIX_INCOMPLETE\",\n )\n valid = runs[:2]\n invalid = runs[2:]\n valid_ok = all(\n run is not None\n and run.rc == 0\n and run.exit_status in {\"Submitted\", \"LimitsExceeded\"}\n and len(run.requests) == 1\n for run in valid\n )\n invalid_ok = all(\n run is not None\n and run.rc not in (None, 0)\n and run.exit_status not in {\"Submitted\", \"LimitsExceeded\"}\n and not run.requests\n for run in invalid\n )\n return HeadlessJudgement(\n HeadlessOutcome.PASS if valid_ok and invalid_ok else HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_PROFILE_CHECKED\",\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "budget_type_domain_control", "family": "headless", "category": "headless", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify that valid budget values are accepted by the headless runtime.", "description": "Verify that valid budget values are accepted by the headless runtime.\n\n1. Run the valid-zero and valid-positive budget probes.\n2. Capture exit status, request count, and submission status for each probe.\n3. Require one request and a successful submitted/limited result per probe.\n4. Return PASS only when the complete valid-budget control matrix is observed.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/budget_type_domain_control.py", "source_code": "\"\"\"Verify that valid budget values are accepted by the headless runtime.\n\n1. Run the valid-zero and valid-positive budget probes.\n2. Capture exit status, request count, and submission status for each probe.\n3. Require one request and a successful submitted/limited result per probe.\n4. Return PASS only when the complete valid-budget control matrix is observed.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability,\n HeadlessJudgement,\n HeadlessObservation,\n HeadlessOutcome,\n HeadlessScenario,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"budget_type_domain_control\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n \"\"\"Check the valid budget probes without evaluating invalid input variants.\"\"\"\n\n labels = tuple(probe.label for probe in RECIPE.formal_runtime_probes)\n by_label = {run.label: run for run in observation.runs}\n runs = tuple(by_label.get(label) for label in labels)\n if any(\n run is None\n or run.start_error\n or run.timed_out\n or not run.cleanup_complete\n or not run.exit_status\n for run in runs\n ):\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_FORMAL_MATRIX_INCOMPLETE\",\n )\n passed = all(\n run is not None\n and run.rc == 0\n and run.exit_status in {\"Submitted\", \"LimitsExceeded\"}\n and len(run.requests) == 1\n for run in runs\n )\n return HeadlessJudgement(\n HeadlessOutcome.PASS if passed else HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_PROFILE_CHECKED\",\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "exec_requires_bg", "family": "headless", "category": "headless", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["exec_requires_bg_control"], "requires": [], "summary": "Check that an orphan --exec is rejected without executing its command.", "description": "Check that an orphan --exec is rejected without executing its command.\n\n1. Run the healthy background control and then the orphan foreground form.\n2. Observe each external return code and marker path in the shared workspace.\n3. Require a closed control and accept only target rc2 with no target marker.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/exec_requires_bg.py", "source_code": "\"\"\"Check that an orphan --exec is rejected without executing its command.\n\n1. Run the healthy background control and then the orphan foreground form.\n2. Observe each external return code and marker path in the shared workspace.\n3. Require a closed control and accept only target rc2 with no target marker.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability, HeadlessJudgement, HeadlessObservation,\n HeadlessOutcome, HeadlessScenario,\n)\nfrom doc2harness.benchmark.harnesses.headless.recipes import scenario_by_id\n\nSCENARIO_ID = \"exec_requires_bg\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nscenario = SCENARIO\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n if len(observation.runs) < 2:\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.INCONCLUSIVE, \"EXEC_BG_TARGET_UNOBSERVED\")\n control, target = observation.runs[:2]\n if not (control.rc == 0 and \"control.marker\" in control.written_paths):\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.INCONCLUSIVE, \"EXEC_BG_CONTROL_GATE_UNSATISFIED\")\n if \"target.marker\" in target.written_paths:\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.APPLICABLE, \"EXEC_BG_ORPHAN_EXECUTED\")\n if target.rc == 2:\n return HeadlessJudgement(HeadlessOutcome.PASS, HeadlessApplicability.APPLICABLE, \"EXEC_BG_ORPHAN_REJECTED\")\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.APPLICABLE, \"EXEC_BG_ORPHAN_NOT_REJECTED\")\n\n\n__all__ = [\"RECIPE\", \"STEPS\", \"definition\", \"scenario\", \"SCENARIO\", \"SCENARIO_ID\", \"judge\"]\n"} | |
| {"scenario_id": "exec_requires_bg_control", "family": "headless", "category": "headless", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Check that the explicit background form executes and writes its marker.", "description": "Check that the explicit background form executes and writes its marker.\n\n1. Launch the artifact with ``--bg ... --exec touch control.marker``.\n2. Observe the external return code and workspace-relative written paths.\n3. Pass only when the process succeeds and the marker is present.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/exec_requires_bg_control.py", "source_code": "\"\"\"Check that the explicit background form executes and writes its marker.\n\n1. Launch the artifact with ``--bg ... --exec touch control.marker``.\n2. Observe the external return code and workspace-relative written paths.\n3. Pass only when the process succeeds and the marker is present.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability, HeadlessJudgement, HeadlessObservation,\n HeadlessOutcome, HeadlessScenario,\n)\nfrom doc2harness.benchmark.harnesses.headless.recipes import scenario_by_id\n\nSCENARIO_ID = \"exec_requires_bg_control\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nscenario = SCENARIO\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n run = observation.runs[0] if observation.runs else None\n if run is None:\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.INCONCLUSIVE, \"EXEC_BG_CONTROL_UNOBSERVED\")\n marker = \"control.marker\" in run.written_paths\n if run.rc == 0 and marker:\n return HeadlessJudgement(HeadlessOutcome.PASS, HeadlessApplicability.APPLICABLE, \"EXEC_BG_CONTROL_CLOSED\")\n if marker and run.rc != 0:\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.APPLICABLE, \"EXEC_BG_CONTROL_CONTRADICTION\")\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.INCONCLUSIVE, \"EXEC_BG_CONTROL_UNOBSERVED\")\n\n\n__all__ = [\"RECIPE\", \"STEPS\", \"definition\", \"scenario\", \"SCENARIO\", \"SCENARIO_ID\", \"judge\"]\n"} | |
| {"scenario_id": "headless_p_json_model_error_wellformed", "family": "headless", "category": "headless", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["headless_p_json_wellformed"], "requires": [], "summary": "Require a model-error headless run to remain a valid JSON error.", "description": "Require a model-error headless run to remain a valid JSON error.\n\n1. Launch the target recipe with the configured model-error gateway.\n2. Capture the main process output and at least one model request.\n3. Parse the response as JSON without relying on human-readable logs.\n4. Pass only when the JSON is valid and the process exits with code one.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/headless_p_json_model_error_wellformed.py", "source_code": "\"\"\"Require a model-error headless run to remain a valid JSON error.\n\n1. Launch the target recipe with the configured model-error gateway.\n2. Capture the main process output and at least one model request.\n3. Parse the response as JSON without relying on human-readable logs.\n4. Pass only when the JSON is valid and the process exits with code one.\n\"\"\"\n\nimport json\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability,\n HeadlessJudgement,\n HeadlessObservation,\n HeadlessOutcome,\n HeadlessScenario,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"headless_p_json_model_error_wellformed\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n \"\"\"Require a live request and a parseable non-success response.\"\"\"\n\n main = next((run for run in observation.runs if run.label == \"main\"), None)\n requests = tuple(request for run in observation.runs for request in run.requests)\n if not observation.cli_available:\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.INCONCLUSIVE,\n \"HEADLESS_CLI_UNAVAILABLE\",\n )\n if observation.driver_error:\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_DRIVER_ERROR\",\n )\n if main is None or not requests:\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.INCONCLUSIVE,\n \"HEADLESS_ERROR_PATH_UNOBSERVED\",\n )\n try:\n value = json.loads(main.stdout.strip())\n except (TypeError, ValueError, json.JSONDecodeError):\n value = None\n passed = value is not None and main.rc == 1\n return HeadlessJudgement(\n HeadlessOutcome.PASS if passed else HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_PROFILE_CHECKED\",\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "headless_p_json_wellformed", "family": "headless", "category": "headless", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Require the normal headless control run to emit clean JSON.", "description": "Require the normal headless control run to emit clean JSON.\n\n1. Launch the control recipe with its fixed JSON response gateway.\n2. Capture the main process output and terminal status.\n3. Parse the output as one JSON value and look for the control sentinel.\n4. Pass only when parsing, sentinel, exit code, and noise constraints hold.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/headless_p_json_wellformed.py", "source_code": "\"\"\"Require the normal headless control run to emit clean JSON.\n\n1. Launch the control recipe with its fixed JSON response gateway.\n2. Capture the main process output and terminal status.\n3. Parse the output as one JSON value and look for the control sentinel.\n4. Pass only when parsing, sentinel, exit code, and noise constraints hold.\n\"\"\"\n\nimport json\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability,\n HeadlessJudgement,\n HeadlessObservation,\n HeadlessOutcome,\n HeadlessScenario,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"headless_p_json_wellformed\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\n# This control uses the fixed-reply recipe without additional scenario-specific\n# setup; retaining the complete recipe as the declarative step preserves every\n# recipe default and makes the selected gateway visible in this file.\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n \"\"\"Check the fixed JSON control response without reading host state.\"\"\"\n\n main = next((run for run in observation.runs if run.label == \"main\"), None)\n if not observation.cli_available:\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.INCONCLUSIVE,\n \"HEADLESS_CLI_UNAVAILABLE\",\n )\n if observation.driver_error:\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_DRIVER_ERROR\",\n )\n if main is None:\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.INCONCLUSIVE,\n \"HEADLESS_MAIN_MISSING\",\n )\n try:\n value = json.loads(main.stdout.strip())\n except (TypeError, ValueError, json.JSONDecodeError):\n value = None\n passed = (\n value is not None\n and RECIPE.oracle.sentinel in json.dumps(value, ensure_ascii=False)\n and main.rc == 0\n and not any(\n marker in main.stdout\n for marker in (\"<function_calls>\", \"<tool_code>\", \"<invoke\", \"<response>\", \"TurnBegin\", \"StepBegin\", \"Traceback (most recent call)\")\n )\n )\n return HeadlessJudgement(\n HeadlessOutcome.PASS if passed else HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_PROFILE_CHECKED\",\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "p34_ctl_bare_mention_not_auto_read", "family": "headless", "category": "headless", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify a bare mention is not automatically read into the request.", "description": "Verify a bare mention is not automatically read into the request.\n\n1. Run the task containing only a bare file mention.\n2. Observe the main process and request records.\n3. Require an observable request without the planted file token.\n4. Pass only when implicit reading is absent.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/p34_ctl_bare_mention_not_auto_read.py", "source_code": "\"\"\"Verify a bare mention is not automatically read into the request.\n\n1. Run the task containing only a bare file mention.\n2. Observe the main process and request records.\n3. Require an observable request without the planted file token.\n4. Pass only when implicit reading is absent.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability,\n HeadlessJudgement,\n HeadlessObservation,\n HeadlessOutcome,\n HeadlessScenario,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"p34_ctl_bare_mention_not_auto_read\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n run = next((r for r in observation.runs if r.label == \"main\"), None)\n if run is None:\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.INCONCLUSIVE,\n \"HEADLESS_MAIN_MISSING\",\n )\n if not run.requests:\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.INCONCLUSIVE,\n \"HEADLESS_REQUEST_UNOBSERVED\",\n )\n present = any(\n RECIPE.probe_token in request.probe_hits or RECIPE.probe_token in request.body\n for request in run.requests\n )\n return HeadlessJudgement(\n HeadlessOutcome.PASS if not present else HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_PROFILE_CHECKED\",\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "p34_ctl_task_text_reaches_wire", "family": "headless", "category": "headless", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify the task text reaches the model request wire.", "description": "Verify the task text reaches the model request wire.\n\n1. Run the task containing the explicit reference text.\n2. Observe the main process and request records.\n3. Require the planted task marker in a request.\n4. Pass only when the marker is transmitted.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/p34_ctl_task_text_reaches_wire.py", "source_code": "\"\"\"Verify the task text reaches the model request wire.\n\n1. Run the task containing the explicit reference text.\n2. Observe the main process and request records.\n3. Require the planted task marker in a request.\n4. Pass only when the marker is transmitted.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability,\n HeadlessJudgement,\n HeadlessObservation,\n HeadlessOutcome,\n HeadlessScenario,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"p34_ctl_task_text_reaches_wire\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n run = next((r for r in observation.runs if r.label == \"main\"), None)\n if run is None or not run.requests:\n return HeadlessJudgement(\n HeadlessOutcome.FAIL,\n HeadlessApplicability.INCONCLUSIVE,\n \"HEADLESS_REQUEST_UNOBSERVED\",\n )\n present = any(\n RECIPE.probe_token in request.probe_hits or RECIPE.probe_token in request.body\n for request in run.requests\n )\n return HeadlessJudgement(\n HeadlessOutcome.PASS if present else HeadlessOutcome.FAIL,\n HeadlessApplicability.APPLICABLE,\n \"HEADLESS_PROFILE_CHECKED\",\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "runtime_error_stdout", "family": "headless", "category": "headless", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["runtime_error_stdout_control"], "requires": [], "summary": "Verify that a model runtime error is surfaced without fake stdout.", "description": "Verify that a model runtime error is surfaced without fake stdout.\n\n1. Run the model-runtime-error formal contract probe.\n2. Capture request count, stdout, return code, and exit status.\n3. Require one request, rc 1, empty stdout, and Error status.\n4. Return PASS only when the runtime error remains honest.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/runtime_error_stdout.py", "source_code": "\"\"\"Verify that a model runtime error is surfaced without fake stdout.\n\n1. Run the model-runtime-error formal contract probe.\n2. Capture request count, stdout, return code, and exit status.\n3. Require one request, rc 1, empty stdout, and Error status.\n4. Return PASS only when the runtime error remains honest.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability,\n HeadlessJudgement,\n HeadlessObservation,\n HeadlessOutcome,\n HeadlessScenario,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"runtime_error_stdout\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n \"\"\"Check honest runtime-error evidence for the target route.\"\"\"\n\n labels = tuple(probe.label for probe in RECIPE.formal_contract_probes)\n by_label = {run.label: run for run in observation.runs}\n runs = tuple(by_label.get(label) for label in labels)\n if any(run is None or run.start_error or run.timed_out or not run.cleanup_complete for run in runs):\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.APPLICABLE, \"HEADLESS_CONTRACT_MATRIX_INCOMPLETE\")\n passed = all(\n run is not None\n and run.rc == 1\n and len(run.requests) == 1\n and run.stdout == \"\"\n and run.exit_status == \"Error\"\n for run in runs\n )\n return HeadlessJudgement(HeadlessOutcome.PASS if passed else HeadlessOutcome.FAIL, HeadlessApplicability.APPLICABLE, \"HEADLESS_PROFILE_CHECKED\")\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "runtime_error_stdout_control", "family": "headless", "category": "headless", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify that a healthy model route returns the canonical reply.", "description": "Verify that a healthy model route returns the canonical reply.\n\n1. Run the model-success formal contract probe.\n2. Capture request count, stdout, return code, and exit status.\n3. Require two requests and the exact submitted reply.\n4. Return PASS only when the control route is fully healthy.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/runtime_error_stdout_control.py", "source_code": "\"\"\"Verify that a healthy model route returns the canonical reply.\n\n1. Run the model-success formal contract probe.\n2. Capture request count, stdout, return code, and exit status.\n3. Require two requests and the exact submitted reply.\n4. Return PASS only when the control route is fully healthy.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability,\n HeadlessJudgement,\n HeadlessObservation,\n HeadlessOutcome,\n HeadlessScenario,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"runtime_error_stdout_control\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n \"\"\"Check the healthy model control response.\"\"\"\n\n labels = tuple(probe.label for probe in RECIPE.formal_contract_probes)\n by_label = {run.label: run for run in observation.runs}\n runs = tuple(by_label.get(label) for label in labels)\n if any(run is None or run.start_error or run.timed_out or not run.cleanup_complete for run in runs):\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.APPLICABLE, \"HEADLESS_CONTRACT_MATRIX_INCOMPLETE\")\n passed = all(\n run is not None\n and run.rc == 0\n and len(run.requests) == 2\n and run.stdout == \"EXACT_REPLY_6047\\n\"\n and run.exit_status == \"Submitted\"\n for run in runs\n )\n return HeadlessJudgement(HeadlessOutcome.PASS if passed else HeadlessOutcome.FAIL, HeadlessApplicability.APPLICABLE, \"HEADLESS_PROFILE_CHECKED\")\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "session_flag_subcommand_conflict", "family": "headless", "category": "headless", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["session_flag_subcommand_conflict_control"], "requires": [], "summary": "Check that --resume is not silently discarded by management commands.", "description": "Check that --resume is not silently discarded by management commands.\n\n1. Run each management command once without and once with a nonexistent session.\n2. Observe return codes and output text for every baseline/flagged pair.\n3. Reject silent rc0 output identical to baseline; accept rc2 or an explicit session error.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/session_flag_subcommand_conflict.py", "source_code": "\"\"\"Check that --resume is not silently discarded by management commands.\n\n1. Run each management command once without and once with a nonexistent session.\n2. Observe return codes and output text for every baseline/flagged pair.\n3. Reject silent rc0 output identical to baseline; accept rc2 or an explicit session error.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability, HeadlessJudgement, HeadlessObservation,\n HeadlessOutcome, HeadlessScenario,\n)\nfrom doc2harness.benchmark.harnesses.headless.recipes import scenario_by_id\n\nSCENARIO_ID = \"session_flag_subcommand_conflict\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nscenario = SCENARIO\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\ndefinition = SCENARIO.definition\n\n\ndef _face_verdict(base, flagged):\n if flagged.rc == 2:\n return \"PASS\"\n blob = (flagged.stdout + \"\\n\" + flagged.stderr).lower()\n mentions = any(token in blob for token in (\"resume\", \"session\", \"conflict\", \"互斥\", \"会话\"))\n if flagged.rc is not None and flagged.rc != 0 and mentions:\n return \"PASS\"\n if flagged.rc == 0 and flagged.stdout.strip() == base.stdout.strip() and not mentions:\n return \"FAIL\"\n return \"INCONCLUSIVE\"\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n if len(observation.runs) < 4:\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.INCONCLUSIVE, \"SESSION_FLAG_MATRIX_INCOMPLETE\")\n verdicts = tuple(_face_verdict(observation.runs[index], observation.runs[index + 1]) for index in (0, 2))\n if \"FAIL\" in verdicts:\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.APPLICABLE, \"SESSION_FLAGS_SILENTLY_DROPPED\")\n if \"PASS\" in verdicts:\n return HeadlessJudgement(HeadlessOutcome.PASS, HeadlessApplicability.APPLICABLE, \"SESSION_FLAGS_REJECTED\")\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.INCONCLUSIVE, \"SESSION_FLAGS_NOT_OBSERVED\")\n\n\n__all__ = [\"RECIPE\", \"STEPS\", \"definition\", \"scenario\", \"SCENARIO\", \"SCENARIO_ID\", \"judge\"]\n"} | |
| {"scenario_id": "session_flag_subcommand_conflict_control", "family": "headless", "category": "headless", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Check that at least one management subcommand has a healthy baseline.", "description": "Check that at least one management subcommand has a healthy baseline.\n\n1. Run memory status and config list without a session flag.\n2. Observe both external return codes in one isolated home/workspace.\n3. Pass when either management face returns rc0; otherwise remain inconclusive.", "source_path": "src/doc2harness/benchmark/harnesses/headless/scenarios/session_flag_subcommand_conflict_control.py", "source_code": "\"\"\"Check that at least one management subcommand has a healthy baseline.\n\n1. Run memory status and config list without a session flag.\n2. Observe both external return codes in one isolated home/workspace.\n3. Pass when either management face returns rc0; otherwise remain inconclusive.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.headless.contracts import (\n HeadlessApplicability, HeadlessJudgement, HeadlessObservation,\n HeadlessOutcome, HeadlessScenario,\n)\nfrom doc2harness.benchmark.harnesses.headless.recipes import scenario_by_id\n\nSCENARIO_ID = \"session_flag_subcommand_conflict_control\"\nSCENARIO: HeadlessScenario = scenario_by_id(SCENARIO_ID)\nscenario = SCENARIO\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: HeadlessObservation) -> HeadlessJudgement:\n if any(run.rc == 0 for run in observation.runs[:2]):\n return HeadlessJudgement(HeadlessOutcome.PASS, HeadlessApplicability.APPLICABLE, \"SESSION_FLAG_BASELINE_HEALTHY\")\n return HeadlessJudgement(HeadlessOutcome.FAIL, HeadlessApplicability.INCONCLUSIVE, \"SESSION_FLAG_BASELINE_UNAVAILABLE\")\n\n\n__all__ = [\"RECIPE\", \"STEPS\", \"definition\", \"scenario\", \"SCENARIO\", \"SCENARIO_ID\", \"judge\"]\n"} | |
| {"scenario_id": "ask_mode_denies_write_and_allows_read", "family": "permission", "category": "permissions", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["p60_ctl_yolo_both_work"], "requires": [], "summary": "Verify that ask mode blocks writes while preserving read access.", "description": "Verify that ask mode blocks writes while preserving read access.\n\n1. Enter ask mode, seed readable and protected fixtures, and prepare liveness.\n2. Run the write probe followed by its read follow-up through Bash.\n3. Capture request, target, and output facts from the permission observer.\n4. Pass only when the target is unchanged, the read token is visible, and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/ask_mode_denies_write_and_allows_read.py", "source_code": "\"\"\"Verify that ask mode blocks writes while preserving read access.\n\n1. Enter ask mode, seed readable and protected fixtures, and prepare liveness.\n2. Run the write probe followed by its read follow-up through Bash.\n3. Capture request, target, and output facts from the permission observer.\n4. Pass only when the target is unchanged, the read token is visible, and cleanup is clean.\n\"\"\"\n\nfrom dataclasses import replace\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n ORIGINAL_TARGET_CONTENT,\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n seed_file,\n set_mode,\n)\n\nSCENARIO_ID = \"ask_mode_denies_write_and_allows_read\"\nEXPECTED_TOKEN = \"ASKMODE_BOTH_9942\"\nSTEPS = (\n set_mode(\"/mode ask\"),\n seed_file(\"rdt.txt\", f\"{EXPECTED_TOKEN} readable\\n\"),\n seed_file(\"tgt.txt\", ORIGINAL_TARGET_CONTENT),\n allow_command(\"echo PERM_LIVE_7755 > live.txt\"),\n probe_command(\"echo HACK_7755 > tgt.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"tgt.txt\", present=True),\n)\nRECIPE = replace(\n compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.WRITE_BLOCKED_READ_ALLOWED\n ),\n expected_token=EXPECTED_TOKEN,\n second_probe=\"cat rdt.txt\",\n control_dependency=\"p60_ctl_yolo_both_work\",\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.TARGET\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require an unchanged target and visible read token with clean boundaries.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n observed_text = observation.messages_text + \"\\n\" + observation.stdout_text\n passed = (\n observation.request_count >= 1\n and observation.target_content == ORIGINAL_TARGET_CONTENT\n and EXPECTED_TOKEN in observed_text\n and clean\n )\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n PermissionOracleProfile.WRITE_BLOCKED_READ_ALLOWED.value\n if passed\n else f\"{PermissionOracleProfile.WRITE_BLOCKED_READ_ALLOWED.value}_FAILED\",\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "autoedit_blocks_mutable_shell", "family": "permission", "category": "permissions", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["yolo_mutable_shell_lands_control"], "requires": [], "summary": "Verify that auto-edit mode blocks a mutable shell write.", "description": "Verify that auto-edit mode blocks a mutable shell write.\n\n1. Configure the permission mode and seed the target file.\n2. Ask Bash to run the probe command while the guard is active.\n3. Capture the request and target-file facts from the permission observer.\n4. Pass only when the original target content remains and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/autoedit_blocks_mutable_shell.py", "source_code": "\"\"\"Verify that auto-edit mode blocks a mutable shell write.\n\n1. Configure the permission mode and seed the target file.\n2. Ask Bash to run the probe command while the guard is active.\n3. Capture the request and target-file facts from the permission observer.\n4. Pass only when the original target content remains and cleanup is clean.\n\"\"\"\n\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n ORIGINAL_TARGET_CONTENT,\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n seed_file,\n set_mode,\n)\n\nSCENARIO_ID = \"autoedit_blocks_mutable_shell\"\nSTEPS = (\n set_mode(\"/mode auto-edit\"),\n seed_file(\"tgt.txt\", ORIGINAL_TARGET_CONTENT),\n allow_command(\"ls -a\"),\n probe_command(\"echo HACK_7755 > tgt.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"tgt.txt\", present=True),\n)\nRECIPE = compile_permission_steps(\n STEPS,\n oracle_profile=PermissionOracleProfile.TARGET_UNCHANGED,\n control_dependency=\"yolo_mutable_shell_lands_control\",\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.TARGET\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require the guarded probe to leave the target unchanged.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = (\n observation.request_count >= 1\n and observation.target_content == ORIGINAL_TARGET_CONTENT\n and clean\n )\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n (\n PermissionOracleProfile.TARGET_UNCHANGED.value\n if passed\n else f\"{PermissionOracleProfile.TARGET_UNCHANGED.value}_FAILED\"\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "autoreview_blocks_canonical_danger", "family": "permission", "category": "permissions", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["p46_ctl_yolo_rm_really_deletes"], "requires": [], "summary": "Verify that auto-review mode blocks a canonical destructive command.", "description": "Verify that auto-review mode blocks a canonical destructive command.\n\n1. Configure the permission mode and seed the target file.\n2. Ask Bash to run the probe command while the guard is active.\n3. Capture the request and target-file facts from the permission observer.\n4. Pass only when the original target content remains and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/autoreview_blocks_canonical_danger.py", "source_code": "\"\"\"Verify that auto-review mode blocks a canonical destructive command.\n\n1. Configure the permission mode and seed the target file.\n2. Ask Bash to run the probe command while the guard is active.\n3. Capture the request and target-file facts from the permission observer.\n4. Pass only when the original target content remains and cleanup is clean.\n\"\"\"\n\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n ORIGINAL_TARGET_CONTENT,\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n seed_file,\n set_mode,\n)\n\nSCENARIO_ID = \"autoreview_blocks_canonical_danger\"\nSTEPS = (\n set_mode(\"/mode auto-review\"),\n seed_file(\"tgt.txt\", ORIGINAL_TARGET_CONTENT),\n allow_command(\"echo PERM_LIVE_7755 > live.txt\"),\n probe_command(\"rm -rf tgt.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"tgt.txt\", present=True),\n)\nRECIPE = compile_permission_steps(\n STEPS,\n oracle_profile=PermissionOracleProfile.TARGET_UNCHANGED,\n control_dependency=\"p46_ctl_yolo_rm_really_deletes\",\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.TARGET\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require the guarded probe to leave the target unchanged.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = (\n observation.request_count >= 1\n and observation.target_content == ORIGINAL_TARGET_CONTENT\n and clean\n )\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n (\n PermissionOracleProfile.TARGET_UNCHANGED.value\n if passed\n else f\"{PermissionOracleProfile.TARGET_UNCHANGED.value}_FAILED\"\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "blocking_hook_missing_exec_control", "family": "permission", "category": "permissions", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify fail-closed behavior when a blocking hook executable is missing.", "description": "Verify fail-closed behavior when a blocking hook executable is missing.\n\n1. Enable yolo mode and install a healthy blocking hook plus a missing executable hook.\n2. Run the operation that matches both hook entries.\n3. Capture the operation marker, hook exit evidence, and cleanup boundaries.\n4. Pass when the control operation lands, or when the missing executable blocks it in the target.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/blocking_hook_missing_exec_control.py", "source_code": "\"\"\"Verify fail-closed behavior when a blocking hook executable is missing.\n\n1. Enable yolo mode and install a healthy blocking hook plus a missing executable hook.\n2. Run the operation that matches both hook entries.\n3. Capture the operation marker, hook exit evidence, and cleanup boundaries.\n4. Pass when the control operation lands, or when the missing executable blocks it in the target.\n\"\"\"\n\nfrom dataclasses import replace\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n seed_file,\n set_mode,\n)\n\nSCENARIO_ID = \"blocking_hook_missing_exec_control\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n seed_file(\"hooks.json\", '{\"beforeShellExecution\": [{\"type\": \"command\", \"matcher\": \"PERM_DENY_7755.txt\", \"match\": \"PERM_DENY_7755.txt\", \"command\": \"{HOOK_EXECUTABLE} {HOOK_MARKER}\", \"blocking\": true}, {\"type\": \"command\", \"matcher\": \"HOOKFAIL_NEVER_MATCH_7606\", \"match\": \"HOOKFAIL_NEVER_MATCH_7606\", \"command\": \"{HOOK_MISSING_EXECUTABLE} {HOOK_MARKER}\", \"blocking\": true}]}'),\n allow_command(\"true\"),\n probe_command(\"printf HOOKFAIL_OPERATION > PERM_DENY_7755.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"PERM_DENY_7755.txt\", present=True),\n)\nRECIPE = replace(\n compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.HEALTHY_HOOK_OPERATION_LANDED\n ),\n hook_exec_fixture=True,\n control_dependency=None,\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.CONTROL\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require the expected operation result and healthy hook exit evidence.\"\"\"\n\n profile = PermissionOracleProfile.HEALTHY_HOOK_OPERATION_LANDED.value\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = (\n observation.request_count >= 1\n and observation.deny_file_present\n and \"HOOKFAIL_HEALTHY_HOOK_EXIT_0\" in observation.hook_events\n and clean\n )\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n profile if passed else f\"{profile}_FAILED\",\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "blocking_hook_missing_exec_fail_closed", "family": "permission", "category": "permissions", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["blocking_hook_missing_exec_control"], "requires": [], "summary": "Verify fail-closed behavior when a blocking hook executable is missing.", "description": "Verify fail-closed behavior when a blocking hook executable is missing.\n\n1. Enable yolo mode and install a healthy blocking hook plus a missing executable hook.\n2. Run the operation that matches both hook entries.\n3. Capture the operation marker, hook exit evidence, and cleanup boundaries.\n4. Pass when the control operation lands, or when the missing executable blocks it in the target.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/blocking_hook_missing_exec_fail_closed.py", "source_code": "\"\"\"Verify fail-closed behavior when a blocking hook executable is missing.\n\n1. Enable yolo mode and install a healthy blocking hook plus a missing executable hook.\n2. Run the operation that matches both hook entries.\n3. Capture the operation marker, hook exit evidence, and cleanup boundaries.\n4. Pass when the control operation lands, or when the missing executable blocks it in the target.\n\"\"\"\n\nfrom dataclasses import replace\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n seed_file,\n set_mode,\n)\n\nSCENARIO_ID = \"blocking_hook_missing_exec_fail_closed\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n seed_file(\"hooks.json\", '{\"beforeShellExecution\": [{\"type\": \"command\", \"matcher\": \"PERM_DENY_7755.txt\", \"match\": \"PERM_DENY_7755.txt\", \"command\": \"{HOOK_EXECUTABLE} {HOOK_MARKER}\", \"blocking\": true}, {\"type\": \"command\", \"matcher\": \"PERM_DENY_7755.txt\", \"match\": \"PERM_DENY_7755.txt\", \"command\": \"{HOOK_MISSING_EXECUTABLE} {HOOK_MARKER}\", \"blocking\": true}]}'),\n allow_command(\"true\"),\n probe_command(\"printf HOOKFAIL_OPERATION > PERM_DENY_7755.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"PERM_DENY_7755.txt\", present=True),\n)\nRECIPE = replace(\n compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.HOOK_FAILURE_OPERATION_BLOCKED\n ),\n hook_exec_fixture=True,\n control_dependency=\"blocking_hook_missing_exec_control\",\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.TARGET\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require the expected operation result and healthy hook exit evidence.\"\"\"\n\n profile = PermissionOracleProfile.HOOK_FAILURE_OPERATION_BLOCKED.value\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = (\n observation.request_count >= 1\n and not observation.deny_file_present\n and \"HOOKFAIL_HEALTHY_HOOK_EXIT_0\" in observation.hook_events\n and clean\n )\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n profile if passed else f\"{profile}_FAILED\",\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "custom_cmd_at_file_read_fences_control", "family": "permission", "category": "permissions", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Control that proves custom command file reads expose all expected tokens.", "description": "Control that proves custom command file reads expose all expected tokens.\n\n1. Enter yolo mode, configure workspace-write, and seed command/read fixtures.\n2. Invoke both custom commands through the Bash adapter.\n3. Capture wire-level observed tokens from the permission observer.\n4. Pass only when every expected token is observed and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/custom_cmd_at_file_read_fences_control.py", "source_code": "\"\"\"Control that proves custom command file reads expose all expected tokens.\n\n1. Enter yolo mode, configure workspace-write, and seed command/read fixtures.\n2. Invoke both custom commands through the Bash adapter.\n3. Capture wire-level observed tokens from the permission observer.\n4. Pass only when every expected token is observed and cleanup is clean.\n\"\"\"\n\nfrom dataclasses import replace\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n add_deny_rule,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n seed_file,\n set_mode,\n)\n\nSCENARIO_ID = \"custom_cmd_at_file_read_fences_control\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n set_mode(\"/sandbox workspace-write\"),\n set_mode(\"/atrefdeny\"),\n set_mode(\"/atrefoutside\"),\n add_deny_rule(\"Read(*atref_denied.txt*)\"),\n seed_file(\n \"commands/atrefdeny.md\",\n \"Gate ATREF_DENY_FACE_7601. Read @{atref_legal_deny.txt} now.\\n\",\n ),\n seed_file(\n \"commands/atrefoutside.md\",\n \"Gate ATREF_OUTSIDE_FACE_7602. Read @{atref_legal_outside.txt} now.\\n\",\n ),\n seed_file(\"atref_legal_deny.txt\", \"ATREF_LEGAL_DENY_BYTES_7603\\n\"),\n seed_file(\"atref_legal_outside.txt\", \"ATREF_LEGAL_OUTSIDE_BYTES_7604\\n\"),\n allow_command(\"true\"),\n probe_command(\"true\"),\n probe_tool(\"bash\"),\n capture_target_file(\"live.txt\", present=True),\n)\nRECIPE = replace(\n compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.WIRE_TOKENS_OBSERVED\n ),\n probe_tokens=(\n \"ATREF_DENY_FACE_7601\",\n \"ATREF_OUTSIDE_FACE_7602\",\n \"ATREF_LEGAL_DENY_BYTES_7603\",\n \"ATREF_LEGAL_OUTSIDE_BYTES_7604\",\n ),\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.CONTROL\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require every control token on the wire with clean boundaries.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = (\n observation.request_count >= 1\n and set(RECIPE.probe_tokens).issubset(observation.observed_tokens)\n and clean\n )\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n PermissionOracleProfile.WIRE_TOKENS_OBSERVED.value\n if passed\n else f\"{PermissionOracleProfile.WIRE_TOKENS_OBSERVED.value}_FAILED\",\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "custom_cmd_at_file_respects_read_fences", "family": "permission", "category": "permissions", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["custom_cmd_at_file_read_fences_control"], "requires": [], "summary": "Verify that custom command file reads respect configured read fences.", "description": "Verify that custom command file reads respect configured read fences.\n\n1. Enter yolo mode, configure workspace-write, and seed fenced command fixtures.\n2. Invoke both custom commands through the Bash adapter.\n3. Capture wire-level observed tokens from the permission observer.\n4. Pass only when fenced content stays absent from the wire and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/custom_cmd_at_file_respects_read_fences.py", "source_code": "\"\"\"Verify that custom command file reads respect configured read fences.\n\n1. Enter yolo mode, configure workspace-write, and seed fenced command fixtures.\n2. Invoke both custom commands through the Bash adapter.\n3. Capture wire-level observed tokens from the permission observer.\n4. Pass only when fenced content stays absent from the wire and cleanup is clean.\n\"\"\"\n\nfrom dataclasses import replace\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n add_deny_rule,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n seed_file,\n set_mode,\n)\n\nSCENARIO_ID = \"custom_cmd_at_file_respects_read_fences\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n set_mode(\"/sandbox workspace-write\"),\n set_mode(\"/atrefdeny\"),\n set_mode(\"/atrefoutside\"),\n add_deny_rule(\"Read(*atref_denied.txt*)\"),\n seed_file(\n \"commands/atrefdeny.md\",\n \"Gate ATREF_DENY_FACE_7601. Read @{atref_denied.txt} now.\\n\",\n ),\n seed_file(\n \"commands/atrefoutside.md\",\n \"Gate ATREF_OUTSIDE_FACE_7602. Read @{{CUSTOM_READ_EXTERNAL}} now.\\n\",\n ),\n seed_file(\"atref_denied.txt\", \"ATREF_DENIED_BYTES_7605\\n\"),\n allow_command(\"true\"),\n probe_command(\"true\"),\n probe_tool(\"bash\"),\n capture_target_file(\"live.txt\", present=True),\n)\nRECIPE = replace(\n compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.WIRE_TOKENS_FENCED\n ),\n probe_tokens=(\n \"ATREF_DENY_FACE_7601\",\n \"ATREF_OUTSIDE_FACE_7602\",\n \"ATREF_DENIED_BYTES_7605\",\n \"ATREF_OUTSIDE_BYTES_7606\",\n ),\n control_dependency=\"custom_cmd_at_file_read_fences_control\",\n custom_read_external=True,\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.TARGET\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require all fenced tokens to stay absent from the wire with clean boundaries.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = (\n observation.request_count >= 1\n and not set(RECIPE.probe_tokens) & set(observation.observed_tokens)\n and clean\n )\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n PermissionOracleProfile.WIRE_TOKENS_FENCED.value\n if passed\n else f\"{PermissionOracleProfile.WIRE_TOKENS_FENCED.value}_FAILED\",\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "deny_blocks_monitor_spawned_cmd", "family": "permission", "category": "permissions", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["monitor_spawns_command_control"], "requires": [], "summary": "Verify the monitor blocked permission behavior.", "description": "Verify the monitor blocked permission behavior.\n\n1. Configure the mode and prepare the liveness command.\n2. Run the monitor probe through the execution adapter.\n3. Capture the request and observer-specific facts.\n4. Pass only when the expected boundary behavior is observed and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/deny_blocks_monitor_spawned_cmd.py", "source_code": "\"\"\"Verify the monitor blocked permission behavior.\n\n1. Configure the mode and prepare the liveness command.\n2. Run the monitor probe through the execution adapter.\n3. Capture the request and observer-specific facts.\n4. Pass only when the expected boundary behavior is observed and cleanup is clean.\n\"\"\"\n\nfrom dataclasses import replace\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n add_deny_rule,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n set_mode,\n)\n\nSCENARIO_ID = \"deny_blocks_monitor_spawned_cmd\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n add_deny_rule(\"Bash(touch*)\"),\n allow_command(\"echo PERM_LIVE_7755 > live.txt\"),\n probe_command(\"echo MONUNUSED_7755\"),\n probe_tool(\"monitor\"),\n capture_target_file(\"live.txt\", present=True),\n)\nRECIPE = replace(\n compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.MONITOR_BLOCKED\n ),\n probe_arguments=(\n (\"command\", \"touch monitor_started_7755; sleep 0.2; touch PERM_DENY_7755.txt\"),\n (\"pattern\", \"x\"),\n ),\n settle_paths=(\"PERM_DENY_7755.txt\", \"monitor_started_7755\"),\n control_dependency=\"monitor_spawns_command_control\",\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.TARGET\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Apply the profile-specific boundary predicate with clean-run checks.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = (\n observation.request_count >= 1\n and not observation.deny_file_present\n and \"monitor_started_7755\" not in observation.settled_paths\n and clean\n )\n applicability = PermissionApplicability.APPLICABLE\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n applicability,\n PermissionOracleProfile.MONITOR_BLOCKED.value\n if passed\n else f\"{PermissionOracleProfile.MONITOR_BLOCKED.value}_FAILED\",\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "hook_absent_bash_write_runs_control", "family": "permission", "category": "permissions", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify that a Bash write runs when no hook is installed.", "description": "Verify that a Bash write runs when no hook is installed.\n\n1. Enter the configured mode and prepare the liveness command without installing a deny rule.\n2. Ask Bash to run the control command against the marker file.\n3. Capture the request and filesystem facts from the permission observer.\n4. Pass only when the request ran, the marker exists, and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/hook_absent_bash_write_runs_control.py", "source_code": "\"\"\"Verify that a Bash write runs when no hook is installed.\n\n1. Enter the configured mode and prepare the liveness command without installing a deny rule.\n2. Ask Bash to run the control command against the marker file.\n3. Capture the request and filesystem facts from the permission observer.\n4. Pass only when the request ran, the marker exists, and cleanup is clean.\n\"\"\"\n\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n set_mode,\n)\n\nSCENARIO_ID = \"hook_absent_bash_write_runs_control\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n allow_command(\"echo PERM_LIVE_7755 > live.txt\"),\n probe_command(\"echo HACK > PERM_DENY_7755.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"PERM_DENY_7755.txt\", present=True),\n)\nRECIPE = compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.COMMAND_EXECUTED\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.CONTROL\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require the unhooked Bash write to create its marker file.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = observation.request_count >= 1 and observation.deny_file_present and clean\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n (\n PermissionOracleProfile.COMMAND_EXECUTED.value\n if passed\n else f\"{PermissionOracleProfile.COMMAND_EXECUTED.value}_FAILED\"\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "hook_blocks_bash_write", "family": "permission", "category": "permissions", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["hook_absent_bash_write_runs_control"], "requires": [], "summary": "Verify that a blocking before-shell hook prevents the target write.", "description": "Verify that a blocking before-shell hook prevents the target write.\n\n1. Apply the permission setup sequence and seed the required fixture.\n2. Ask Bash to run the probe after the setup sequence.\n3. Capture the request and resulting facts from the permission observer.\n4. Pass only when the expected oracle outcome and cleanup gates hold.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/hook_blocks_bash_write.py", "source_code": "\"\"\"Verify that a blocking before-shell hook prevents the target write.\n\n1. Apply the permission setup sequence and seed the required fixture.\n2. Ask Bash to run the probe after the setup sequence.\n3. Capture the request and resulting facts from the permission observer.\n4. Pass only when the expected oracle outcome and cleanup gates hold.\n\"\"\"\n\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import PermissionApplicability, PermissionOracleProfile, PermissionOutcome, PermissionRawObservation, PermissionScenario, allow_command, capture_target_file, compile_permission_steps, define_permission_scenario, probe_command, probe_tool, seed_file, set_mode\n\nSCENARIO_ID = \"hook_blocks_bash_write\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n seed_file(\"hooks.json\", \"{\\\"beforeShellExecution\\\": [{\\\"matcher\\\": \\\"PERM_DENY_7755\\\", \\\"match\\\": \\\"PERM_DENY_7755\\\", \\\"command\\\": \\\"echo '{\\\\\\\"decision\\\\\\\":\\\\\\\"deny\\\\\\\",\\\\\\\"permission\\\\\\\":\\\\\\\"deny\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"blocked by hook\\\\\\\"}'; exit 2\\\"}]}\"),\n allow_command(\"echo PERM_LIVE_7755 > live.txt\"),\n probe_command(\"echo HACK > PERM_DENY_7755.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"PERM_DENY_7755.txt\", present=False),\n)\nRECIPE = compile_permission_steps(\n STEPS,\n oracle_profile=PermissionOracleProfile.DENY_BLOCKED,\n control_dependency=\"hook_absent_bash_write_runs_control\",\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.TARGET\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Evaluate the expected outcome and cleanup gates.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = observation.request_count >= 1 and not observation.deny_file_present and clean\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n (\n PermissionOracleProfile.DENY_BLOCKED.value\n if passed\n else f\"{PermissionOracleProfile.DENY_BLOCKED.value}_FAILED\"\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "monitor_spawns_command_control", "family": "permission", "category": "permissions", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify the monitor executed control permission behavior.", "description": "Verify the monitor executed control permission behavior.\n\n1. Configure the mode and prepare the liveness command.\n2. Run the monitor probe through the execution adapter.\n3. Capture the request and observer-specific facts.\n4. Pass only when the expected boundary behavior is observed and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/monitor_spawns_command_control.py", "source_code": "\"\"\"Verify the monitor executed control permission behavior.\n\n1. Configure the mode and prepare the liveness command.\n2. Run the monitor probe through the execution adapter.\n3. Capture the request and observer-specific facts.\n4. Pass only when the expected boundary behavior is observed and cleanup is clean.\n\"\"\"\n\nfrom dataclasses import replace\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n set_mode,\n)\n\nSCENARIO_ID = \"monitor_spawns_command_control\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n allow_command(\"echo PERM_LIVE_7755 > live.txt\"),\n probe_command(\"echo MONUNUSED_7755\"),\n probe_tool(\"monitor\"),\n capture_target_file(\"live.txt\", present=True),\n)\nRECIPE = replace(\n compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.MONITOR_EXECUTED_CONTROL\n ),\n probe_arguments=(\n (\"command\", \"touch monitor_started_7755; sleep 0.2; touch PERM_DENY_7755.txt\"),\n (\"pattern\", \"x\"),\n ),\n settle_paths=(\"PERM_DENY_7755.txt\", \"monitor_started_7755\"),\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.CONTROL\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Apply the profile-specific boundary predicate with clean-run checks.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = (\n observation.deny_file_present\n and \"monitor_started_7755\" in observation.settled_paths\n and clean\n )\n applicability = PermissionApplicability.APPLICABLE\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n applicability,\n PermissionOracleProfile.MONITOR_EXECUTED_CONTROL.value\n if passed\n else f\"{PermissionOracleProfile.MONITOR_EXECUTED_CONTROL.value}_FAILED\",\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "network_off_blocks_offline_npm_test", "family": "permission", "category": "permissions", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["p37_ctl_plain_cmd_chain_runs"], "requires": [], "summary": "Verify that the network-off policy still records the guarded npm probe.", "description": "Verify that the network-off policy still records the guarded npm probe.\n\n1. Apply the permission setup sequence and seed any required fixture.\n2. Ask Bash to run the probe after the setup sequence.\n3. Capture the request and resulting facts from the permission observer.\n4. Pass only when the expected oracle outcome and cleanup gates hold.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/network_off_blocks_offline_npm_test.py", "source_code": "\"\"\"Verify that the network-off policy still records the guarded npm probe.\n\n1. Apply the permission setup sequence and seed any required fixture.\n2. Ask Bash to run the probe after the setup sequence.\n3. Capture the request and resulting facts from the permission observer.\n4. Pass only when the expected oracle outcome and cleanup gates hold.\n\"\"\"\n\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import PermissionApplicability, PermissionOracleProfile, PermissionOutcome, PermissionRawObservation, PermissionScenario, allow_command, capture_target_file, compile_permission_steps, define_permission_scenario, probe_command, probe_tool, set_mode\n\nSCENARIO_ID = \"network_off_blocks_offline_npm_test\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n allow_command(\"echo PERM_LIVE_7755 > live.txt\"),\n probe_command(\"npm test > /dev/null 2>&1; echo HACK > PERM_DENY_7755.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"PERM_DENY_7755.txt\", present=True),\n)\nRECIPE = compile_permission_steps(\n STEPS,\n oracle_profile=PermissionOracleProfile.COMMAND_EXECUTED,\n control_dependency=\"p37_ctl_plain_cmd_chain_runs\",\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.TARGET\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Evaluate the expected outcome and cleanup gates.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = observation.request_count >= 1 and observation.deny_file_present and clean\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n (\n PermissionOracleProfile.COMMAND_EXECUTED.value\n if passed\n else f\"{PermissionOracleProfile.COMMAND_EXECUTED.value}_FAILED\"\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "p37_ctl_plain_cmd_chain_runs", "family": "permission", "category": "permissions", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify that a plain command chain executes its marker write without a deny rule.", "description": "Verify that a plain command chain executes its marker write without a deny rule.\n\n1. Enter yolo mode and prepare the liveness command without installing a deny rule.\n2. Ask Bash to run the control command against the marker file.\n3. Capture the request and marker-file facts from the permission observer.\n4. Pass only when the request ran, the marker exists, and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/p37_ctl_plain_cmd_chain_runs.py", "source_code": "\"\"\"Verify that a plain command chain executes its marker write without a deny rule.\n\n1. Enter yolo mode and prepare the liveness command without installing a deny rule.\n2. Ask Bash to run the control command against the marker file.\n3. Capture the request and marker-file facts from the permission observer.\n4. Pass only when the request ran, the marker exists, and cleanup is clean.\n\"\"\"\n\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n set_mode,\n)\n\nSCENARIO_ID = \"p37_ctl_plain_cmd_chain_runs\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n allow_command(\"echo PERM_LIVE_7755 > live.txt\"),\n probe_command(\"true > /dev/null 2>&1; echo HACK > PERM_DENY_7755.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"PERM_DENY_7755.txt\", present=True),\n)\nRECIPE = compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.COMMAND_EXECUTED\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.CONTROL\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require the chained control command to create its marker file.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = observation.request_count >= 1 and observation.deny_file_present and clean\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n (\n PermissionOracleProfile.COMMAND_EXECUTED.value\n if passed\n else f\"{PermissionOracleProfile.COMMAND_EXECUTED.value}_FAILED\"\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "p46_ctl_yolo_rm_really_deletes", "family": "permission", "category": "permissions", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify that yolo mode permits rm -rf to delete the target.", "description": "Verify that yolo mode permits rm -rf to delete the target.\n\n1. Enter yolo mode, seed the target file, and prepare the liveness command.\n2. Ask Bash to perform the scenario's mutation against the target.\n3. Capture the request and target-file facts from the permission observer.\n4. Pass only when the target content differs from its original value and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/p46_ctl_yolo_rm_really_deletes.py", "source_code": "\"\"\"Verify that yolo mode permits rm -rf to delete the target.\n\n1. Enter yolo mode, seed the target file, and prepare the liveness command.\n2. Ask Bash to perform the scenario's mutation against the target.\n3. Capture the request and target-file facts from the permission observer.\n4. Pass only when the target content differs from its original value and cleanup is clean.\n\"\"\"\n\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n ORIGINAL_TARGET_CONTENT,\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n seed_file,\n set_mode,\n)\n\nSCENARIO_ID = \"p46_ctl_yolo_rm_really_deletes\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n seed_file(\"tgt.txt\", ORIGINAL_TARGET_CONTENT),\n allow_command(\"echo PERM_LIVE_7755 > live.txt\"),\n probe_command(\"rm -rf tgt.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"tgt.txt\", present=True),\n)\nRECIPE = compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.TARGET_MUTATED\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.CONTROL\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require rm -rf to mutate the target.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = (\n observation.request_count >= 1\n and observation.target_content != ORIGINAL_TARGET_CONTENT\n and clean\n )\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n (\n PermissionOracleProfile.TARGET_MUTATED.value\n if passed\n else f\"{PermissionOracleProfile.TARGET_MUTATED.value}_FAILED\"\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "p60_ctl_yolo_both_work", "family": "permission", "category": "permissions", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Control that proves yolo mode allows both write and read operations.", "description": "Control that proves yolo mode allows both write and read operations.\n\n1. Enter yolo mode, seed readable and protected fixtures, and prepare liveness.\n2. Run the write probe followed by its read follow-up through Bash.\n3. Capture request, target, and output facts from the permission observer.\n4. Pass only when the target changes, the read token is visible, and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/p60_ctl_yolo_both_work.py", "source_code": "\"\"\"Control that proves yolo mode allows both write and read operations.\n\n1. Enter yolo mode, seed readable and protected fixtures, and prepare liveness.\n2. Run the write probe followed by its read follow-up through Bash.\n3. Capture request, target, and output facts from the permission observer.\n4. Pass only when the target changes, the read token is visible, and cleanup is clean.\n\"\"\"\n\nfrom dataclasses import replace\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n ORIGINAL_TARGET_CONTENT,\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n seed_file,\n set_mode,\n)\n\nSCENARIO_ID = \"p60_ctl_yolo_both_work\"\nEXPECTED_TOKEN = \"ASKMODE_BOTH_9942\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n seed_file(\"rdt.txt\", \"ASKMODE_BOTH_9942 readable\\n\"),\n seed_file(\"tgt.txt\", ORIGINAL_TARGET_CONTENT),\n allow_command(\"echo PERM_LIVE_7755 > live.txt\"),\n probe_command(\"echo HACK_7755 > tgt.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"tgt.txt\", present=True),\n)\nRECIPE = replace(\n compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.WRITE_AND_READ_EXECUTED\n ),\n second_probe=\"cat rdt.txt\",\n expected_token=EXPECTED_TOKEN,\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.CONTROL\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require a mutated target and visible read token with clean boundaries.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n expected_token = EXPECTED_TOKEN or \"RDTK_4242X\"\n observed_text = observation.messages_text + \"\\n\" + observation.stdout_text\n passed = (\n observation.request_count >= 1\n and observation.target_content != ORIGINAL_TARGET_CONTENT\n and expected_token in observed_text\n and clean\n )\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n PermissionOracleProfile.WRITE_AND_READ_EXECUTED.value\n if passed\n else f\"{PermissionOracleProfile.WRITE_AND_READ_EXECUTED.value}_FAILED\",\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "yolo_mutable_shell_lands_control", "family": "permission", "category": "permissions", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify that yolo mode permits the mutable shell command to land.", "description": "Verify that yolo mode permits the mutable shell command to land.\n\n1. Enter yolo mode, seed the target file, and prepare the liveness command.\n2. Ask Bash to perform the scenario's mutation against the target.\n3. Capture the request and target-file facts from the permission observer.\n4. Pass only when the target content differs from its original value and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/permission/scenarios/yolo_mutable_shell_lands_control.py", "source_code": "\"\"\"Verify that yolo mode permits the mutable shell command to land.\n\n1. Enter yolo mode, seed the target file, and prepare the liveness command.\n2. Ask Bash to perform the scenario's mutation against the target.\n3. Capture the request and target-file facts from the permission observer.\n4. Pass only when the target content differs from its original value and cleanup is clean.\n\"\"\"\n\nfrom typing import NamedTuple\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.permission.contracts import (\n ORIGINAL_TARGET_CONTENT,\n PermissionApplicability,\n PermissionOracleProfile,\n PermissionOutcome,\n PermissionRawObservation,\n PermissionScenario,\n allow_command,\n capture_target_file,\n compile_permission_steps,\n define_permission_scenario,\n probe_command,\n probe_tool,\n seed_file,\n set_mode,\n)\n\nSCENARIO_ID = \"yolo_mutable_shell_lands_control\"\nSTEPS = (\n set_mode(\"/mode yolo\"),\n seed_file(\"tgt.txt\", ORIGINAL_TARGET_CONTENT),\n allow_command(\"ls -a\"),\n probe_command(\"echo HACK_7755 > tgt.txt\"),\n probe_tool(\"bash\"),\n capture_target_file(\"tgt.txt\", present=True),\n)\nRECIPE = compile_permission_steps(\n STEPS, oracle_profile=PermissionOracleProfile.TARGET_MUTATED\n)\nSCENARIO: PermissionScenario = define_permission_scenario(\n SCENARIO_ID, RECIPE, ScenarioRole.CONTROL\n)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\nclass Judgement(NamedTuple):\n outcome: PermissionOutcome\n applicability: PermissionApplicability\n reason_code: str\n\n\ndef judge(observation: PermissionRawObservation) -> Judgement:\n \"\"\"Require the mutable shell command to change the target.\"\"\"\n\n clean = (\n observation.process_tree_clean\n and observation.gateway_clean\n and observation.workspace_clean\n and not observation.timed_out\n )\n passed = (\n observation.request_count >= 1\n and observation.target_content != ORIGINAL_TARGET_CONTENT\n and clean\n )\n return Judgement(\n PermissionOutcome.PASS if passed else PermissionOutcome.FAIL,\n PermissionApplicability.APPLICABLE,\n (\n PermissionOracleProfile.TARGET_MUTATED.value\n if passed\n else f\"{PermissionOracleProfile.TARGET_MUTATED.value}_FAILED\"\n ),\n )\n\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "launcher_ambient_python_isolated", "family": "startup", "category": "startup", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["launcher_health_control"], "requires": [], "summary": "The launcher must isolate the selected Python from ambient path and home state.", "description": "The launcher must isolate the selected Python from ambient path and home state.\n1. Declare the ambient-Python isolation probe and its health-control dependency.\n2. Compile the declaration into the startup recipe.\n3. Run the startup observer against that recipe.\n4. Judge entry selection, poison checks, isolation, and cleanup without side effects.", "source_path": "src/doc2harness/benchmark/harnesses/startup/scenarios/launcher_ambient_python_isolated.py", "source_code": "\"\"\"The launcher must isolate the selected Python from ambient path and home state.\n1. Declare the ambient-Python isolation probe and its health-control dependency.\n2. Compile the declaration into the startup recipe.\n3. Run the startup observer against that recipe.\n4. Judge entry selection, poison checks, isolation, and cleanup without side effects.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind, ScenarioRole\nfrom doc2harness.benchmark.harnesses.startup.contracts import (\n StartupObservation,\n StartupProfile,\n build_startup_evaluation,\n compile_startup_steps,\n define_startup_scenario,\n startup_configuration,\n validate_startup_observation,\n)\n\nSCENARIO_ID = \"launcher_ambient_python_isolated\"\nSTEPS = (\n startup_configuration(\n StartupProfile.AMBIENT_PYTHON,\n launcher_probe=\"ambient-python\",\n dependencies=((\"launcher_health_control\", DependencyKind.GATE),),\n timeout_seconds=25,\n ),\n)\nRECIPE = compile_startup_steps(STEPS)\nSCENARIO = define_startup_scenario(SCENARIO_ID, RECIPE, ScenarioRole.TARGET)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StartupObservation):\n validate_startup_observation(SCENARIO, observation)\n if not observation.launcher_available:\n return build_startup_evaluation(SCENARIO, observation, False, False, \"LAUNCHER_UNOBSERVED\")\n if not observation.fixture_verified:\n return build_startup_evaluation(SCENARIO, observation, False, True, \"LAUNCHER_FIXTURE_FAILED\")\n passed = (\n observation.exact_entry\n and observation.poison_selftest\n and observation.ambient_path_isolated\n and observation.ambient_home_isolated\n )\n return build_startup_evaluation(SCENARIO, observation, passed, True, \"AMBIENT_PYTHON_CHECKED\")\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "launcher_health_control", "family": "startup", "category": "startup", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "The launcher health control verifies availability and selects the intended entry.", "description": "The launcher health control verifies availability and selects the intended entry.\n1. Declare the launcher health probe and its short timeout.\n2. Compile the declaration into the startup recipe.\n3. Run the startup observer against that recipe.\n4. Judge launcher, fixture, entry, path, and cleanup facts without side effects.", "source_path": "src/doc2harness/benchmark/harnesses/startup/scenarios/launcher_health_control.py", "source_code": "\"\"\"The launcher health control verifies availability and selects the intended entry.\n1. Declare the launcher health probe and its short timeout.\n2. Compile the declaration into the startup recipe.\n3. Run the startup observer against that recipe.\n4. Judge launcher, fixture, entry, path, and cleanup facts without side effects.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.startup.contracts import (\n StartupObservation,\n StartupProfile,\n build_startup_evaluation,\n compile_startup_steps,\n define_startup_scenario,\n startup_configuration,\n validate_startup_observation,\n)\n\nSCENARIO_ID = \"launcher_health_control\"\nSTEPS = (\n startup_configuration(\n StartupProfile.LAUNCHER_HEALTH,\n launcher_probe=\"control\",\n timeout_seconds=25,\n ),\n)\nRECIPE = compile_startup_steps(STEPS)\nSCENARIO = define_startup_scenario(SCENARIO_ID, RECIPE, ScenarioRole.CONTROL)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StartupObservation):\n validate_startup_observation(SCENARIO, observation)\n if not observation.launcher_available:\n return build_startup_evaluation(SCENARIO, observation, False, False, \"LAUNCHER_UNOBSERVED\")\n if not observation.fixture_verified:\n return build_startup_evaluation(SCENARIO, observation, False, True, \"LAUNCHER_FIXTURE_FAILED\")\n if observation.exact_entry and not observation.path_selected:\n return build_startup_evaluation(SCENARIO, observation, False, False, \"LAUNCHER_PATH_UNOBSERVED\")\n return build_startup_evaluation(\n SCENARIO,\n observation,\n observation.exact_entry and observation.path_selected and not observation.wrong_entry,\n True,\n \"LAUNCHER_HEALTH_CHECKED\",\n )\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "launcher_python_minimum_fallback", "family": "startup", "category": "startup", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["launcher_health_control"], "requires": [], "summary": "The launcher must fall back safely when probing below the supported Python floor.", "description": "The launcher must fall back safely when probing below the supported Python floor.\n1. Declare the launcher Python-floor probe and its health-control dependency.\n2. Compile the declaration into the startup recipe.\n3. Run the startup observer against that recipe.\n4. Judge fallback selection, version facts, traceback, and cleanup without side effects.", "source_path": "src/doc2harness/benchmark/harnesses/startup/scenarios/launcher_python_minimum_fallback.py", "source_code": "\"\"\"The launcher must fall back safely when probing below the supported Python floor.\n1. Declare the launcher Python-floor probe and its health-control dependency.\n2. Compile the declaration into the startup recipe.\n3. Run the startup observer against that recipe.\n4. Judge fallback selection, version facts, traceback, and cleanup without side effects.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind, ScenarioRole\nfrom doc2harness.benchmark.harnesses.startup.contracts import (\n StartupObservation,\n StartupProfile,\n build_startup_evaluation,\n compile_startup_steps,\n define_startup_scenario,\n startup_configuration,\n validate_startup_observation,\n)\n\nSCENARIO_ID = \"launcher_python_minimum_fallback\"\nSTEPS = (\n startup_configuration(\n StartupProfile.PYTHON_MINIMUM,\n launcher_probe=\"python-floor\",\n dependencies=((\"launcher_health_control\", DependencyKind.GATE),),\n timeout_seconds=25,\n ),\n)\nRECIPE = compile_startup_steps(STEPS)\nSCENARIO = define_startup_scenario(SCENARIO_ID, RECIPE, ScenarioRole.TARGET)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StartupObservation):\n validate_startup_observation(SCENARIO, observation)\n if not observation.launcher_available:\n return build_startup_evaluation(SCENARIO, observation, False, False, \"LAUNCHER_UNOBSERVED\")\n if not observation.fixture_verified:\n return build_startup_evaluation(SCENARIO, observation, False, True, \"LAUNCHER_FIXTURE_FAILED\")\n if not observation.declared_floor:\n return build_startup_evaluation(SCENARIO, observation, False, False, \"PYTHON_FLOOR_UNOBSERVED\")\n passed = (\n observation.exact_entry\n and observation.path_selected\n and not observation.wrong_entry\n and observation.old_python_probed\n and not observation.old_python_entered\n and observation.healthy_version_satisfies\n )\n return build_startup_evaluation(SCENARIO, observation, passed, True, \"PYTHON_FLOOR_CHECKED\")\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "startup_bom_config", "family": "startup", "category": "startup", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "A UTF-8 BOM-prefixed configuration must cross startup without a bare crash.", "description": "A UTF-8 BOM-prefixed configuration must cross startup without a bare crash.\n1. Declare the clean-start configuration with its UTF-8 BOM.\n2. Compile the declaration into the startup recipe.\n3. Run the startup observer against that recipe.\n4. Judge construction, interface, traceback, and cleanup facts without side effects.", "source_path": "src/doc2harness/benchmark/harnesses/startup/scenarios/startup_bom_config.py", "source_code": "\"\"\"A UTF-8 BOM-prefixed configuration must cross startup without a bare crash.\n1. Declare the clean-start configuration with its UTF-8 BOM.\n2. Compile the declaration into the startup recipe.\n3. Run the startup observer against that recipe.\n4. Judge construction, interface, traceback, and cleanup facts without side effects.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.startup.contracts import (\n StartupObservation,\n StartupProfile,\n build_startup_evaluation,\n compile_startup_steps,\n define_startup_scenario,\n startup_configuration,\n validate_startup_observation,\n)\n\nSCENARIO_ID = \"startup_bom_config\"\nSTEPS = (\n startup_configuration(StartupProfile.CLEAN_CONSTRUCT, '\\ufeff{\"yolo\": true}'),\n)\nRECIPE = compile_startup_steps(STEPS)\nSCENARIO = define_startup_scenario(SCENARIO_ID, RECIPE, ScenarioRole.TARGET)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StartupObservation):\n validate_startup_observation(SCENARIO, observation)\n if not observation.result_present or observation.import_traceback:\n return build_startup_evaluation(SCENARIO, observation, False, True, \"STARTUP_IMPORT_FAILED\")\n if not observation.standard_interface:\n return build_startup_evaluation(SCENARIO, observation, False, False, \"STARTUP_INTERFACE_UNOBSERVED\")\n return build_startup_evaluation(\n SCENARIO,\n observation,\n observation.constructed and not observation.constructor_traceback,\n True,\n \"STARTUP_CONSTRUCT_CHECKED\",\n )\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "startup_broken_config_file", "family": "startup", "category": "startup", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "A syntactically broken configuration must fail through the normal startup boundary.", "description": "A syntactically broken configuration must fail through the normal startup boundary.\n1. Declare the clean-start configuration with malformed JSON.\n2. Compile the declaration into the startup recipe.\n3. Run the startup observer against that recipe.\n4. Judge construction, interface, traceback, and cleanup facts without side effects.", "source_path": "src/doc2harness/benchmark/harnesses/startup/scenarios/startup_broken_config_file.py", "source_code": "\"\"\"A syntactically broken configuration must fail through the normal startup boundary.\n1. Declare the clean-start configuration with malformed JSON.\n2. Compile the declaration into the startup recipe.\n3. Run the startup observer against that recipe.\n4. Judge construction, interface, traceback, and cleanup facts without side effects.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom doc2harness.benchmark.harnesses.startup.contracts import (\n StartupObservation,\n StartupProfile,\n build_startup_evaluation,\n compile_startup_steps,\n define_startup_scenario,\n startup_configuration,\n validate_startup_observation,\n)\n\nSCENARIO_ID = \"startup_broken_config_file\"\nSTEPS = (\n startup_configuration(StartupProfile.CLEAN_CONSTRUCT, '{\"yolo\": true,, }'),\n)\nRECIPE = compile_startup_steps(STEPS)\nSCENARIO = define_startup_scenario(SCENARIO_ID, RECIPE, ScenarioRole.TARGET)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StartupObservation):\n validate_startup_observation(SCENARIO, observation)\n if not observation.result_present or observation.import_traceback:\n return build_startup_evaluation(SCENARIO, observation, False, True, \"STARTUP_IMPORT_FAILED\")\n if not observation.standard_interface:\n return build_startup_evaluation(SCENARIO, observation, False, False, \"STARTUP_INTERFACE_UNOBSERVED\")\n return build_startup_evaluation(\n SCENARIO,\n observation,\n observation.constructed and not observation.constructor_traceback,\n True,\n \"STARTUP_CONSTRUCT_CHECKED\",\n )\n\n__all__ = [\"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "agent_api_close_retry_incomplete", "family": "state", "category": "session state", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["agent_api_close_retry_incomplete_control"], "requires": [], "summary": "Verify the structured close-retry evidence for the target route.", "description": "Verify the structured close-retry evidence for the target route.\n\n1. Run the close operation through the session-close API variant fixture.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when the structured route is complete and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/agent_api_close_retry_incomplete.py", "source_code": "\"\"\"Verify the structured close-retry evidence for the target route.\n\n1. Run the close operation through the session-close API variant fixture.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when the structured route is complete and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability, StateEvaluation, StateObservation, StateOracleProfile,\n StateOutcome, StateScenario, compile_state_steps,\n evaluation_digest, structured_fact,\n)\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"agent_api_close_retry_incomplete\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_VARIANTS_KEY = \"clipboard_api_variants\"\n_EXEC = (\n (_VARIANTS_KEY, ((\n (\"heartbeat_file\", \"close_helper.heartbeat\"), (\"inject_fault\", True), (\"label\", \"target\"),\n (\"lease_file\", \"close_helper.lease\"), (\"operation\", \"close\"), (\"pid_file\", \"close_helper.pid\"),\n (\"prompt\", \"CLOSE_ROUTE_6501\"), (\"state_file\", \"close_helper.state\"),\n (\"stub\", (\n (\"mode\", \"seq_probe\"), (\"probe_tokens\", (\"CLOSE_ROUTE_6501\",)),\n (\"rounds\", (\n (((\"args\", ((\"run_in_background\", True),)), (\"command\", \"__CLOSE_COMMAND__\"), (\"name\", \"bash\")),),\n (((\"name\", \"__finish__\"),),),\n )),\n )),\n ),)) ,\n)\nSTEPS = (structured_fact(\"structured_facts\"),)\nRECIPE = compile_state_steps(\n STEPS, oracle_profile=StateOracleProfile.STRUCTURED_FACTS,\n oracle_parameters=((\"fact_key\", SCENARIO_ID),), execution_parameters=_EXEC,\n dependencies=((\"agent_api_close_retry_incomplete_control\", DependencyKind.GATE),),\n timeout_seconds=45,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the structured-facts close-retry contract using typed facts only.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = dict(observation.facts)\n passed, conclusive, reason = False, True, \"CHILD_RESULT_MISSING\"\n if not observation.fixture_verified:\n conclusive, reason = False, \"FIXTURE_UNVERIFIED\"\n elif facts.get(\"result_present\") is not True:\n reason = \"CHILD_RESULT_MISSING\"\n else:\n structured = facts.get(\"structured_facts\")\n structured = dict(structured) if type(structured) is tuple else {}\n row = structured.get(SCENARIO_ID)\n row = dict(row) if type(row) is tuple else {}\n if row.get(\"observed\") is not True or row.get(\"supported\") is False:\n conclusive, reason = False, \"STRUCTURED_FACTS_UNOBSERVED\"\n else:\n checks = row.get(\"checks\")\n checks = checks if type(checks) is tuple else ()\n if not checks:\n conclusive, reason = False, \"STRUCTURED_CHECKS_MISSING\"\n elif not all(item is True for item in checks):\n reason = \"STRUCTURED_FACTS_FAILED\"\n else:\n passed, reason = True, \"STRUCTURED_FACTS_CHECKED\"\n if conclusive and (not observation.process_tree_clean or not observation.workspace_clean):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(\n SCENARIO_ID, StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE if conclusive else StateApplicability.INCONCLUSIVE,\n reason, evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if conclusive else 0,\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "agent_api_close_retry_incomplete_control", "family": "state", "category": "session state", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify the structured close-retry evidence for the control route.", "description": "Verify the structured close-retry evidence for the control route.\n\n1. Run the close operation through the session-close API variant fixture.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when the structured route is complete and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/agent_api_close_retry_incomplete_control.py", "source_code": "\"\"\"Verify the structured close-retry evidence for the control route.\n\n1. Run the close operation through the session-close API variant fixture.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when the structured route is complete and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability, StateEvaluation, StateObservation, StateOracleProfile,\n StateOutcome, StateScenario, compile_state_steps,\n evaluation_digest, structured_fact,\n)\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"agent_api_close_retry_incomplete_control\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_VARIANTS_KEY = \"clipboard_api_variants\"\n_EXEC = (\n (\"kind\", \"control\"), (_VARIANTS_KEY, ((\n (\"heartbeat_file\", \"close_helper.heartbeat\"), (\"inject_fault\", False), (\"label\", \"control\"),\n (\"lease_file\", \"close_helper.lease\"), (\"operation\", \"close\"), (\"pid_file\", \"close_helper.pid\"),\n (\"prompt\", \"CLOSE_ROUTE_6501\"), (\"state_file\", \"close_helper.state\"),\n (\"stub\", (\n (\"mode\", \"seq_probe\"), (\"probe_tokens\", (\"CLOSE_ROUTE_6501\",)),\n (\"rounds\", (\n (((\"args\", ((\"run_in_background\", True),)), (\"command\", \"__CLOSE_COMMAND__\"), (\"name\", \"bash\")),),\n (((\"name\", \"__finish__\"),),),\n )),\n )),\n ),)) ,\n)\nSTEPS = (structured_fact(\"structured_facts\"),)\nRECIPE = compile_state_steps(\n STEPS, oracle_profile=StateOracleProfile.STRUCTURED_FACTS,\n oracle_parameters=((\"fact_key\", SCENARIO_ID),), execution_parameters=_EXEC,\n timeout_seconds=45,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the structured-facts close-retry contract using typed facts only.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = dict(observation.facts)\n passed, conclusive, reason = False, True, \"CHILD_RESULT_MISSING\"\n if not observation.fixture_verified:\n conclusive, reason = False, \"FIXTURE_UNVERIFIED\"\n elif facts.get(\"result_present\") is not True:\n reason = \"CHILD_RESULT_MISSING\"\n else:\n structured = facts.get(\"structured_facts\")\n structured = dict(structured) if type(structured) is tuple else {}\n row = structured.get(SCENARIO_ID)\n row = dict(row) if type(row) is tuple else {}\n if row.get(\"observed\") is not True or row.get(\"supported\") is False:\n conclusive, reason = False, \"STRUCTURED_FACTS_UNOBSERVED\"\n else:\n checks = row.get(\"checks\")\n checks = checks if type(checks) is tuple else ()\n if not checks:\n conclusive, reason = False, \"STRUCTURED_CHECKS_MISSING\"\n elif not all(item is True for item in checks):\n reason = \"STRUCTURED_FACTS_FAILED\"\n else:\n passed, reason = True, \"STRUCTURED_FACTS_CHECKED\"\n if conclusive and (not observation.process_tree_clean or not observation.workspace_clean):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(\n SCENARIO_ID, StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE if conclusive else StateApplicability.INCONCLUSIVE,\n reason, evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if conclusive else 0,\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "child_add_dir_inheritance", "family": "state", "category": "session state", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["child_add_dir_inheritance_control"], "requires": [], "summary": "Verify target child add-directory inheritance and its empty variant.", "description": "Verify target child add-directory inheritance and its empty variant.\n\n1. Run target child-grant and child-empty API variants with controlled read probes.\n2. Capture the scenario-specific structured-facts row after the control gate.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when inheritance boundaries are conclusive and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/child_add_dir_inheritance.py", "source_code": "\"\"\"Verify target child add-directory inheritance and its empty variant.\n\n1. Run target child-grant and child-empty API variants with controlled read probes.\n2. Capture the scenario-specific structured-facts row after the control gate.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when inheritance boundaries are conclusive and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n compile_state_steps,\n evaluation_digest,\n structured_fact,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"child_add_dir_inheritance\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_VARIANTS_KEY = \"api_probe_variants\"\n_EXECUTION_PARAMETERS = (\n (\n \"stub\",\n (\n (\"mode\", \"seq_probe\"),\n (\"probe_tokens\", (\"CHILD_TARGET_7325\", \"CHILD_EMPTY_7326\")),\n (\n \"rounds\",\n (\n (\n ((\"args\", ((\"file_path\", \"__REPO__/main.txt\"),)), (\"name\", \"read\")),\n ((\"args\", ((\"file_path\", \"__EXTRA__/extra.txt\"),)), (\"name\", \"read\")),\n ((\"args\", ((\"file_path\", \"__UNAUTHORIZED__/outside.txt\"),)), (\"name\", \"read\")),\n ),\n (((\"name\", \"__finish__\"),),),\n ),\n ),\n ),\n ),\n (\n _VARIANTS_KEY,\n (\n (\n (\"actor\", \"child\"), (\"add_dir\", True), (\"extra_token\", \"EXTRA_7322\"),\n (\"label\", \"child-target\"), (\"main_token\", \"MAIN_7321\"),\n (\"operation\", \"child\"), (\"prompt\", \"CHILD_TARGET_7325\"),\n (\"settle_s\", \"2.0\"), (\"shape\", \"child-target\"),\n (\"unauthorized_token\", \"UNAUTH_7323\"),\n ),\n (\n (\"actor\", \"child\"), (\"add_dir\", False), (\"extra_token\", \"EXTRA_7322\"),\n (\"label\", \"child-empty-target\"), (\"main_token\", \"MAIN_7321\"),\n (\"operation\", \"child\"), (\"prompt\", \"CHILD_EMPTY_7326\"),\n (\"settle_s\", \"2.0\"), (\"shape\", \"child-empty-target\"),\n (\"unauthorized_token\", \"UNAUTH_7323\"),\n ),\n ),\n ),\n)\nSTEPS = (structured_fact(\"structured_facts\"),)\nRECIPE = compile_state_steps(\n STEPS,\n oracle_profile=StateOracleProfile.STRUCTURED_FACTS,\n oracle_parameters=((\"fact_key\", SCENARIO_ID),),\n execution_parameters=_EXECUTION_PARAMETERS,\n dependencies=((\"child_add_dir_inheritance_control\", DependencyKind.GATE),),\n timeout_seconds=30,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the structured child-inheritance target contract using typed facts only.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = dict(observation.facts)\n passed, conclusive, reason = False, True, \"CHILD_RESULT_MISSING\"\n if not observation.fixture_verified:\n conclusive, reason = False, \"FIXTURE_UNVERIFIED\"\n elif facts.get(\"result_present\") is not True:\n reason = \"CHILD_RESULT_MISSING\"\n else:\n structured = facts.get(\"structured_facts\")\n structured = dict(structured) if type(structured) is tuple else {}\n row = structured.get(SCENARIO_ID)\n row = dict(row) if type(row) is tuple else {}\n if row.get(\"observed\") is not True or row.get(\"supported\") is False:\n conclusive, reason = False, \"STRUCTURED_FACTS_UNOBSERVED\"\n else:\n checks = row.get(\"checks\")\n checks = checks if type(checks) is tuple else ()\n if not checks:\n conclusive, reason = False, \"STRUCTURED_CHECKS_MISSING\"\n elif not all(item is True for item in checks):\n reason = \"STRUCTURED_FACTS_FAILED\"\n else:\n passed, reason = True, \"STRUCTURED_FACTS_CHECKED\"\n if conclusive and (not observation.process_tree_clean or not observation.workspace_clean):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(\n SCENARIO_ID,\n StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE if conclusive else StateApplicability.INCONCLUSIVE,\n reason,\n evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if conclusive else 0,\n )\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "child_add_dir_inheritance_control", "family": "state", "category": "session state", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify the control route for child add-directory inheritance.", "description": "Verify the control route for child add-directory inheritance.\n\n1. Run parent-grant and child-empty API variants with controlled read probes.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when inheritance boundaries are conclusive and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/child_add_dir_inheritance_control.py", "source_code": "\"\"\"Verify the control route for child add-directory inheritance.\n\n1. Run parent-grant and child-empty API variants with controlled read probes.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when inheritance boundaries are conclusive and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n compile_state_steps,\n evaluation_digest,\n structured_fact,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"child_add_dir_inheritance_control\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_VARIANTS_KEY = \"api_probe_variants\"\n_EXECUTION_PARAMETERS = (\n (\"kind\", \"control\"),\n (\n \"stub\",\n (\n (\"mode\", \"seq_probe\"),\n (\"probe_tokens\", (\"CHILD_PARENT_7324\", \"CHILD_EMPTY_7326\")),\n (\n \"rounds\",\n (\n (\n ((\"args\", ((\"file_path\", \"__REPO__/main.txt\"),)), (\"name\", \"read\")),\n ((\"args\", ((\"file_path\", \"__EXTRA__/extra.txt\"),)), (\"name\", \"read\")),\n ((\"args\", ((\"file_path\", \"__UNAUTHORIZED__/outside.txt\"),)), (\"name\", \"read\")),\n ),\n (((\"name\", \"__finish__\"),),),\n ),\n ),\n ),\n ),\n (\n _VARIANTS_KEY,\n (\n (\n (\"actor\", \"parent\"), (\"add_dir\", True), (\"extra_token\", \"EXTRA_7322\"),\n (\"label\", \"parent-grant\"), (\"main_token\", \"MAIN_7321\"),\n (\"operation\", \"child\"), (\"prompt\", \"CHILD_PARENT_7324\"),\n (\"shape\", \"parent-grant\"), (\"unauthorized_token\", \"UNAUTH_7323\"),\n ),\n (\n (\"actor\", \"child\"), (\"add_dir\", False), (\"extra_token\", \"EXTRA_7322\"),\n (\"label\", \"child-empty\"), (\"main_token\", \"MAIN_7321\"),\n (\"operation\", \"child\"), (\"prompt\", \"CHILD_EMPTY_7326\"),\n (\"settle_s\", \"2.0\"), (\"shape\", \"child-empty\"),\n (\"unauthorized_token\", \"UNAUTH_7323\"),\n ),\n ),\n ),\n)\nSTEPS = (structured_fact(\"structured_facts\"),)\nRECIPE = compile_state_steps(\n STEPS,\n oracle_profile=StateOracleProfile.STRUCTURED_FACTS,\n oracle_parameters=((\"fact_key\", SCENARIO_ID),),\n execution_parameters=_EXECUTION_PARAMETERS,\n timeout_seconds=30,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the structured child-inheritance control contract using typed facts only.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = dict(observation.facts)\n passed, conclusive, reason = False, True, \"CHILD_RESULT_MISSING\"\n if not observation.fixture_verified:\n conclusive, reason = False, \"FIXTURE_UNVERIFIED\"\n elif facts.get(\"result_present\") is not True:\n reason = \"CHILD_RESULT_MISSING\"\n else:\n structured = facts.get(\"structured_facts\")\n structured = dict(structured) if type(structured) is tuple else {}\n row = structured.get(SCENARIO_ID)\n row = dict(row) if type(row) is tuple else {}\n if row.get(\"observed\") is not True or row.get(\"supported\") is False:\n conclusive, reason = False, \"STRUCTURED_FACTS_UNOBSERVED\"\n else:\n checks = row.get(\"checks\")\n checks = checks if type(checks) is tuple else ()\n if not checks:\n conclusive, reason = False, \"STRUCTURED_CHECKS_MISSING\"\n elif not all(item is True for item in checks):\n reason = \"STRUCTURED_FACTS_FAILED\"\n else:\n passed, reason = True, \"STRUCTURED_FACTS_CHECKED\"\n if conclusive and (not observation.process_tree_clean or not observation.workspace_clean):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(\n SCENARIO_ID,\n StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE if conclusive else StateApplicability.INCONCLUSIVE,\n reason,\n evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if conclusive else 0,\n )\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "copy_utf8_clipboard_bytes", "family": "state", "category": "session state", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["copy_utf8_clipboard_control"], "requires": [], "summary": "Verify that the target route preserves UTF-8 clipboard bytes.", "description": "Verify that the target route preserves UTF-8 clipboard bytes.\n\n1. Run the UTF-8 copy operation through the target API variant after its control gate.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when the structured route is complete and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/copy_utf8_clipboard_bytes.py", "source_code": "\"\"\"Verify that the target route preserves UTF-8 clipboard bytes.\n\n1. Run the UTF-8 copy operation through the target API variant after its control gate.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when the structured route is complete and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n compile_state_steps,\n evaluation_digest,\n structured_fact,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"copy_utf8_clipboard_bytes\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_VARIANTS_KEY = \"clipboard_api_variants\"\n_EXECUTION_PARAMETERS = (\n (\n _VARIANTS_KEY,\n ((\n (\"capture\", \"clipboard_capture.bin\"),\n (\"label\", \"target\"),\n (\"meta\", \"clipboard_meta.json\"),\n (\"operation\", \"copy\"),\n (\"prompt\", \"COPY_ROUTE_6601\"),\n (\"stub\", (\n (\"mode\", \"fixed_reply\"),\n (\"probe_tokens\", (\"COPY_ROUTE_6601\",)),\n (\"reply_content\", \"COPY_UTF8_6603 雪豹 café Δ\"),\n )),\n ),),\n ),\n)\nSTEPS = (structured_fact(\"structured_facts\"),)\nRECIPE = compile_state_steps(\n STEPS,\n oracle_profile=StateOracleProfile.STRUCTURED_FACTS,\n oracle_parameters=((\"fact_key\", SCENARIO_ID),),\n execution_parameters=_EXECUTION_PARAMETERS,\n dependencies=((\"copy_utf8_clipboard_control\", DependencyKind.GATE),),\n timeout_seconds=45,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the structured UTF-8 clipboard contract using typed facts only.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = dict(observation.facts)\n passed, conclusive, reason = False, True, \"CHILD_RESULT_MISSING\"\n if not observation.fixture_verified:\n conclusive, reason = False, \"FIXTURE_UNVERIFIED\"\n elif facts.get(\"result_present\") is not True:\n reason = \"CHILD_RESULT_MISSING\"\n else:\n structured = facts.get(\"structured_facts\")\n structured = dict(structured) if type(structured) is tuple else {}\n row = structured.get(SCENARIO_ID)\n row = dict(row) if type(row) is tuple else {}\n if row.get(\"observed\") is not True or row.get(\"supported\") is False:\n conclusive, reason = False, \"STRUCTURED_FACTS_UNOBSERVED\"\n else:\n checks = row.get(\"checks\")\n checks = checks if type(checks) is tuple else ()\n if not checks:\n conclusive, reason = False, \"STRUCTURED_CHECKS_MISSING\"\n elif not all(item is True for item in checks):\n reason = \"STRUCTURED_FACTS_FAILED\"\n else:\n passed, reason = True, \"STRUCTURED_FACTS_CHECKED\"\n if conclusive and (not observation.process_tree_clean or not observation.workspace_clean):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(\n SCENARIO_ID,\n StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE if conclusive else StateApplicability.INCONCLUSIVE,\n reason,\n evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if conclusive else 0,\n )\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "copy_utf8_clipboard_control", "family": "state", "category": "session state", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify the control route for UTF-8 clipboard copying.", "description": "Verify the control route for UTF-8 clipboard copying.\n\n1. Run the fixed-reply copy operation through the control API variant.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when the structured route is complete and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/copy_utf8_clipboard_control.py", "source_code": "\"\"\"Verify the control route for UTF-8 clipboard copying.\n\n1. Run the fixed-reply copy operation through the control API variant.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true behavioral check vector.\n4. Return PASS only when the structured route is complete and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n compile_state_steps,\n evaluation_digest,\n structured_fact,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"copy_utf8_clipboard_control\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_VARIANTS_KEY = \"clipboard_api_variants\"\n_EXECUTION_PARAMETERS = (\n (\"kind\", \"control\"),\n (\n _VARIANTS_KEY,\n ((\n (\"capture\", \"clipboard_capture.bin\"),\n (\"label\", \"control\"),\n (\"meta\", \"clipboard_meta.json\"),\n (\"operation\", \"copy\"),\n (\"prompt\", \"COPY_ROUTE_6601\"),\n (\"stub\", (\n (\"mode\", \"fixed_reply\"),\n (\"probe_tokens\", (\"COPY_ROUTE_6601\",)),\n (\"reply_content\", \"COPY_ASCII_6602 exact bytes\"),\n )),\n ),),\n ),\n)\nSTEPS = (structured_fact(\"structured_facts\"),)\nRECIPE = compile_state_steps(\n STEPS,\n oracle_profile=StateOracleProfile.STRUCTURED_FACTS,\n oracle_parameters=((\"fact_key\", SCENARIO_ID),),\n execution_parameters=_EXECUTION_PARAMETERS,\n timeout_seconds=45,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the structured clipboard control contract using typed facts only.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = dict(observation.facts)\n passed, conclusive, reason = False, True, \"CHILD_RESULT_MISSING\"\n if not observation.fixture_verified:\n conclusive, reason = False, \"FIXTURE_UNVERIFIED\"\n elif facts.get(\"result_present\") is not True:\n reason = \"CHILD_RESULT_MISSING\"\n else:\n structured = facts.get(\"structured_facts\")\n structured = dict(structured) if type(structured) is tuple else {}\n row = structured.get(SCENARIO_ID)\n row = dict(row) if type(row) is tuple else {}\n if row.get(\"observed\") is not True or row.get(\"supported\") is False:\n conclusive, reason = False, \"STRUCTURED_FACTS_UNOBSERVED\"\n else:\n checks = row.get(\"checks\")\n checks = checks if type(checks) is tuple else ()\n if not checks:\n conclusive, reason = False, \"STRUCTURED_CHECKS_MISSING\"\n elif not all(item is True for item in checks):\n reason = \"STRUCTURED_FACTS_FAILED\"\n else:\n passed, reason = True, \"STRUCTURED_FACTS_CHECKED\"\n if conclusive and (not observation.process_tree_clean or not observation.workspace_clean):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(\n SCENARIO_ID,\n StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE if conclusive else StateApplicability.INCONCLUSIVE,\n reason,\n evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if conclusive else 0,\n )\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "custom_args_no_secondary_expansion", "family": "state", "category": "session state", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["custom_args_single_expansion_control"], "requires": [], "summary": "Verify that a custom command does not perform secondary expansion.", "description": "Verify that a custom command does not perform secondary expansion.\n\n1. Restore the central guarded-command and secret fixtures.\n2. Execute the command sequence with its guarded argument payload.\n3. Observe request probes and the protected execution file.\n4. Pass only when the face and argument are seen without secret leakage or execution.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/custom_args_no_secondary_expansion.py", "source_code": "\"\"\"Verify that a custom command does not perform secondary expansion.\n\n1. Restore the central guarded-command and secret fixtures.\n2. Execute the command sequence with its guarded argument payload.\n3. Observe request probes and the protected execution file.\n4. Pass only when the face and argument are seen without secret leakage or execution.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n command,\n compile_state_steps,\n evaluation_digest,\n observe_file,\n observe_requests,\n seed_file,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"custom_args_no_secondary_expansion\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_SEED_STEPS = tuple(\n seed_file(path, content) for path, content in _BASE_SCENARIO.recipe.seed_files\n)\n_COMMAND_STEPS = tuple(command(value) for value in _BASE_SCENARIO.recipe.commands)\nSTEPS = (\n *_SEED_STEPS,\n *_COMMAND_STEPS,\n observe_file(_BASE_SCENARIO.recipe.observed_files[0]),\n observe_requests(),\n)\nRECIPE = compile_state_steps(\n STEPS,\n oracle_profile=StateOracleProfile.CUSTOM_NO_SECONDARY,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n dependencies=_BASE_SCENARIO.recipe.dependencies,\n timeout_seconds=_BASE_SCENARIO.recipe.timeout_seconds,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef _mapping(value: object) -> dict[str, object]:\n if type(value) is tuple and all(\n type(item) is tuple and len(item) == 2 and type(item[0]) is str\n for item in value\n ):\n return dict(value)\n return {}\n\n\ndef _requests(value: object) -> tuple[dict[str, object], ...]:\n return (\n tuple(_mapping(item) for item in value if type(item) is tuple)\n if type(value) is tuple\n else ()\n )\n\n\ndef _probe(request: dict[str, object], token: str) -> bool:\n return _mapping(request.get(\"probes\")).get(token) is True\n\n\ndef _texts(value: object) -> tuple[str, ...]:\n return (\n tuple(item for item in value if type(item) is str)\n if type(value) is tuple\n else ()\n )\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the CUSTOM_NO_SECONDARY contract using typed facts.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = _mapping(observation.facts)\n params = _mapping(RECIPE.oracle_parameters)\n requests = _requests(facts.get(\"requests\"))\n blob = (\n \" || \".join(_texts(facts.get(\"returns\")))\n + \" || \"\n + (facts.get(\"console\") if type(facts.get(\"console\")) is str else \"\")\n )\n\n def observed(token: object) -> bool:\n value = token if type(token) is str else \"\"\n return any(_probe(request, value) for request in requests) or value in blob\n\n if not observed(params.get(\"face_token\")) or not observed(params.get(\"args_token\")):\n passed, conclusive, reason = False, False, \"CUSTOM_ARGUMENTS_UNOBSERVED\"\n else:\n files = _mapping(facts.get(\"files\"))\n secret = (\n params.get(\"secret_token\")\n if type(params.get(\"secret_token\")) is str\n else \"\"\n )\n path = params.get(\"path\")\n passed = not observed(secret) and files.get(path) is None\n conclusive, reason = True, \"CUSTOM_SECONDARY_BOUNDARY_CHECKED\"\n if conclusive and (\n not observation.process_tree_clean or not observation.workspace_clean\n ):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(\n SCENARIO_ID,\n StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE\n if conclusive\n else StateApplicability.INCONCLUSIVE,\n reason,\n evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if conclusive else 0,\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "custom_args_single_expansion_control", "family": "state", "category": "session state", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify the control path expands custom-command arguments exactly once.", "description": "Verify the control path expands custom-command arguments exactly once.\n\n1. Restore the central command and fixture definitions.\n2. Execute the controlled command sequence and observe the request wire.\n3. Check the face, argument, file, and non-empty output evidence.\n4. Pass only when all expansion facts are observable and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/custom_args_single_expansion_control.py", "source_code": "\"\"\"Verify the control path expands custom-command arguments exactly once.\n\n1. Restore the central command and fixture definitions.\n2. Execute the controlled command sequence and observe the request wire.\n3. Check the face, argument, file, and non-empty output evidence.\n4. Pass only when all expansion facts are observable and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n command,\n compile_state_steps,\n evaluation_digest,\n observe_file,\n observe_requests,\n seed_file,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"custom_args_single_expansion_control\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_SEED_STEPS = tuple(\n seed_file(path, content) for path, content in _BASE_SCENARIO.recipe.seed_files\n)\n_COMMAND_STEPS = tuple(command(value) for value in _BASE_SCENARIO.recipe.commands)\nSTEPS = (\n *_SEED_STEPS,\n *_COMMAND_STEPS,\n observe_file(_BASE_SCENARIO.recipe.observed_files[0]),\n observe_requests(),\n)\nRECIPE = compile_state_steps(\n STEPS,\n oracle_profile=StateOracleProfile.CUSTOM_SINGLE_EXPANSION,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n dependencies=_BASE_SCENARIO.recipe.dependencies,\n timeout_seconds=_BASE_SCENARIO.recipe.timeout_seconds,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef _mapping(value: object) -> dict[str, object]:\n if type(value) is tuple and all(\n type(item) is tuple and len(item) == 2 and type(item[0]) is str\n for item in value\n ):\n return dict(value)\n return {}\n\n\ndef _requests(value: object) -> tuple[dict[str, object], ...]:\n return (\n tuple(_mapping(item) for item in value if type(item) is tuple)\n if type(value) is tuple\n else ()\n )\n\n\ndef _probe(request: dict[str, object], token: str) -> bool:\n return _mapping(request.get(\"probes\")).get(token) is True\n\n\ndef _texts(value: object) -> tuple[str, ...]:\n return (\n tuple(item for item in value if type(item) is str)\n if type(value) is tuple\n else ()\n )\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the CUSTOM_SINGLE_EXPANSION contract using typed facts.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = _mapping(observation.facts)\n params = _mapping(RECIPE.oracle_parameters)\n requests = _requests(facts.get(\"requests\"))\n blob = (\n \" || \".join(_texts(facts.get(\"returns\")))\n + \" || \"\n + (facts.get(\"console\") if type(facts.get(\"console\")) is str else \"\")\n )\n\n def observed(token: object) -> bool:\n value = token if type(token) is str else \"\"\n return any(_probe(request, value) for request in requests) or value in blob\n\n face = params.get(\"face_token\")\n if not observed(face):\n passed, conclusive, reason = False, False, \"CUSTOM_COMMAND_UNOBSERVED\"\n else:\n files = _mapping(facts.get(\"files\"))\n path = params.get(\"path\")\n content = files.get(path)\n passed = (\n observed(params.get(\"args_token\"))\n and observed(params.get(\"file_token\"))\n and type(content) is str\n and bool(content.strip())\n )\n conclusive, reason = True, \"CUSTOM_SINGLE_EXPANSION_CHECKED\"\n if conclusive and (\n not observation.process_tree_clean or not observation.workspace_clean\n ):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(\n SCENARIO_ID,\n StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE\n if conclusive\n else StateApplicability.INCONCLUSIVE,\n reason,\n evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if conclusive else 0,\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "memory_query_topk_residency", "family": "state", "category": "session state", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["memory_query_topk_residency_control"], "requires": [], "summary": "Verify that memory top-k residency stays bounded from small to large fixtures.", "description": "Verify that memory top-k residency stays bounded from small to large fixtures.\n\n1. Run the small and large memory fixtures with the same bounded top-k query.\n2. Capture the scenario-specific structured-facts row after the control gate.\n3. Require observed/support evidence and an all-true residency check vector.\n4. Return PASS only when both sizes remain bounded and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/memory_query_topk_residency.py", "source_code": "\"\"\"Verify that memory top-k residency stays bounded from small to large fixtures.\n\n1. Run the small and large memory fixtures with the same bounded top-k query.\n2. Capture the scenario-specific structured-facts row after the control gate.\n3. Require observed/support evidence and an all-true residency check vector.\n4. Return PASS only when both sizes remain bounded and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.definition import DependencyKind\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n compile_state_steps,\n evaluation_digest,\n structured_fact,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"memory_query_topk_residency\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_VARIANTS_KEY = \"clipboard_api_variants\"\n_ROUNDS = (\n (((\"args\", ((\"limit\", 3), (\"query\", \"zirconium quasar heliotrope\"))), (\"name\", (\"memory_search\", \"memory-search\", \"memorysearch\"))),),\n (((\"name\", \"__finish__\"),),),\n)\n_EXECUTION_PARAMETERS = (\n (_VARIANTS_KEY, (\n ((\"decoy\", \"DECOY_\"), (\"entries\", 2000), (\"label\", \"small\"), (\"markers\", (\"MEMORY_ALPHA_6402\", \"MEMORY_BETA_6403\", \"MEMORY_GAMMA_6404\")), (\"operation\", \"memory\"), (\"rss_probe_bytes\", 16777216), (\"stub\", ((\"mode\", \"seq_probe\"), (\"probe_tokens\", (\"MEMORY_TARGET_ROUTE_6406\",)), (\"rounds\", _ROUNDS))), (\"target_prompt\", \"MEMORY_TARGET_ROUTE_6406\"), (\"warm_query\", \"warmup_only_6401\")),\n ((\"decoy\", \"DECOY_\"), (\"entries\", 120000), (\"label\", \"large\"), (\"markers\", (\"MEMORY_ALPHA_6402\", \"MEMORY_BETA_6403\", \"MEMORY_GAMMA_6404\")), (\"operation\", \"memory\"), (\"rss_probe_bytes\", 16777216), (\"stub\", ((\"mode\", \"seq_probe\"), (\"probe_tokens\", (\"MEMORY_TARGET_ROUTE_6406\",)), (\"rounds\", _ROUNDS))), (\"target_prompt\", \"MEMORY_TARGET_ROUTE_6406\"), (\"warm_query\", \"warmup_only_6401\")),\n )),\n)\nSTEPS = (structured_fact(\"structured_facts\"),)\nRECIPE = compile_state_steps(\n STEPS,\n oracle_profile=StateOracleProfile.STRUCTURED_FACTS,\n oracle_parameters=((\"fact_key\", SCENARIO_ID),),\n execution_parameters=_EXECUTION_PARAMETERS,\n dependencies=((\"memory_query_topk_residency_control\", DependencyKind.GATE),),\n timeout_seconds=180,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the structured memory-residency target contract using typed facts only.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = dict(observation.facts)\n passed, conclusive, reason = False, True, \"CHILD_RESULT_MISSING\"\n if not observation.fixture_verified:\n conclusive, reason = False, \"FIXTURE_UNVERIFIED\"\n else:\n structured = facts.get(\"structured_facts\")\n structured = dict(structured) if type(structured) is tuple else {}\n row = structured.get(SCENARIO_ID)\n row = dict(row) if type(row) is tuple else {}\n if row.get(\"observed\") is not True or row.get(\"supported\") is False:\n conclusive, reason = False, \"STRUCTURED_FACTS_UNOBSERVED\"\n else:\n checks = row.get(\"checks\")\n checks = checks if type(checks) is tuple else ()\n if not checks:\n conclusive, reason = False, \"STRUCTURED_CHECKS_MISSING\"\n elif not all(item is True for item in checks):\n reason = \"STRUCTURED_FACTS_FAILED\"\n else:\n passed, reason = True, \"STRUCTURED_FACTS_CHECKED\"\n if conclusive and (not observation.process_tree_clean or not observation.workspace_clean):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(SCENARIO_ID, StateOutcome.PASS if passed else StateOutcome.FAIL, StateApplicability.APPLICABLE if conclusive else StateApplicability.INCONCLUSIVE, reason, evaluation_digest(SCENARIO, observation), SCENARIO.definition.weight_microunits if conclusive else 0)\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "memory_query_topk_residency_control", "family": "state", "category": "session state", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify the control route for a bounded memory top-k query.", "description": "Verify the control route for a bounded memory top-k query.\n\n1. Run the small control memory fixture with a bounded top-k query.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true residency check vector.\n4. Return PASS only when the control query is complete and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/memory_query_topk_residency_control.py", "source_code": "\"\"\"Verify the control route for a bounded memory top-k query.\n\n1. Run the small control memory fixture with a bounded top-k query.\n2. Capture the scenario-specific structured-facts row.\n3. Require observed/support evidence and an all-true residency check vector.\n4. Return PASS only when the control query is complete and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n compile_state_steps,\n evaluation_digest,\n structured_fact,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"memory_query_topk_residency_control\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\n_VARIANTS_KEY = \"clipboard_api_variants\"\n_EXECUTION_PARAMETERS = (\n (\"kind\", \"control\"),\n (_VARIANTS_KEY, ((\n (\"decoy\", \"DECOY_\"),\n (\"entries\", 2000),\n (\"label\", \"control\"),\n (\"markers\", (\"MEMORY_ALPHA_6402\", \"MEMORY_BETA_6403\", \"MEMORY_GAMMA_6404\")),\n (\"operation\", \"memory\"),\n (\"rss_probe_bytes\", 16777216),\n (\"stub\", ((\"mode\", \"seq_probe\"), (\"probe_tokens\", (\"MEMORY_TARGET_ROUTE_6406\",)), (\"rounds\", (\n (((\"args\", ((\"limit\", 3), (\"query\", \"zirconium quasar heliotrope\"))), (\"name\", (\"memory_search\", \"memory-search\", \"memorysearch\"))),),\n (((\"name\", \"__finish__\"),),),\n )))),\n (\"target_prompt\", \"MEMORY_TARGET_ROUTE_6406\"),\n (\"warm_query\", \"warmup_only_6401\"),\n ),),),\n)\nSTEPS = (structured_fact(\"structured_facts\"),)\nRECIPE = compile_state_steps(\n STEPS,\n oracle_profile=StateOracleProfile.STRUCTURED_FACTS,\n oracle_parameters=((\"fact_key\", SCENARIO_ID),),\n execution_parameters=_EXECUTION_PARAMETERS,\n timeout_seconds=120,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the structured memory-residency control contract using typed facts only.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = dict(observation.facts)\n passed, conclusive, reason = False, True, \"CHILD_RESULT_MISSING\"\n if not observation.fixture_verified:\n conclusive, reason = False, \"FIXTURE_UNVERIFIED\"\n else:\n structured = facts.get(\"structured_facts\")\n structured = dict(structured) if type(structured) is tuple else {}\n row = structured.get(SCENARIO_ID)\n row = dict(row) if type(row) is tuple else {}\n if row.get(\"observed\") is not True or row.get(\"supported\") is False:\n conclusive, reason = False, \"STRUCTURED_FACTS_UNOBSERVED\"\n else:\n checks = row.get(\"checks\")\n checks = checks if type(checks) is tuple else ()\n if not checks:\n conclusive, reason = False, \"STRUCTURED_CHECKS_MISSING\"\n elif not all(item is True for item in checks):\n reason = \"STRUCTURED_FACTS_FAILED\"\n else:\n public_calls = row.get(\"public_calls\")\n if type(public_calls) is not bool:\n conclusive, reason = False, \"STRUCTURED_PUBLIC_CALLS_UNOBSERVED\"\n elif public_calls is not True:\n reason = \"STRUCTURED_PUBLIC_CALLS_FAILED\"\n else:\n passed, reason = True, \"STRUCTURED_FACTS_CHECKED\"\n if conclusive and (not observation.process_tree_clean or not observation.workspace_clean):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(SCENARIO_ID, StateOutcome.PASS if passed else StateOutcome.FAIL, StateApplicability.APPLICABLE if conclusive else StateApplicability.INCONCLUSIVE, reason, evaluation_digest(SCENARIO, observation), SCENARIO.definition.weight_microunits if conclusive else 0)\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "p30_ctl_security_review_sees_worktree_change", "family": "state", "category": "session state", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify that the security-review control route sees a worktree change.", "description": "Verify that the security-review control route sees a worktree change.\n\n1. Seed the scenario-specific fixture files and invoke the command sequence.\n2. Capture the model request facts after the scenario's execution gates.\n3. Check whether the expected token appears in a request probe.\n4. Return PASS only when the request is observed and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/p30_ctl_security_review_sees_worktree_change.py", "source_code": "\"\"\"Verify that the security-review control route sees a worktree change.\n\n1. Seed the scenario-specific fixture files and invoke the command sequence.\n2. Capture the model request facts after the scenario's execution gates.\n3. Check whether the expected token appears in a request probe.\n4. Return PASS only when the request is observed and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n command,\n compile_state_steps,\n evaluation_digest,\n observe_requests,\n seed_file,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"p30_ctl_security_review_sees_worktree_change\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSTEPS = (\n seed_file(\"vuln_9601.py\", \"import os\\n\"),\n command(\"/security-review\"),\n observe_requests(),\n)\nRECIPE = compile_state_steps(\n STEPS,\n oracle_profile=StateOracleProfile.REQUEST_TOKEN_PRESENT,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n dependencies=_BASE_SCENARIO.recipe.dependencies,\n timeout_seconds=_BASE_SCENARIO.recipe.timeout_seconds,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef _mapping(value: object) -> dict[str, object]:\n if type(value) is tuple and all(\n type(item) is tuple and len(item) == 2 and type(item[0]) is str\n for item in value\n ):\n return dict(value)\n return {}\n\n\ndef _requests(value: object) -> tuple[dict[str, object], ...]:\n if type(value) is not tuple:\n return ()\n return tuple(_mapping(item) for item in value if type(item) is tuple)\n\n\ndef _probe(request: dict[str, object], token: str) -> bool:\n return _mapping(request.get(\"probes\")).get(token) is True\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the REQUEST_TOKEN_PRESENT contract using typed request facts.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = _mapping(observation.facts)\n requests = _requests(facts.get(\"requests\"))\n params = _mapping(RECIPE.oracle_parameters)\n token = params.get(\"token\") if type(params.get(\"token\")) is str else \"\"\n passed, conclusive, reason = False, True, \"REQUEST_TOKEN_CHECKED\"\n if not requests:\n conclusive, reason = False, \"MODEL_TURN_UNOBSERVED\"\n else:\n passed = any(_probe(request, token) for request in requests)\n if conclusive and (\n not observation.process_tree_clean or not observation.workspace_clean\n ):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(\n SCENARIO_ID,\n StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE\n if conclusive\n else StateApplicability.INCONCLUSIVE,\n reason,\n evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if conclusive else 0,\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "plugin_declared_command_reaches_wire", "family": "state", "category": "session state", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["plugin_toplevel_command_control"], "requires": [], "summary": "Verify that a plugin-declared command face reaches the model wire.", "description": "Verify that a plugin-declared command face reaches the model wire.\n\n1. Seed the plugin manifest and its command file, then invoke `/probecmd`.\n2. Send the continuation prompt through the same session.\n3. Capture the recorder-owned command-face request probe after the gate.\n4. Pass only when the plugin token reaches a model request without an unknown-command result.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/plugin_declared_command_reaches_wire.py", "source_code": "\"\"\"Verify that a plugin-declared command face reaches the model wire.\n\n1. Seed the plugin manifest and its command file, then invoke `/probecmd`.\n2. Send the continuation prompt through the same session.\n3. Capture the recorder-owned command-face request probe after the gate.\n4. Pass only when the plugin token reaches a model request without an unknown-command result.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n command,\n compile_state_steps,\n evaluation_digest,\n observe_requests,\n seed_file,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"plugin_declared_command_reaches_wire\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSTEPS = (\n seed_file(\"plugins/probeplug/commands/probecmd.md\", \"Summarize PLUGCMD_5150 for the team now.\\n\"),\n seed_file(\"plugins/probeplug/plugin.json\", '{\\n \"name\": \"probeplug\",\\n \"description\": \"probe plugin\",\\n \"commands\": [\\n \"commands/probecmd.md\"\\n ]\\n}'),\n command(\"/probecmd\"),\n command(\"please continue\"),\n observe_requests(),\n)\nRECIPE = compile_state_steps(STEPS, oracle_profile=StateOracleProfile.CUSTOM_COMMAND_FACE,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n dependencies=_BASE_SCENARIO.recipe.dependencies, timeout_seconds=_BASE_SCENARIO.recipe.timeout_seconds)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef _probe(request: dict[str, object], token: str) -> bool:\n probes = request.get(\"probes\")\n return type(probes) is tuple and dict(probes).get(token) is True\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the custom-command face contract using typed request facts only.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = dict(observation.facts)\n requests = facts.get(\"requests\")\n requests = requests if type(requests) is tuple else ()\n requests = tuple(dict(item) for item in requests if type(item) is tuple)\n returns = facts.get(\"returns\")\n returns = returns if type(returns) is tuple else ()\n params = dict(RECIPE.oracle_parameters)\n passed, conclusive, reason = False, True, \"CUSTOM_COMMAND_FACE_CHECKED\"\n if not observation.fixture_verified:\n conclusive, reason = False, \"FIXTURE_UNVERIFIED\"\n elif returns and any(\"unknown command\" in str(item).lower() for item in returns):\n reason = \"CUSTOM_COMMAND_MISSING\"\n elif not requests:\n conclusive, reason = False, \"MODEL_TURN_UNOBSERVED\"\n else:\n passed = any(_probe(request, params[\"token\"]) for request in requests)\n if conclusive and (not observation.process_tree_clean or not observation.workspace_clean):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(SCENARIO_ID, StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE if conclusive else StateApplicability.INCONCLUSIVE,\n reason, evaluation_digest(SCENARIO, observation), SCENARIO.definition.weight_microunits if conclusive else 0)\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "plugin_toplevel_command_control", "family": "state", "category": "session state", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify the control route for a top-level custom command face.", "description": "Verify the control route for a top-level custom command face.\n\n1. Seed the top-level command file and invoke `/probecmd`.\n2. Send the continuation prompt through the same session.\n3. Capture the recorder-owned command-face request probe.\n4. Pass only when the command token reaches a model request without an unknown-command result.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/plugin_toplevel_command_control.py", "source_code": "\"\"\"Verify the control route for a top-level custom command face.\n\n1. Seed the top-level command file and invoke `/probecmd`.\n2. Send the continuation prompt through the same session.\n3. Capture the recorder-owned command-face request probe.\n4. Pass only when the command token reaches a model request without an unknown-command result.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n command,\n compile_state_steps,\n evaluation_digest,\n observe_requests,\n seed_file,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"plugin_toplevel_command_control\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSTEPS = (\n seed_file(\"commands/probecmd.md\", \"Summarize PLUGCMD_5150 for the team now.\\n\"),\n command(\"/probecmd\"),\n command(\"please continue\"),\n observe_requests(),\n)\nRECIPE = compile_state_steps(STEPS, oracle_profile=StateOracleProfile.CUSTOM_COMMAND_FACE,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n dependencies=_BASE_SCENARIO.recipe.dependencies, timeout_seconds=_BASE_SCENARIO.recipe.timeout_seconds)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef _probe(request: dict[str, object], token: str) -> bool:\n probes = request.get(\"probes\")\n return type(probes) is tuple and dict(probes).get(token) is True\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the custom-command face contract using typed request facts only.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = dict(observation.facts)\n requests = facts.get(\"requests\")\n requests = requests if type(requests) is tuple else ()\n requests = tuple(dict(item) for item in requests if type(item) is tuple)\n returns = facts.get(\"returns\")\n returns = returns if type(returns) is tuple else ()\n params = dict(RECIPE.oracle_parameters)\n passed, conclusive, reason = False, True, \"CUSTOM_COMMAND_FACE_CHECKED\"\n if not observation.fixture_verified:\n conclusive, reason = False, \"FIXTURE_UNVERIFIED\"\n elif returns and any(\"unknown command\" in str(item).lower() for item in returns):\n reason = \"CUSTOM_COMMAND_MISSING\"\n elif not requests:\n conclusive, reason = False, \"MODEL_TURN_UNOBSERVED\"\n else:\n passed = any(_probe(request, params[\"token\"]) for request in requests)\n if conclusive and (not observation.process_tree_clean or not observation.workspace_clean):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(SCENARIO_ID, StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE if conclusive else StateApplicability.INCONCLUSIVE,\n reason, evaluation_digest(SCENARIO, observation), SCENARIO.definition.weight_microunits if conclusive else 0)\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "security_review_covers_branch_commits", "family": "state", "category": "session state", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["p30_ctl_security_review_sees_worktree_change"], "requires": [], "summary": "Verify that security review covers a branch commit after the worktree change.", "description": "Verify that security review covers a branch commit after the worktree change.\n\n1. Seed the scenario-specific fixture files and invoke the command sequence.\n2. Capture the model request facts after the scenario's execution gates.\n3. Check whether the expected token appears in a request probe.\n4. Return PASS only when the request is observed and cleanup is clean.", "source_path": "src/doc2harness/benchmark/harnesses/state/scenarios/security_review_covers_branch_commits.py", "source_code": "\"\"\"Verify that security review covers a branch commit after the worktree change.\n\n1. Seed the scenario-specific fixture files and invoke the command sequence.\n2. Capture the model request facts after the scenario's execution gates.\n3. Check whether the expected token appears in a request probe.\n4. Return PASS only when the request is observed and cleanup is clean.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.state.contracts import (\n StateApplicability,\n StateEvaluation,\n StateObservation,\n StateOracleProfile,\n StateOutcome,\n StateScenario,\n command,\n compile_state_steps,\n evaluation_digest,\n observe_requests,\n seed_file,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"security_review_covers_branch_commits\"\n_BASE_SCENARIO = scenario_by_id(SCENARIO_ID)\nSTEPS = (\n seed_file(\"vuln_9601.py\", \"import os\\n\"),\n command(\"/security-review\"),\n observe_requests(),\n)\nRECIPE = compile_state_steps(\n STEPS,\n oracle_profile=StateOracleProfile.REQUEST_TOKEN_PRESENT,\n oracle_parameters=_BASE_SCENARIO.recipe.oracle_parameters,\n execution_parameters=_BASE_SCENARIO.recipe.execution_parameters,\n dependencies=_BASE_SCENARIO.recipe.dependencies,\n timeout_seconds=_BASE_SCENARIO.recipe.timeout_seconds,\n)\nSCENARIO: StateScenario = StateScenario(_BASE_SCENARIO.definition, RECIPE)\nscenario = _BASE_SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef _mapping(value: object) -> dict[str, object]:\n if type(value) is tuple and all(\n type(item) is tuple and len(item) == 2 and type(item[0]) is str\n for item in value\n ):\n return dict(value)\n return {}\n\n\ndef _requests(value: object) -> tuple[dict[str, object], ...]:\n if type(value) is not tuple:\n return ()\n return tuple(_mapping(item) for item in value if type(item) is tuple)\n\n\ndef _probe(request: dict[str, object], token: str) -> bool:\n return _mapping(request.get(\"probes\")).get(token) is True\n\n\ndef judge(observation: StateObservation) -> StateEvaluation:\n \"\"\"Apply the REQUEST_TOKEN_PRESENT contract using typed request facts.\"\"\"\n if observation.scenario_id != SCENARIO_ID:\n raise ValueError(\"state observation belongs to another scenario\")\n facts = _mapping(observation.facts)\n requests = _requests(facts.get(\"requests\"))\n params = _mapping(RECIPE.oracle_parameters)\n token = params.get(\"token\") if type(params.get(\"token\")) is str else \"\"\n passed, conclusive, reason = False, True, \"REQUEST_TOKEN_CHECKED\"\n if not requests:\n conclusive, reason = False, \"MODEL_TURN_UNOBSERVED\"\n else:\n passed = any(_probe(request, token) for request in requests)\n if conclusive and (\n not observation.process_tree_clean or not observation.workspace_clean\n ):\n passed, reason = False, \"EXECUTION_CLEANUP_FAILED\"\n return StateEvaluation(\n SCENARIO_ID,\n StateOutcome.PASS if passed else StateOutcome.FAIL,\n StateApplicability.APPLICABLE\n if conclusive\n else StateApplicability.INCONCLUSIVE,\n reason,\n evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if conclusive else 0,\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "history_realpath_key", "family": "tui", "category": "interactive terminal", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["history_workspace_a_fresh_control", "history_workspace_b_fresh_control"], "requires": [], "summary": "Verify history is keyed by the workspace real path.", "description": "Verify history is keyed by the workspace real path.\n\n1. Run two workspace views that resolve to the same real path.\n2. Observe history lookup and the final process status.\n3. Require the completion token without a crash signature.\n4. Pass only when the real-path key is honored.", "source_path": "src/doc2harness/benchmark/harnesses/tui/scenarios/history_realpath_key.py", "source_code": "\"\"\"Verify history is keyed by the workspace real path.\n\n1. Run two workspace views that resolve to the same real path.\n2. Observe history lookup and the final process status.\n3. Require the completion token without a crash signature.\n4. Pass only when the real-path key is honored.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.tui.contracts import (\n TuiApplicability, TuiEvaluation, TuiObservation, TuiOutcome, TuiScenario,\n evaluation_digest,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"history_realpath_key\"\nSCENARIO: TuiScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: TuiObservation) -> TuiEvaluation:\n text = observation.screen_text\n bind = RECIPE.oracle\n live = bool(text.strip())\n passed = live and bind.completion_token in text and not any(\n token in text for token in bind.crash_signatures\n )\n return TuiEvaluation(SCENARIO_ID, TuiOutcome.PASS if passed else TuiOutcome.FAIL,\n TuiApplicability.APPLICABLE if live else TuiApplicability.INCONCLUSIVE,\n \"TUI_PROFILE_CHECKED\", evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if live else 0)\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "history_workspace_a_fresh_control", "family": "tui", "category": "interactive terminal", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify a fresh workspace starts with an isolated history control.", "description": "Verify a fresh workspace starts with an isolated history control.\n\n1. Start the workspace with an empty history store.\n2. Observe the initial history state and process status.\n3. Require the completion token without a crash signature.\n4. Pass only when no stale history is inherited.", "source_path": "src/doc2harness/benchmark/harnesses/tui/scenarios/history_workspace_a_fresh_control.py", "source_code": "\"\"\"Verify a fresh workspace starts with an isolated history control.\n\n1. Start the workspace with an empty history store.\n2. Observe the initial history state and process status.\n3. Require the completion token without a crash signature.\n4. Pass only when no stale history is inherited.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.tui.contracts import (\n TuiApplicability, TuiEvaluation, TuiObservation, TuiOutcome, TuiScenario,\n evaluation_digest,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"history_workspace_a_fresh_control\"\nSCENARIO: TuiScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: TuiObservation) -> TuiEvaluation:\n text = observation.screen_text\n bind = RECIPE.oracle\n live = bool(text.strip())\n passed = live and bind.completion_token in text and not any(\n token in text for token in bind.crash_signatures\n )\n return TuiEvaluation(SCENARIO_ID, TuiOutcome.PASS if passed else TuiOutcome.FAIL,\n TuiApplicability.APPLICABLE if live else TuiApplicability.INCONCLUSIVE,\n \"TUI_PROFILE_CHECKED\", evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if live else 0)\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "history_workspace_b_fresh_control", "family": "tui", "category": "interactive terminal", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify a second fresh workspace has isolated history.", "description": "Verify a second fresh workspace has isolated history.\n\n1. Start workspace B with an empty history store.\n2. Observe its initial history and process status.\n3. Require completion without a crash signature.\n4. Pass only when workspace A history is not inherited.", "source_path": "src/doc2harness/benchmark/harnesses/tui/scenarios/history_workspace_b_fresh_control.py", "source_code": "\"\"\"Verify a second fresh workspace has isolated history.\n\n1. Start workspace B with an empty history store.\n2. Observe its initial history and process status.\n3. Require completion without a crash signature.\n4. Pass only when workspace A history is not inherited.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.tui.contracts import (\n TuiApplicability, TuiEvaluation, TuiObservation, TuiOutcome, TuiScenario,\n evaluation_digest,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"history_workspace_b_fresh_control\"\nSCENARIO: TuiScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: TuiObservation) -> TuiEvaluation:\n text = observation.screen_text\n bind = RECIPE.oracle\n live = bool(text.strip())\n passed = live and bind.completion_token in text and not any(\n token in text for token in bind.crash_signatures\n )\n return TuiEvaluation(SCENARIO_ID, TuiOutcome.PASS if passed else TuiOutcome.FAIL,\n TuiApplicability.APPLICABLE if live else TuiApplicability.INCONCLUSIVE,\n \"TUI_PROFILE_CHECKED\", evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if live else 0)\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "trajectory_autocommit_fail_recorded", "family": "tui", "category": "interactive terminal", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["trajectory_autocommit_fail_recorded_control"], "requires": [], "summary": "Require an autocommit failure and its cause in the trajectory.", "description": "Require an autocommit failure and its cause in the trajectory.\n\n1. Run a write with an isolated failing Git hook or signing program.\n2. Observe the persisted trajectory and dynamic failure token.\n3. Require explicit auto-commit ownership and failure semantics.", "source_path": "src/doc2harness/benchmark/harnesses/tui/scenarios/trajectory_autocommit_fail_recorded.py", "source_code": "\"\"\"Require an autocommit failure and its cause in the trajectory.\n\n1. Run a write with an isolated failing Git hook or signing program.\n2. Observe the persisted trajectory and dynamic failure token.\n3. Require explicit auto-commit ownership and failure semantics.\n\"\"\"\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom ..adapter import build_scenario, make_judge\n\nSCENARIO_ID = \"trajectory_autocommit_fail_recorded\"\nSCENARIO = build_scenario(SCENARIO_ID, ScenarioRole.TARGET, \"trajectory_autocommit_fail_recorded_control\", \"gpg_fail\")\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n_judge = make_judge(SCENARIO, \"autocommit_fail\")\ndef judge(observation):\n return _judge(observation)\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "trajectory_autocommit_fail_recorded_control", "family": "tui", "category": "interactive terminal", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Control for the autocommit-failure trajectory stimulus.", "description": "Control for the autocommit-failure trajectory stimulus.", "source_path": "src/doc2harness/benchmark/harnesses/tui/scenarios/trajectory_autocommit_fail_recorded_control.py", "source_code": "\"\"\"Control for the autocommit-failure trajectory stimulus.\"\"\"\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom ..adapter import build_scenario, make_judge\n\nSCENARIO_ID = \"trajectory_autocommit_fail_recorded_control\"\nSCENARIO = build_scenario(SCENARIO_ID, ScenarioRole.CONTROL, None, \"seq_probe\")\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n_judge = make_judge(SCENARIO, \"autocommit_fail\")\ndef judge(observation):\n return _judge(observation)\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "trajectory_step_limit_terminal_accurate", "family": "tui", "category": "interactive terminal", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": ["trajectory_step_limit_terminal_accurate_control"], "requires": [], "summary": "Require an explicit step-limit terminal event in the trajectory.", "description": "Require an explicit step-limit terminal event in the trajectory.\n\n1. Run the bounded PTY conversation against the normal mock gateway.\n2. Observe the externally persisted trajectory rather than recorder facts.\n3. Require both a limit marker and a terminal event; ordinary completion is insufficient.", "source_path": "src/doc2harness/benchmark/harnesses/tui/scenarios/trajectory_step_limit_terminal_accurate.py", "source_code": "\"\"\"Require an explicit step-limit terminal event in the trajectory.\n\n1. Run the bounded PTY conversation against the normal mock gateway.\n2. Observe the externally persisted trajectory rather than recorder facts.\n3. Require both a limit marker and a terminal event; ordinary completion is insufficient.\n\"\"\"\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom ..adapter import build_scenario, make_judge\n\nSCENARIO_ID = \"trajectory_step_limit_terminal_accurate\"\nSCENARIO = build_scenario(SCENARIO_ID, ScenarioRole.TARGET, \"trajectory_step_limit_terminal_accurate_control\", \"seq_probe\")\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n_judge = make_judge(SCENARIO, \"step_limit\")\ndef judge(observation):\n return _judge(observation)\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "trajectory_step_limit_terminal_accurate_control", "family": "tui", "category": "interactive terminal", "role": "positive_control", "scored": false, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Control for an externally observed step-limit terminal trajectory.", "description": "Control for an externally observed step-limit terminal trajectory.\n\n1. Run the bounded PTY conversation against the normal mock gateway.\n2. Observe requests, exit status, cleanup, and trajectory files.\n3. Establish that the stimulus and terminal channel are live.", "source_path": "src/doc2harness/benchmark/harnesses/tui/scenarios/trajectory_step_limit_terminal_accurate_control.py", "source_code": "\"\"\"Control for an externally observed step-limit terminal trajectory.\n\n1. Run the bounded PTY conversation against the normal mock gateway.\n2. Observe requests, exit status, cleanup, and trajectory files.\n3. Establish that the stimulus and terminal channel are live.\n\"\"\"\nfrom doc2harness.benchmark.definition import ScenarioRole\nfrom ..adapter import build_scenario, make_judge\n\nSCENARIO_ID = \"trajectory_step_limit_terminal_accurate_control\"\nSCENARIO = build_scenario(SCENARIO_ID, ScenarioRole.CONTROL, None, \"seq_probe\")\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n_judge = make_judge(SCENARIO, \"step_limit\")\ndef judge(observation):\n return _judge(observation)\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "tui_bang_alone_enters_shell_mode", "family": "tui", "category": "interactive terminal", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify a standalone bang enters shell mode and returns cleanly.", "description": "Verify a standalone bang enters shell mode and returns cleanly.\n\n1. Submit the standalone bang command and observe shell-mode output.\n2. Submit the follow-up probe turn.\n3. Require completion without a crash signature.\n4. Pass only when shell-mode interaction remains usable.", "source_path": "src/doc2harness/benchmark/harnesses/tui/scenarios/tui_bang_alone_enters_shell_mode.py", "source_code": "\"\"\"Verify a standalone bang enters shell mode and returns cleanly.\n\n1. Submit the standalone bang command and observe shell-mode output.\n2. Submit the follow-up probe turn.\n3. Require completion without a crash signature.\n4. Pass only when shell-mode interaction remains usable.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.tui.contracts import (\n TuiApplicability, TuiEvaluation, TuiObservation, TuiOutcome, TuiScenario,\n evaluation_digest,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"tui_bang_alone_enters_shell_mode\"\nSCENARIO: TuiScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: TuiObservation) -> TuiEvaluation:\n text = observation.screen_text\n bind = RECIPE.oracle\n live = bool(text.strip())\n # The declared oracle for this point is FILE_WRITTEN: the shell line must\n # really run and leave the file behind. Judging the survival sentinel\n # instead asks whether the *driver's own* closing line was echoed, which a\n # session answers whether or not the point's line did anything. Read the\n # file the recipe\n # declared, exactly as the shared oracle for this profile does.\n item = next(\n (entry for entry in observation.files if entry.path == bind.path), None,\n )\n passed = (\n live\n and item is not None\n and item.present\n and bind.primary_token in item.content\n and not any(token in text for token in bind.crash_signatures)\n )\n return TuiEvaluation(SCENARIO_ID, TuiOutcome.PASS if passed else TuiOutcome.FAIL,\n TuiApplicability.APPLICABLE if live else TuiApplicability.INCONCLUSIVE,\n \"TUI_PROFILE_CHECKED\", evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if live else 0)\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |
| {"scenario_id": "tui_ctrl_byte_storm_survives", "family": "tui", "category": "interactive terminal", "role": "test_case", "scored": true, "difficulty": "hard", "gated_by": [], "requires": [], "summary": "Verify a control-byte storm leaves the TUI alive.", "description": "Verify a control-byte storm leaves the TUI alive.\n\n1. Feed the control-byte fixture and wait for completion.\n2. Observe the final screen text and process status.\n3. Require the completion marker and no crash signature.\n4. Pass only when the TUI survives the input storm.", "source_path": "src/doc2harness/benchmark/harnesses/tui/scenarios/tui_ctrl_byte_storm_survives.py", "source_code": "\"\"\"Verify a control-byte storm leaves the TUI alive.\n\n1. Feed the control-byte fixture and wait for completion.\n2. Observe the final screen text and process status.\n3. Require the completion marker and no crash signature.\n4. Pass only when the TUI survives the input storm.\n\"\"\"\n\nfrom doc2harness.benchmark.harnesses.tui.contracts import (\n TuiApplicability,\n TuiEvaluation,\n TuiObservation,\n TuiOutcome,\n TuiScenario,\n evaluation_digest,\n)\n\nfrom ..recipes import scenario_by_id\n\nSCENARIO_ID = \"tui_ctrl_byte_storm_survives\"\nSCENARIO: TuiScenario = scenario_by_id(SCENARIO_ID)\nRECIPE = SCENARIO.recipe\nSTEPS = (RECIPE,)\nscenario = SCENARIO\ndefinition = SCENARIO.definition\n\n\ndef judge(observation: TuiObservation) -> TuiEvaluation:\n text = observation.screen_text\n bind = RECIPE.oracle\n live = bool(text.strip())\n passed = (\n live\n and bind.completion_token in text\n and not any(token in text for token in bind.crash_signatures)\n )\n return TuiEvaluation(\n SCENARIO_ID,\n TuiOutcome.PASS if passed else TuiOutcome.FAIL,\n TuiApplicability.APPLICABLE if live else TuiApplicability.INCONCLUSIVE,\n \"TUI_PROFILE_CHECKED\",\n evaluation_digest(SCENARIO, observation),\n SCENARIO.definition.weight_microunits if live else 0,\n )\n\n\n__all__ = [\"RECIPE\", \"SCENARIO\", \"STEPS\", \"definition\", \"judge\", \"scenario\"]\n"} | |