{"files": {"README.md": {"sha256": "bd8615367f623680d051c30e93d55fdf70a4753d46040802d4ad5702c11b4056", "text": "# Review-permissions teaching example\n\nFollow https://synthlabs.mintlify.app/tutorials/first-review . This directory contains a complete\nHarbor task package, reviewer profile and example evaluation/training plans.\nUpload only review-permissions/, not this enclosing directory.\n\nThe task deliberately contains one small authorization regression. Its verifier\nchecks an executable counterexample, not all aspects of natural-language review\nquality. A good score on this example does not establish general reviewer quality.\nThe verifier is not copied into the actor image.\n\nThe profile permits Read, Glob, Grep, Bash and Write without interactive approval.\nIt is intended for the prepared managed task, not arbitrary host execution.\nDo not run it locally without reviewing its permissions and files.\n\nSign in with `synth login`, then run the read-only setup check:\n`python3 check_setup.py`. The evaluation plan requests exactly one trial.\nThe Docker base is pinned by image digest.\n\nThe included training plan is an illustration for a multi-task practice dataset.\nIt requests 24 slots. It is not a recommendation to train only on this one toy\ntask or evidence that doing so will improve a real code reviewer.\n"}, "check_setup.py": {"sha256": "345bfd6f259c06b708fa5e74dc13507b9dfe26334e271059b88c9c29e22a3efe", "text": "#!/usr/bin/env python3\n\"\"\"Read-only local prerequisite check. Does not prove server access or spend.\"\"\"\nimport argparse\nimport hashlib\nimport json\nfrom pathlib import Path\nimport subprocess\nimport sys\nfrom urllib.parse import urlsplit\n\nEXPECTED = 'synth 0.0.1-alpha.62'\nPRODUCTION = 'https://sprites-gateway.api.synthlabs.ai'\n\n\ndef invoke(args):\n    try:\n        result = subprocess.run(['synth', *args], capture_output=True, text=True, timeout=30)\n    except FileNotFoundError:\n        raise ValueError('Synth CLI was not found on PATH; install CLI alpha.62: '\n                         'https://synthlabs.mintlify.app/getting-started/install') from None\n    if result.returncode:\n        raise ValueError('synth ' + ' '.join(args[:2]) + ' failed; inspect that command before proceeding')\n    return result.stdout\n\n\ndef check(directory, confirmed=None, runner=invoke):\n    # Keep the old optional argument for callers of previous example releases.\n    if sys.version_info < (3, 10):\n        raise ValueError('Python 3.10 or later is required')\n    version = runner(['version']).strip()\n    if version != EXPECTED:\n        raise ValueError('This example is qualified with ' + EXPECTED + '; inspect your installed release')\n    status = json.loads(runner(['status', '--json']))\n    if not isinstance(status, dict) or not status.get('request_authenticated') or status.get('service_key_active'):\n        raise ValueError('Sign in with synth login, then run this check again')\n    try:\n        endpoint = urlsplit(status.get('api_base_url', ''))\n        port = endpoint.port\n        unsafe = (endpoint.scheme != 'https' or not endpoint.hostname\n                  or endpoint.username is not None or endpoint.password is not None\n                  or bool(endpoint.query) or bool(endpoint.fragment)\n                  or port == 0)\n    except (AttributeError, TypeError, ValueError):\n        unsafe = True\n    if unsafe:\n        raise ValueError('The CLI connection must be a valid HTTPS URL without embedded credentials, a query or fragment')\n    profile = directory/'reviewer.json'\n    if profile.is_symlink() or not profile.is_file():\n        raise ValueError('Run this check beside the ordinary reviewer.json supplied in the project')\n    runner(['agent', 'validate', '@'+str(profile)])\n    return {'schema':'synth.example-readiness.v1', 'local_prerequisites':'passed',\n            'cli':version, 'python':'.'.join(map(str,sys.version_info[:3])),\n            'profile_sha256':hashlib.sha256(profile.read_bytes()).hexdigest(),\n            'server_admission':'not tested', 'model_availability':'not tested',\n            'paid_work_submitted':False,\n            'next':'Follow the first-result tutorial. Only an actual accepted execution proves live compatibility.'}\n\n\nif __name__ == '__main__':\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument('--confirm-dev', action='store_true', help=argparse.SUPPRESS)\n    options = parser.parse_args()\n    try:\n        print(json.dumps(check(Path(__file__).resolve().parent, options.confirm_dev), indent=2))\n    except (ValueError, OSError, subprocess.SubprocessError) as error:\n        raise SystemExit(str(error))\n"}, "eval-plan.json": {"sha256": "007471ec031cd0f06aec10a7ca49bea60a8508e93845990ce038519783d79c4b", "text": "{\"trials_per_task\": 1}\n"}, "review-permissions/environment/Dockerfile": {"sha256": "785459ebd2ec29890351da8b331af68d900edda07b85206d564f53ee242da487", "text": "FROM python:3.12-slim@sha256:f77ac9e44ae96ef2c90b8053ea08c31f8be030f824196b0ae4db6d462c84e51f\nRUN apt-get update \\\n    && apt-get install -y --no-install-recommends bash ca-certificates curl git \\\n    && rm -rf /var/lib/apt/lists/*\nRUN useradd --create-home --uid 1000 reviewer \\\n    && mkdir -p /app /logs/artifacts \\\n    && chown reviewer:reviewer /logs/artifacts\nCOPY permissions.py POLICY.md change.diff /app/\nWORKDIR /app\n# Environment setup needs root. task.toml runs the actor as reviewer; do not\n# change the whole sandbox's default user or setup cannot create its log paths.\n"}, "review-permissions/environment/POLICY.md": {"sha256": "5f58865ba373343da15180e5895d085a2d07e8584b7df0c067c6120319df19f7", "text": "# Export access\n\nAn export may be downloaded only by an administrator of the organization that\nowns it. Both conditions are required. Being an administrator does not authorize\naccess to another organization's export.\n"}, "review-permissions/environment/change.diff": {"sha256": "dd19566858e1f91b7fcd0b2651edca4e7ad7ddaa5e49b8ad7d306aaa27b804b0", "text": "--- a/permissions.py\n+++ b/permissions.py\n@@ -14,7 +14,7 @@\n \n \n def can_download(user, export):\n-    return user.is_admin and user.org_id == export.org_id\n+    return user.is_admin or user.org_id == export.org_id\n \n \n def download_export(user, export):\n"}, "review-permissions/environment/permissions.py": {"sha256": "ae0a98f4e169135046eee3282569abffc6b5dbc775f2f618351d70f7fac21df1", "text": "from dataclasses import dataclass\n\n\n@dataclass\nclass User:\n    is_admin: bool\n    org_id: str\n\n\n@dataclass\nclass Export:\n    org_id: str\n    contents: bytes = b\"private export\"\n\n\ndef can_download(user, export):\n    return user.is_admin or user.org_id == export.org_id\n\n\ndef download_export(user, export):\n    if not can_download(user, export):\n        raise PermissionError(\"Export access denied\")\n    return export.contents\n"}, "review-permissions/instruction.md": {"sha256": "b80266a7595c089443a2bb69970a26b3dc5c59267ffec3329ac486034714e274", "text": "# Review the permission change\n\nReview /app/change.diff against the export-access policy in /app/POLICY.md.\nThe current implementation and caller are in /app/permissions.py.\nReport a consequential bug introduced by the change.\n\nWrite /logs/artifacts/review.json with this structure:\n\n```json\n{\n  \"findings\": [\n    {\n      \"path\": \"permissions.py\",\n      \"title\": \"Short description\",\n      \"explanation\": \"Connect the changed code to the failing input and consequence.\",\n      \"counterexample\": {\n        \"is_admin\": true,\n        \"user_org_id\": \"example-org\",\n        \"export_org_id\": \"example-org\"\n      }\n    }\n  ]\n}\n```\n\nThe object above illustrates the format, not a failing input. Your\ncounterexample must be a real input that the changed implementation allows\nbut the stated policy forbids. Use JSON booleans, not strings. Report the root\ncause once; do not duplicate it for several inputs. If you find no supported\nissue, write an empty findings array.\n\nDo not modify the implementation. You may read it and execute small checks.\nThe verifier checks the counterexample against the code and policy; it cannot\nfully assess the quality of your explanation. This is a small teaching example,\nnot an exhaustive test of code-review ability.\n"}, "review-permissions/task.toml": {"sha256": "6a02e47b142b072d268fce0f5726fdfd823703e19ed5098ac92c808d3f3bf96e", "text": "version = \"1.0\"\n\n[metadata]\nname = \"review-permissions\"\ndescription = \"Review an authorization regression and supply an executable counterexample.\"\n\n[agent]\nuser = \"reviewer\"\ntimeout_sec = 180\n\n[verifier]\ntimeout_sec = 60\n\n[environment]\ncpus = 1\nmemory_mb = 4096\n"}, "review-permissions/tests/grade.py": {"sha256": "48458fa920f38dfcd8caddfbcf466eb082aaced68e37b91ffde7b51eeca4fee0", "text": "\"\"\"Assess executable counterexamples, not the semantic quality of review prose.\"\"\"\nimport argparse\nimport importlib.util\nimport json\nimport pathlib\nimport sys\n\n\ndef load_implementation(path):\n    spec = importlib.util.spec_from_file_location(\"review_example\", path)\n    module = importlib.util.module_from_spec(spec)\n    sys.modules[spec.name] = module\n    spec.loader.exec_module(module)\n    return module\n\n\ndef grade(review, implementation):\n    findings = review.get(\"findings\") if isinstance(review, dict) else None\n    if not isinstance(findings, list):\n        return {\"reward\": 0.0, \"rationale\": \"Expected a findings array.\"}\n    if len(findings) != 1:\n        return {\"reward\": 0.0, \"rationale\": \"Report the single root cause once, or no finding.\"}\n    finding = findings[0]\n    if not isinstance(finding, dict) or finding.get(\"path\") != \"permissions.py\":\n        return {\"reward\": 0.0, \"rationale\": \"The finding must identify permissions.py.\"}\n    if any(not isinstance(finding.get(key), str) or not finding[key].strip()\n           for key in (\"title\", \"explanation\")):\n        return {\"reward\": 0.0, \"rationale\": \"Provide a title and explanation.\"}\n    case = finding.get(\"counterexample\")\n    if not isinstance(case, dict) or type(case.get(\"is_admin\")) is not bool:\n        return {\"reward\": 0.0, \"rationale\": \"Provide a counterexample with a JSON boolean is_admin.\"}\n    if any(not isinstance(case.get(key), str) or not case[key]\n           for key in (\"user_org_id\", \"export_org_id\")):\n        return {\"reward\": 0.0, \"rationale\": \"Counterexample organization IDs must be nonempty strings.\"}\n    user = implementation.User(case[\"is_admin\"], case[\"user_org_id\"])\n    export = implementation.Export(case[\"export_org_id\"])\n    policy_allows = user.is_admin and user.org_id == export.org_id\n    implementation_allows = implementation.can_download(user, export)\n    try:\n        leaked = implementation.download_export(user, export) == export.contents\n    except PermissionError:\n        leaked = False\n    valid = implementation_allows is True and policy_allows is False and leaked\n    return {\n        \"reward\": 1.0 if valid else 0.0,\n        \"rationale\": (\"The supplied input demonstrates a forbidden download.\" if valid\n                      else \"The supplied input does not demonstrate the regression.\"),\n        \"assessment_scope\": \"executable counterexample; prose quality is not independently scored\",\n    }\n\n\ndef main():\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--review\", required=True)\n    parser.add_argument(\"--reward\", required=True)\n    parser.add_argument(\"--implementation\", default=\"/app/permissions.py\")\n    args = parser.parse_args()\n    implementation = load_implementation(args.implementation)\n    try:\n        review = json.loads(pathlib.Path(args.review).read_text())\n    except (OSError, ValueError):\n        result = {\"reward\": 0.0, \"rationale\": \"The review file is missing or is not valid JSON.\"}\n    else:\n        result = grade(review, implementation)\n    destination = pathlib.Path(args.reward)\n    destination.parent.mkdir(parents=True, exist_ok=True)\n    # Harbor's executable-verifier result is a numeric mapping. Keep prose in\n    # a separate retained artifact; the model-judge adapter is a distinct API.\n    destination.with_name(\"assessment.json\").write_text(json.dumps(result) + \"\\n\")\n    destination.write_text(json.dumps({\"reward\": result[\"reward\"]}) + \"\\n\")\n\n\nif __name__ == \"__main__\":\n    main()\n"}, "review-permissions/tests/test.sh": {"sha256": "7b2b0eea302d05e0ee5844886f78a04a4c180581c968fec5ff2c541b292ee2b7", "text": "#!/bin/sh\nset -eu\npython3 /tests/grade.py --review /logs/artifacts/review.json --reward /logs/verifier/reward.json\n"}, "reviewer.json": {"sha256": "fad2582eafde35f74c1ba25eaf0a9c9522704e8a870b4eb734fdc2d766e8c713", "text": "{\n  \"schema\": \"synth.agent-profile.v2\",\n  \"agent\": {\n    \"model\": \"Qwen/Qwen3.8-27B:peft:262144\",\n    \"engine\": {\"type\": \"claude-code\", \"version\": \"2.1.263\"},\n    \"files\": {\n      \"mcp\": {\"path\": \"mcp.json\", \"content\": \"{\\\"mcpServers\\\":{}}\\n\"}\n    },\n    \"execution\": {\n      \"cwd\": \"{{task.workspace}}\",\n      \"args\": [\n        \"--model\", \"{{model}}\",\n        \"--session-id\", \"{{run.session_id}}\",\n        \"--setting-sources\", \"\",\n        \"--permission-mode\", \"dontAsk\",\n        \"--tools\", \"Read,Glob,Grep,Bash,Write\",\n        \"--allowedTools\", \"Read,Glob,Grep,Bash,Write\",\n        \"--disallowedTools\", \"WebSearch,WebFetch,Agent,Task\",\n        \"--strict-mcp-config\",\n        \"--mcp-config\", \"{{files.mcp}}\",\n        \"--print\"\n      ],\n      \"stdin\": {\"file\": \"{{task.instruction_file}}\"}\n    },\n    \"outputs\": {\n      \"review\": {\"path\": \"/logs/artifacts/review.json\", \"required\": true}\n    }\n  }\n}\n"}, "train-plan.json": {"sha256": "6e1b073635eb955f3a60196167f128f133373f984dbf3f8396430ee8578c0f78", "text": "{\"num_batches\": 3, \"batch\": {\"tasks\": 2, \"trials_per_task\": 4}}\n"}}, "name": "review-permissions", "schema": "synth.tutorial-project.v1"}
