# Penny Engine: JSON Checks & Catalog CSV Audit (`pennyengine/penny-engine-structured-work`) Actor

Check up to 20 JSON results against your rules, or audit up to 50 catalog rows for missing fields, duplicate SKUs and margin arithmetic. Get JSON and Markdown issue reports. $0.05 per completed job. Checks supplied data; does not fetch data or verify facts.

- **URL**: https://apify.com/pennyengine/penny-engine-structured-work.md
- **Developed by:** [kasheik mcgee](https://apify.com/pennyengine) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$50.00 / 1,000 completed work orders

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Penny Engine · Agent QA and Catalog Quality Reports

**Buy a completed, deterministic digital work order.** This Apify Actor is designed to give agents and automation operators a machine-readable JSON quality report plus a Markdown summary, without a separate x402 wallet or manual invoice. Apify handles the billing when you configure the Actor's **pay-per-event** price.

### Supported jobs

1. `agent-output-batch-qa` — check 1–20 results from an agent workflow against user-supplied assertions: required paths, nonempty paths, expected values, and numeric ranges. Each item returns PASS/FAIL, failed paths, and an input-content SHA-256 fingerprint.
2. `catalog-csv-audit` — audit 1–50 catalog products provided as CSV text (`sku`, `name`, optional `price`, `cost`, `shippingCost`, and `feePct`). Return duplicate SKU flags, missing required fields, and estimated contribution and margins. These are arithmetic estimates, not validated market prices.

The dataset receives exactly **one output record per successful work order**, containing `deliverables.reportJson`, `deliverables.reportMarkdown`, and `evidence.sha256`.

#### Example 1 — agent result QA

```json
{
  "jobType": "agent-output-batch-qa",
  "payload": {
    "jobs": [
      {"id": "step_1", "result": {"status": "done", "records": 5}, "expectations": {"equals": {"status": "done"}, "numberRanges": {"records": {"min": 1}}}}
    ]
  }
}
```

#### Example 2 — catalog quality

```json
{
  "jobType": "catalog-csv-audit",
  "payload": {"csv": "sku,name,price,cost,shippingCost,feePct\nA1,Widget,24,10,3,10\nA2,Other,19,12,2,8", "targetMarginPct": 25}
}
```

### Pricing, refunds and limits

This Actor uses `Actor.pushData(result, "work-order-completed")` to **save the result and bill the one named event together** after successful computation. **You must configure the price for that event in Apify Console**, e.g. an introductory **$0.05 per completed work order**, and test its paid-tier budget behavior. No completed event is charged if input validation fails. The SDK enforces the run budget; a charge result with `chargedCount` other than one is rejected. Users on Apify free plans do not generate developer revenue under the current platform model. Apify's documented profit formula is `0.8 × event revenue − platform costs`; payouts are subject to Apify's rules and schedule. The suggested price is not configured by this source package. As of v0.2.1, payout onboarding and PPE pricing remain pending; no buyer revenue has been independently verified.

No network calls, scraping, external agent execution, account operations or spending are performed. Input data are provided by the caller. Integrity hashes are not independent proof that a third party completed real-world work. Do not send secrets or personally identifiable information in inputs.

### Recurring workflow integration

The buyer sends **fresh input on each occurrence** through its automation or API client; setting up a timer with unchanged sample input would generate redundant work and charges. Repeat scheduling and publication have **not** been configured. Each result includes a deterministic `workOrder.id` for customer-side reconciliation, not automatic billing deduplication.

### Publish to the existing market

1. The private Penny Engine Actor is already created in the owner’s Apify account. The code currently builds in Apify; publication is not complete.
2. Update the configured ZIP source URL if deploying a new version; keep the Actor private until Store and payment verification is complete.
3. Run both sample inputs before publication. The agent-QA workflow passed its first cloud test; the catalog smoke test remains to be verified.
4. In **Publishing → Monetization**, choose **pay per event** and configure `work-order-completed` (start with a small, economically viable price after testing costs).
5. Complete Apify Store's publishing checklist. Publication and payout verification are separate steps.

Local core tests use Node's built-in test runner and do not require an Apify account or any payment. To run the Apify-specific main process locally, install the Apify package (`npm install`) and follow Apify's Actor local-run instructions.

Penny Engine retains its existing Railway MCP gateway and x402 API service. This standalone Actor **does not call or charge the existing paid Railway endpoint**, preventing double-billing.

### Example output and machine schema

Apify uses `.actor/output_schema.json` and `.actor/dataset_schema.json` to expose the default dataset to API clients and render the result with documented field meanings. Each work order returns a `jobType`, completion `status`, JSON and Markdown `deliverables`, content-integrity `evidence`, and stable `workOrder` metadata. A successful Actor run does **not** necessarily mean all individual checks passed; read the detailed `reportJson`.

# Actor input Schema

## `jobType` (type: `string`):

Agent output QA or ecommerce catalog quality checks.

## `payload` (type: `object`):

For agent QA: {jobs:\[{id,result,expectations}]}. For catalog: {csv:"sku,name,price,cost\nA1,Widget,20,8",targetMarginPct:25}.

## Actor input object example

```json
{
  "jobType": "agent-output-batch-qa",
  "payload": {
    "jobs": [
      {
        "id": "step_1",
        "result": {
          "status": "done",
          "records": 5
        },
        "expectations": {
          "equals": {
            "status": "done"
          },
          "numberRanges": {
            "records": {
              "min": 1
            }
          }
        }
      }
    ]
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "payload": {
        "jobs": [
            {
                "id": "step_1",
                "result": {
                    "status": "done",
                    "records": 5
                },
                "expectations": {
                    "equals": {
                        "status": "done"
                    },
                    "numberRanges": {
                        "records": {
                            "min": 1
                        }
                    }
                }
            }
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("pennyengine/penny-engine-structured-work").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "payload": { "jobs": [{
                "id": "step_1",
                "result": {
                    "status": "done",
                    "records": 5,
                },
                "expectations": {
                    "equals": { "status": "done" },
                    "numberRanges": { "records": { "min": 1 } },
                },
            }] } }

# Run the Actor and wait for it to finish
run = client.actor("pennyengine/penny-engine-structured-work").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "payload": {
    "jobs": [
      {
        "id": "step_1",
        "result": {
          "status": "done",
          "records": 5
        },
        "expectations": {
          "equals": {
            "status": "done"
          },
          "numberRanges": {
            "records": {
              "min": 1
            }
          }
        }
      }
    ]
  }
}' |
apify call pennyengine/penny-engine-structured-work --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,pennyengine/penny-engine-structured-work"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/G6WYSlblyORiEAddi/builds/edKmUqrtYhoYU2USe/openapi.json
