# CPSC Certificate Gap Checker (CPC/GCC pre-check) (`jadelike_zine/cpsc-certificate-gap-checker`) Actor

Batch US import-compliance pre-check: classifies 1-100 product listings as children's/general-use, maps them to the official CPSC certification rule lists, and reports which certificate (CPC or GCC), tests and labels each SKU is missing — citations backed by a rule matrix, never invented.

- **URL**: https://apify.com/jadelike\_zine/cpsc-certificate-gap-checker.md
- **Developed by:** [Derrick](https://apify.com/jadelike_zine) (community)
- **Categories:** E-commerce, Automation, Agents
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$100.00 / 1,000 sku certificate-gap checkeds

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## CPSC Certificate Gap Checker (CPC/GCC pre-check)

Batch US import-compliance pre-check for e-commerce sellers. Feed it 1–100 product records; for each SKU it answers:

- Is this a **children's product** (CPSA: designed or intended primarily for ages 12 or younger) or a general-use product?
- Which certificate does US law require at import — a **Children's Product Certificate (CPC)** or a **General Certificate of Conformity (GCC)**?
- Which **specific CPSC rules** (16 CFR parts / statutes) apply, and is **third-party testing at a CPSC-accepted lab** required?
- What is missing before the shipment clears — as an actionable **gap checklist** (certificate, testing, tracking label, eFiling).

Why now: **since July 8, 2026, importers of most regulated consumer products must eFile certificates of compliance with CBP** via the PGA Message Set (Federal Register 2024-30826). No certificate data = detention risk at the border.

### Input

```json
{
  "products": [
    {
      "id": "SKU-001",
      "title": "Rainbow Stacking Rings Toy for Babies 6-18 Months",
      "description": "Colorful plastic stacking rings with painted wooden base.",
      "materials": "ABS plastic, painted beech wood"
    }
  ],
  "fetch_urls": true
}
````

`title` is required; everything else is optional but more text = better classification. `url` is fetched **best-effort only** (direct → datacenter proxy → Jina Reader) when `description` is missing or short; a failed fetch never blocks the check.

**From a catalog CSV**: export your product list, keep the columns you have (title/description/category/age\_range/materials/url/id), and convert the rows to this JSON array — one object per SKU, up to 100 per run. Each text field is capped at 4000 chars.

Every run also appends a final **batch summary** row (`record_type: "summary"`) with counts: how many SKUs need CPC vs GCC vs none, how many were billable, and how many need human review — so you can triage 100 SKUs at a glance without reading each record.

### Output (per SKU)

```json
{
  "record_type": "sku",
  "ok": true,
  "id": "SKU-001",
  "classification": "childrens",
  "certificate_required": "CPC",
  "evidence_hit_ratio": 1,
  "applicable_rules": [
    {
      "rule_id": "16cfr1250",
      "cfr_cite": "16 CFR part 1250",
      "title": "Children's toys",
      "test_standard": "ASTM F963",
      "third_party_lab_required": true,
      "reason": "category:toys",
      "evidence_quote": "Stacking Rings Toy"
    }
  ],
  "gap_checklist": [
    "Children's Product Certificate (CPC) required before import/distribution, citing: 16 CFR part 1250; ...",
    "Third-party testing by a CPSC-accepted laboratory required for each cited rule (find labs: cpsc.gov/labsearch)",
    "Permanent tracking label required on product and packaging (CPSA section 14(a)(5))",
    "From July 8, 2026: importers must eFile certificate data with CBP via the PGA Message Set (cpsc.gov/eFiling)"
  ],
  "confidence": "high",
  "warnings": [],
  "disclaimer": "Automated pre-check ... NOT legal advice ..."
}
```

### How it works (and why you can trust the citations)

1. **LLM classification only** — the model maps your listing text to a fixed category catalog and attribute flags (painted surface, soft plastic, button battery, under-3 age grading). It is *forbidden* from writing regulation numbers.
2. **Deterministic rule matrix** — every citation comes from `rules/cpsc-matrix.json`, hand-transcribed from the two official CPSC certification lists (children's rules list, complete as of 2024-12-05, canonical at 16 CFR 1112.15; GCC rules list, current as of 2024-08-08). The LLM cannot invent a rule.
3. **Mechanical validation** — every category/flag must exist in the matrix, and every `evidence_quote` must be a verbatim substring of your input text. Anything that fails verification is dropped and logged in `warnings`, never silently kept.

### Honest billing

Pay per event `sku-gap-checked`. **You are not charged** whenever `confidence: "low"`, which we deliberately trigger in every case where the answer isn't trustworthy:

- age classification is **ambiguous** (sparse/garbage listing text — the exact case where a wrong "none" would be most dangerous);
- **conflicting signals** (e.g. a listing calls itself "adult" but matches a children-only category) — downgraded to review, never billed as a confident "none";
- the model proposed matches but **all evidence failed verification**, or the applicable rules were entirely gated out.

The design bias is: **when in doubt, mark it low and don't charge.** A confident "no certificate needed" is only ever billed when there was real, verified signal behind it. The batch summary reports `billable` separately from `total` so you can see exactly what you paid for.

### vs. CPSC's free Regulatory Robot

CPSC's official [Regulatory Robot](https://www.cpsc.gov/Business--Manufacturing/Regulatory-Robot/Safer-Products-Start-Here) is a great interactive questionnaire — but it is designed for **one product at a time** ("you'll need to run the Robot one time for each product"), answered manually. This Actor does the batch/API version of the same triage: 100 SKUs from your catalog CSV in one run, judged from listing text, with machine-checkable citations. For any single ambiguous product we *recommend* the Robot as a second opinion — the checklist even links to it.

This is also **not** a recall monitor (there are plenty of those on Apify) — it is a pre-import certificate gap check.

### Limits (read this)

- Pre-check tool, **NOT legal advice** and not a compliance determination. Testing labs and compliance professionals make the final call.
- Covers **CPSC certification rules only** — FDA, FCC, EPA, USDA, state rules (e.g. CA Prop 65) are out of scope.
- The rule matrix is a snapshot of CPSC's two official certification lists (children's rules complete as of **2024-12-05**; GCC rules current as of **2024-08-08** — roughly 18 months old at time of writing). The canonical live list is [16 CFR 1112.15](https://www.ecfr.gov/current/title-16/chapter-II/subchapter-B/part-1112/subpart-B/section-1112.15); matrix version, `retrieved` date, and source URLs ship in `rules/cpsc-matrix.json`. We re-sync against the CFR periodically — check the matrix `version` before relying on it for a newly regulated category.
- **`test_standard` is populated only where CPSC names a specific standard on the rule page** (toys → ASTM F963, sleepwear → FF 3-71/FF 5-74). For every other rule it is `null` — that means "consult the cited CFR part for the test method", not "no testing required".
- Classification is **text-only**. It reads your listing fields (and, best-effort, the page). It does not see product photos, and a determined seller who mislabels a children's product as "adult, not a toy" can fool the age call — in that case the tool degrades to an **unbilled** `none`/`ambiguous` rather than a confident wrong answer, but it is not a substitute for honest product data. `evidence_quote` proves a quote exists in your text; it does not prove the quote is semantically airtight.
- Each output record carries `evidence_hit_ratio` (share of the model's proposed evidence that survived verbatim verification) — use it to decide which SKUs deserve a manual second look.

### Development

```bash
pnpm install
pnpm typecheck   # tsc --noEmit, zero errors is the bar
pnpm test        # vitest: matrix invariants, validate layer, match layer
pnpm smoke       # offline end-to-end (no network, no LLM)
pnpm golden      # real-LLM acceptance vs hand-labeled expectations (needs DEEPSEEK_API_KEY)
```

Secrets live outside the repo in `~/.secrets/cpsc-cert-gap.env` (falls back to `~/.secrets/tender-extractor.env`). Never commit `.env`.

Architecture (single-direction deps): `main → fetch/extract/match/validate → rules → domain`. The LLM provider chain (DeepSeek default / Anthropic / claude-code subscription loop) is inherited from tender-extractor, including the prefix-cache prompt constraints documented in `src/extract/prompts.ts`.

# Actor input Schema

## `products` (type: `array`):

1-100 product records. Each record: {title (required), description, category, age\_range, materials, url, id}. More text = better classification. url is fetched best-effort only when description is missing/short. Tip: export your catalog CSV, then map columns to these keys. Per-field text is capped at 4000 chars.

## `fetch_urls` (type: `boolean`):

When a record has url but little/no description, try fetching the page text (direct -> proxy -> Jina Reader). Failures never block classification.

## Actor input object example

```json
{
  "products": [
    {
      "id": "SKU-001",
      "title": "Rainbow Stacking Rings Toy for Babies 6-18 Months",
      "description": "Colorful plastic stacking rings, painted wooden base, helps develop fine motor skills for infants and toddlers.",
      "materials": "ABS plastic, painted beech wood"
    },
    {
      "id": "SKU-002",
      "title": "LED Flameless Candle with Remote, CR2032 battery included",
      "description": "Warm white flickering LED pillar candle for home decor. Remote control uses one CR2032 coin battery."
    }
  ],
  "fetch_urls": true
}
```

# 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 = {
    "products": [
        {
            "id": "SKU-001",
            "title": "Rainbow Stacking Rings Toy for Babies 6-18 Months",
            "description": "Colorful plastic stacking rings, painted wooden base, helps develop fine motor skills for infants and toddlers.",
            "materials": "ABS plastic, painted beech wood"
        },
        {
            "id": "SKU-002",
            "title": "LED Flameless Candle with Remote, CR2032 battery included",
            "description": "Warm white flickering LED pillar candle for home decor. Remote control uses one CR2032 coin battery."
        }
    ],
    "fetch_urls": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("jadelike_zine/cpsc-certificate-gap-checker").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 = {
    "products": [
        {
            "id": "SKU-001",
            "title": "Rainbow Stacking Rings Toy for Babies 6-18 Months",
            "description": "Colorful plastic stacking rings, painted wooden base, helps develop fine motor skills for infants and toddlers.",
            "materials": "ABS plastic, painted beech wood",
        },
        {
            "id": "SKU-002",
            "title": "LED Flameless Candle with Remote, CR2032 battery included",
            "description": "Warm white flickering LED pillar candle for home decor. Remote control uses one CR2032 coin battery.",
        },
    ],
    "fetch_urls": True,
}

# Run the Actor and wait for it to finish
run = client.actor("jadelike_zine/cpsc-certificate-gap-checker").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "products": [
    {
      "id": "SKU-001",
      "title": "Rainbow Stacking Rings Toy for Babies 6-18 Months",
      "description": "Colorful plastic stacking rings, painted wooden base, helps develop fine motor skills for infants and toddlers.",
      "materials": "ABS plastic, painted beech wood"
    },
    {
      "id": "SKU-002",
      "title": "LED Flameless Candle with Remote, CR2032 battery included",
      "description": "Warm white flickering LED pillar candle for home decor. Remote control uses one CR2032 coin battery."
    }
  ],
  "fetch_urls": true
}' |
apify call jadelike_zine/cpsc-certificate-gap-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=jadelike_zine/cpsc-certificate-gap-checker",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "CPSC Certificate Gap Checker (CPC/GCC pre-check)",
        "description": "Batch US import-compliance pre-check: classifies 1-100 product listings as children's/general-use, maps them to the official CPSC certification rule lists, and reports which certificate (CPC or GCC), tests and labels each SKU is missing — citations backed by a rule matrix, never invented.",
        "version": "0.1",
        "x-build-id": "7T4Fy9mibAdZ1ppW0"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/jadelike_zine~cpsc-certificate-gap-checker/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-jadelike_zine-cpsc-certificate-gap-checker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/jadelike_zine~cpsc-certificate-gap-checker/runs": {
            "post": {
                "operationId": "runs-sync-jadelike_zine-cpsc-certificate-gap-checker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/jadelike_zine~cpsc-certificate-gap-checker/run-sync": {
            "post": {
                "operationId": "run-sync-jadelike_zine-cpsc-certificate-gap-checker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "products"
                ],
                "properties": {
                    "products": {
                        "title": "Product records",
                        "minItems": 1,
                        "maxItems": 100,
                        "type": "array",
                        "description": "1-100 product records. Each record: {title (required), description, category, age_range, materials, url, id}. More text = better classification. url is fetched best-effort only when description is missing/short. Tip: export your catalog CSV, then map columns to these keys. Per-field text is capped at 4000 chars."
                    },
                    "fetch_urls": {
                        "title": "Fetch product URLs (best effort)",
                        "type": "boolean",
                        "description": "When a record has url but little/no description, try fetching the page text (direct -> proxy -> Jina Reader). Failures never block classification.",
                        "default": true
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
