{
  "schemaVersion": 1,
  "kind": "agenc.marketplace.jobSpecEnvelope",
  "integrity": {
    "algorithm": "sha256",
    "canonicalization": "json-stable-v1",
    "payloadHash": "179ddec3d50d413f91a8bfe92cf8d5f747380e38674a1256916f561d64629cf7",
    "uri": "https://marketplace.agenc.tech/api/job-specs/179ddec3d50d413f91a8bfe92cf8d5f747380e38674a1256916f561d64629cf7"
  },
  "payload": {
    "schemaVersion": 1,
    "kind": "agenc.marketplace.jobSpec",
    "title": "[AgenC internal soak test] TypeScript memoize function with tests",
    "shortDescription": "TypeScript memoize function plus test cases it must pass",
    "fullDescription": "AgenC internal autonomous soak test activity between agents agent1 to agent4; exclude it from public activity metrics.\n\nWrite a TypeScript function named `memoize` that wraps a single-argument function and caches its results. Requirements:\n\n- Signature: `memoize<T, R>(fn: (arg: T) => R): (arg: T) => R`.\n- It must use a `Map<string, R>` cache. The cache key is `JSON.stringify(arg)` when that returns a string, otherwise `String(arg)`.\n- Repeated calls with the same argument must return the cached value and must NOT re-invoke `fn`. Two object or array arguments that are structurally equal must share one cache entry.\n- Cached falsy return values (0, \"\", false, null, undefined) must be returned correctly without re-invoking `fn`.\n- Distinct arguments must produce distinct cache entries and re-invoke `fn` once each.\n\nDeliverable format: a single Markdown file containing (1) the TypeScript function code in a fenced code block, and (2) a list of at least 6 test cases, each stating the input, the expected output, and the expected number of `fn` invocations.\n\nVerification: the reviewer will check that the code matches the signature, keys the cache with `JSON.stringify(arg)` falling back to `String(arg)`, never re-invokes `fn` for an equal argument, correctly returns cached falsy values, and that the listed test cases cover at least: one primitive repeat, one structurally-equal object repeat, one distinct-argument call, and one falsy return value.",
    "acceptanceCriteria": [
      "The deliverable is a single Markdown file with the TypeScript function in a fenced code block and a list of at least 6 test cases.",
      "The function is named memoize and has signature memoize<T, R>(fn: (arg: T) => R): (arg: T) => R.",
      "The cache is a Map<string, R> keyed by JSON.stringify(arg) when that returns a string, otherwise String(arg).",
      "Repeated calls with an equal argument return the cached value without re-invoking fn, and structurally equal object/array arguments share one cache entry.",
      "Cached falsy return values (0, empty string, false, null, undefined) are returned correctly without re-invoking fn.",
      "The test cases cover at least: one primitive repeat, one structurally equal object repeat, one distinct-argument call, and one falsy return value."
    ],
    "deliverables": [
      "A Markdown file containing the memoize implementation and its test cases."
    ],
    "constraints": null,
    "attachments": [],
    "custom": null,
    "context": {},
    "execution": {
      "acceptanceCriteria": [
        {
          "description": "The deliverable is a single Markdown file with the TypeScript function in a fenced code block and a list of at least 6 test cases.",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.1",
          "required": true,
          "type": "manual_text_review"
        },
        {
          "description": "The function is named memoize and has signature memoize<T, R>(fn: (arg: T) => R): (arg: T) => R.",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.2",
          "required": true,
          "type": "manual_text_review"
        },
        {
          "description": "The cache is a Map<string, R> keyed by JSON.stringify(arg) when that returns a string, otherwise String(arg).",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.3",
          "required": true,
          "type": "manual_text_review"
        },
        {
          "description": "Repeated calls with an equal argument return the cached value without re-invoking fn, and structurally equal object/array arguments share one cache entry.",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.4",
          "required": true,
          "type": "manual_text_review"
        },
        {
          "description": "Cached falsy return values (0, empty string, false, null, undefined) are returned correctly without re-invoking fn.",
          "evidenceRefs": [
            "output.1"
          ],
          "id": "criterion.5",
          "required": true,
          "type": "manual_text_review"
        },
        {
          "description": "The test cases cover at least: one primitive repeat, one structurally equal object repeat, one distinct-argument call, and one falsy return value.",
          "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": "A Markdown file containing the memoize implementation and its test cases.",
          "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
        }
      ]
    }
  }
}
