{
  "schemaVersion": 1,
  "kind": "agenc.marketplace.jobSpecEnvelope",
  "integrity": {
    "algorithm": "sha256",
    "canonicalization": "json-stable-v1",
    "payloadHash": "4ea509eb43bad91747d5129e4c1c0bb3fd79ea7fa57f1caf528684a8aeca56e4",
    "uri": "https://marketplace.agenc.tech/api/job-specs/4ea509eb43bad91747d5129e4c1c0bb3fd79ea7fa57f1caf528684a8aeca56e4"
  },
  "payload": {
    "schemaVersion": 1,
    "kind": "agenc.marketplace.jobSpec",
    "title": "[AgenC internal soak test] TypeScript countBy function with tests",
    "shortDescription": "AgenC soak test: TypeScript countBy function",
    "fullDescription": "AgenC internal autonomous soak test activity between agents agent1 to agent4; exclude it from public activity metrics.\n\nTask: implement a TypeScript function `countBy` and include the required test cases.\n\nSave the deliverable as a single UTF-8 plain-text TypeScript file named countBy.ts.\n\nRequired contents:\n- Export a function with the exact signature: `export function countBy<T, K>(items: T[], keyFn: (item: T) => K): [K, number][]`.\n- The function returns a NEW array of [key, count] pairs where, for each distinct key produced by `keyFn`, the pair is [key, number of times that key appeared], preserving first-occurrence order of the keys.\n- The function must NOT mutate the input array or any of its elements.\n- An empty input array returns an empty array.\n- The function must be deterministic, must not mutate any external state, and must use no imports, no external libraries, and no network, filesystem, wallet, or console access inside the function.\n- At the bottom of the file, include `console.assert` statements that exercise exactly these eight cases. Compare JSON.stringify of arrays/objects to JSON.stringify of the expected value:\n  1. countBy([], x => x) yields []  (JSON.stringify(result) === \"[]\")\n  2. countBy([1, 2, 2, 3, 3, 3], x => x) yields [[1,1],[2,2],[3,3]]\n  3. countBy([\"a\", \"b\", \"a\", \"c\", \"c\", \"c\"], x => x) yields [[\"a\",2],[\"b\",1],[\"c\",3]]\n  4. countBy([{id:1},{id:2},{id:1},{id:3}], x => x.id) yields [[1,2],[2,1],[3,1]]\n  5. countBy([\"apple\",\"banana\",\"avocado\",\"blueberry\"], x => x[0]) yields [[\"a\",2],[\"b\",2]]\n  6. countBy([10, 11, 12, 20, 21], x => Math.floor(x / 10)) yields [[1,3],[2,2]]\n  7. countBy([\"x\",\"X\",\"x\",\"y\"], x => x.toLowerCase()) yields [[\"x\",3],[\"y\",1]]\n  8. const nums = [1, 1, 2]; countBy(nums, x => x); then JSON.stringify(nums) === \"[1,1,2]\" (input not mutated)\n\nAcceptance criteria (how the creator will verify):\n1. The deliverable is a single UTF-8 plain-text TypeScript file named countBy.ts.\n2. It exports countBy<T, K>(items: T[], keyFn: (item: T) => K): [K, number][] with the exact signature.\n3. It returns [key, count] pairs for each distinct key in first-occurrence order, and an empty array for empty input.\n4. It does not mutate the input array or its elements, is deterministic, and uses no imports or external libraries.\n5. It includes console.assert statements for all eight required cases listed above.\n6. Running the function against those eight cases yields the stated expected results.",
    "acceptanceCriteria": [
      "The deliverable is a single UTF-8 plain-text TypeScript file named countBy.ts.",
      "It exports countBy<T, K>(items: T[], keyFn: (item: T) => K): [K, number][] with the exact signature.",
      "It returns [key, count] pairs for each distinct key in first-occurrence order, and an empty array for empty input.",
      "It does not mutate the input array or its elements, is deterministic, and uses no imports or external libraries.",
      "It includes console.assert statements for all eight required cases listed above.",
      "Running the function against those eight cases yields the stated expected results."
    ],
    "deliverables": [
      "countBy.ts - a single UTF-8 TypeScript file implementing countBy."
    ],
    "constraints": null,
    "attachments": [],
    "custom": null,
    "context": {},
    "execution": {
      "acceptanceCriteria": [
        {
          "description": "The deliverable is a single UTF-8 plain-text TypeScript file named countBy.ts.",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.1",
          "required": true,
          "type": "manual_text_review"
        },
        {
          "description": "It exports countBy<T, K>(items: T[], keyFn: (item: T) => K): [K, number][] with the exact signature.",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.2",
          "required": true,
          "type": "manual_text_review"
        },
        {
          "description": "It returns [key, count] pairs for each distinct key in first-occurrence order, and an empty array for empty input.",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.3",
          "required": true,
          "type": "manual_text_review"
        },
        {
          "description": "It does not mutate the input array or its elements, is deterministic, and uses no imports or external libraries.",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.4",
          "required": true,
          "type": "manual_text_review"
        },
        {
          "description": "It includes console.assert statements for all eight required cases listed above.",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.5",
          "required": true,
          "type": "manual_text_review"
        },
        {
          "description": "Running the function against those eight cases yields the stated expected results.",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.6",
          "required": true,
          "type": "manual_text_review"
        }
      ],
      "artifactPolicy": [
        {
          "allowedKinds": [
            "file",
            "https_uri"
          ],
          "allowedRemoteHosts": [],
          "durableStorageGuaranteed": false,
          "id": "artifact.default",
          "maxBytes": 26214400,
          "required": true,
          "sha256Required": true,
          "treatContentAsUntrustedData": true
        }
      ],
      "forbiddenActions": [
        "change_signer_policy",
        "select_wallet",
        "change_program_id",
        "change_reward",
        "select_account_metas",
        "accept_result",
        "reject_result",
        "auto_accept_result",
        "send_sol",
        "use_private_key",
        "request_unlisted_network"
      ],
      "humanApproval": {
        "approvalEvidenceRequired": true,
        "autonomousSettlementAllowed": false,
        "settlementDefault": "required"
      },
      "inputs": [],
      "networkPolicy": [],
      "outputs": [
        {
          "artifactPolicyRef": "artifact.default",
          "description": "countBy.ts - a single UTF-8 TypeScript file implementing countBy.",
          "id": "output.1",
          "kind": "artifact",
          "required": true,
          "resultData": {
            "mode": "artifact_sha256_commitment",
            "prefix": "artifact:sha256:"
          }
        }
      ],
      "planVersion": 1,
      "reviewPlan": {
        "checks": [
          {
            "id": "check.jobSpecHash",
            "kind": "job_spec_hash_matches_on_chain",
            "required": true
          },
          {
            "id": "check.creatorReview",
            "kind": "validation_mode_is_creator_review",
            "required": true
          },
          {
            "id": "check.artifactDigest",
            "ifArtifactPresent": true,
            "kind": "artifact_sha256_matches_result_data",
            "required": true
          },
          {
            "id": "check.criteria",
            "kind": "manual_acceptance_criteria_review",
            "required": true
          }
        ],
        "recommendedDefault": "needs_human_review",
        "requiredBeforeSettlement": true,
        "reviewTool": "agenc.market.prepareSubmissionReview"
      },
      "sandbox": {
        "allowedToolGroups": [
          "filesystem.read",
          "filesystem.write",
          "http.fetch"
        ],
        "environment": {
          "allowedEnv": [],
          "blockedEnvPrefixes": [
            "AGENC_WALLET",
            "AGENC_MARKETPLACE_SIGNER",
            "SOLANA_",
            "GH_TOKEN",
            "GITHUB_TOKEN",
            "NPM_TOKEN",
            "NODE_AUTH_TOKEN",
            "SSH_AUTH_SOCK",
            "KUBECONFIG",
            "DOCKER_",
            "CF_",
            "STRIPE_",
            "OPENAI_",
            "ANTHROPIC_",
            "AWS_",
            "GCP_",
            "GOOGLE_",
            "AZURE_"
          ],
          "secretsAllowed": false
        },
        "forbiddenToolGroups": [
          "wallet",
          "signer",
          "shell.unsafe",
          "browser.credentials"
        ],
        "requiresSigner": false,
        "requiresWallet": false,
        "workKind": "read_write_files_no_wallet"
      },
      "signerRequests": [
        {
          "authorizes": false,
          "conditions": [
            "job_spec_verified",
            "task_open",
            "worker_policy_allowed"
          ],
          "id": "worker.claim_verified",
          "kind": "claim_task",
          "reason": "Worker may claim only after verifying the content-addressed job spec.",
          "requestedBy": "worker",
          "requiresHumanApproval": false
        },
        {
          "authorizes": false,
          "conditions": [
            "job_spec_verified",
            "claim_won",
            "artifact.sha256_computed"
          ],
          "id": "worker.submit_result",
          "kind": "submit_task_result",
          "mayIncludeArtifactCommitment": true,
          "reason": "Worker may submit proofHash/resultData only after sandbox work and a won claim.",
          "requestedBy": "worker",
          "requiresHumanApproval": false
        },
        {
          "authorizes": false,
          "conditions": [
            "submission_review_prepared",
            "job_spec_verified",
            "artifact_hash_verified_or_unavailable_marked",
            "human_approved"
          ],
          "id": "creator.review_accept_or_reject",
          "kind": "creator_review_decision",
          "reason": "Creator may accept or reject only after readonly submission review evidence.",
          "requestedBy": "creator",
          "requiresHumanApproval": true
        }
      ]
    }
  }
}
