# California Prop 65 Notice Watchlist Processor (`mehdi_badawi/proposition-65-watchlist`) Actor

Normalize and compare California Prop 65 notice snapshots, then flag new or changed records that match your watchlist. Preserves source links and uncertainty; informational only.

- **URL**: https://apify.com/mehdi\_badawi/proposition-65-watchlist.md
- **Developed by:** [Mehdi Badawi](https://apify.com/mehdi_badawi) (community)
- **Categories:** News, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.05 / processed notice snapshot

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

## California Prop 65 Notice Watchlist Processor

Normalize and compare California Proposition 65 notice snapshots, then flag
new or changed records that match companies, chemicals, or product categories
on your watchlist. Every result preserves source links and uncertainty.

### Start in 30 seconds

1. Select **Try for free** and run with no input for a labeled demo.
2. Supply a notice snapshot, source attestation, and optional watchlist.
3. Reuse the persisted baseline to detect changes on later runs.

**Price:** $0.05 per successfully processed snapshot, plus a $0.00005 start
event, regardless of notice or match count. Failed-source and demo runs are
free.

This Actor does not collect the live register or prove complete enforcement
coverage. It is an informational research aid, not legal or compliance advice.

### Overview

The California Office of the Attorney General (OAG) maintains the public register of Proposition 65 60-day notices of violation. Businesses and compliance teams often lack automated alerts and face costly private-enforcer settlement demands.

This Actor provides:

- **Deterministic snapshot ingestion**: Ingests public notice records with stable notice identity (`noticeNumber` or reproducible hash).
- **Normalized entity and substance classification**: Canonicalizes alleged violators, complainants, listed chemicals, and product categories.
- **Snapshot diff engine**: Computes diffs between successive snapshot states (`new`, `changed`, `unchanged`, `removed`, `unknown`).
- **Exact source provenance**: Attests register URLs, document URIs, fetch timestamps, snapshot SHA-256 digests, and ingestion mechanisms.
- **Explicit unknown and failed-source semantics**: If a register fetch fails, times out, or returns incomplete data, verdicts are explicitly marked `unknown` with failure reasons. They are **never** falsely presented as unchanged.
- **Watchlist filtering**: Matches specific companies, chemicals, or categories of interest for targeted alerts.
- **Pure offline / fixture operation**: Runs completely locally with `npm test` and `npm start` without network access or external credentials.

### Input Contract

Defined in `.actor/input_schema.json`:

- `snapshot`: Array of current notice objects (e.g. `noticeNumber`, `noticeDate`, `allegedViolators`, `chemicals`, `category`, `productDetails`, `sourceUrl`, `documentUri`).
- `priorSnapshot`: Optional prior snapshot array or state object to diff against. If omitted and state persistence is enabled, the previous run's snapshot is restored from the state store.
- `watchlist`: Optional matching rules:
  - `companies`: e.g. `["Acme Nutrition", "Apex Imports"]`
  - `chemicals`: e.g. `["Lead", "Bisphenol A (BPA)", "Cadmium"]`
  - `categories`: e.g. `["Dietary Supplements", "Food & Beverage", "Home & Kitchen"]`
- `source`: Source fetch attestation:
  - `status`: `"ok" | "failed" | "rate_limited" | "timeout" | "unavailable" | "malformed" | "unauthorized"`
  - `registerUrl`: e.g. `"https://oag.ca.gov/prop65"`
  - `fetchedAt`: ISO-8601 instant
  - `mechanism`: `"public-register" | "fixture" | "manual"`
  - `completeCoverage`: boolean
- `stateStoreName`: Name of key-value store for cross-run snapshot persistence (default: `"prop65-watchlist-state"`). Set to `null` to disable persistence.
- `emitOnlyWatchlistMatches`: When true, only notices matching watchlist criteria are pushed to the dataset.
- `emitUnchanged`: When true, unchanged notices are also emitted.

### Output Contract

Defined in `.actor/output_schema.json`, `.actor/dataset_schema.json`, and `.actor/key_value_store_schema.json`:

1. **Default Dataset (`rows[]`)**: Each notice item includes:
   - `noticeId`: Canonical stable notice identifier.
   - `noticeNumber`: Register notice number.
   - `noticeDate`: Date notice was filed.
   - `status`: Change verdict (`"new" | "changed" | "unchanged" | "removed" | "unknown"`).
   - `isNew`: Boolean flag.
   - `isChanged`: Boolean flag.
   - `changedFields`: Array of modified fields with before/after values if changed.
   - `companies`: `{ allegedViolators: string[], noticingParties: string[] }`.
   - `chemicals`: Array of canonicalized chemical names.
   - `category`: Standardized category name.
   - `productDetails`: Product description.
   - `watchlist`: `{ matched: boolean, matchedCriteria: string[] }`.
   - `reasons`: Deterministic audit reasons.
   - `provenance`: `{ sourceUrl, registerUrl, documentUri, fetchedAt, snapshotHash, mechanism }`.
   - `disclaimer`: Mandatory legal disclaimer text.

2. **Default Key-Value Store (`OUTPUT`)**:
   - `contractVersion`: `"1.0.0"`
   - `ruleVersion`: `"1.0.0"`
   - `runStatus`: `"ok" | "degraded" | "failed"`
   - `evaluatedAt`: Evaluation ISO-8601 instant.
   - `counts`: Total, new, changed, unchanged, removed, unknown, and watchlist match counts.
   - `source`: Validated source provenance and attestation.
   - `warnings`: Audit warnings.
   - `disclaimer`: Legal boundary text.

3. **Durable State (`STATE`)**:
   - Persisted snapshot map of normalized notices used as baseline for the next run.

### Diff and Failure Semantics

- **New notice**: Present in current snapshot, absent in prior snapshot.
- **Changed notice**: Present in both, but chemicals, alleged violators, category, or product details differ.
- **Unchanged notice**: Identical across current and prior snapshots.
- **Failed source**: If `source.status` is not `"ok"`, `runStatus` is `"failed"`, notices are emitted with `status: "unknown"` and reason `source-failed`. Under no circumstances is a failed source presented as "unchanged".

### Local Development & Testing

Run all unit and behavior tests using the built-in Node.js test runner (requires Node >= 18):

```bash
npm test
```

Execute a local run against the default fixture without network or credentials:

```bash
npm start
```

### Boundaries and Non-Goals

- **No Legal Advice**: Notice alerts are for operational tracking of public filings only.
- **No Compliance Claims**: The absence of a notice against a product or company does not certify statutory compliance, safe harbor status, or safety.
- **Zero Paid Input / Credential Dependencies**: Works entirely on public-register data and deterministic input snapshots.
- **Allegation is not adjudication**: A notice is a public filing, not proof of
  a violation or an automated legal conclusion.
- Partial snapshots retain unseen baseline notices as `unknown`; only an
  explicitly complete source can support `removed`.
- Use one writer per state store, export `STATE` before recovery, and delete
  datasets and the named store under your retention policy. Support owner:
  Mehdi Badawi through the Apify Store support channel, with an
  initial-response target of two business days.

# Actor input Schema

## `contractVersion` (type: `string`):

Must equal 1.0.0 when provided. The Actor stamps the current contract version when omitted.

## `evaluationTime` (type: `string`):

ISO-8601 instant treated as 'now' for comparisons (e.g. 2026-09-21T12:00:00Z).

## `snapshot` (type: `array`):

Array of notice records from the California AG register snapshot.

## `priorSnapshot` (type: `array`):

Optional prior notice records to diff against. If omitted or empty and state persistence is enabled, the prior state is loaded from the named state store. Set stateStoreName to null to force a run without persisted history.

## `watchlist` (type: `object`):

Watchlist rules specifying company names, chemical names, or product categories to monitor.

## `source` (type: `object`):

Attestation of source register status and provenance.

## `stateStoreName` (type: `string`):

Name of the Apify Key-Value Store used to persist prior notice snapshots across runs. Set to null to disable persistence.

## `emitOnlyWatchlistMatches` (type: `boolean`):

When true and watchlist criteria are provided, only notices matching the watchlist are pushed to the dataset. When false, all new/changed notices are pushed with matched tags.

## `emitUnchanged` (type: `boolean`):

When true, notices that have not changed since the prior snapshot are also emitted with status 'unchanged'.

## Actor input object example

```json
{
  "contractVersion": "1.0.0",
  "watchlist": {},
  "source": {
    "status": "ok",
    "registerUrl": "https://oag.ca.gov/prop65",
    "mechanism": "fixture",
    "completeCoverage": false
  },
  "stateStoreName": "prop65-watchlist-state",
  "emitOnlyWatchlistMatches": false,
  "emitUnchanged": false
}
```

# Actor output Schema

## `notices` (type: `string`):

Normalized Proposition 65 notice rows in the default dataset with stable identity, change status (new/changed/unchanged/unknown), matched watchlist tags, and exact provenance.

## `runOutput` (type: `string`):

Run-level evaluation metadata, counts, source attestation, warnings, and legal disclaimer.

## `state` (type: `string`):

Snapshot of normalized notice registry persisted for the next run's diff baseline.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("mehdi_badawi/proposition-65-watchlist").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("mehdi_badawi/proposition-65-watchlist").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 '{}' |
apify call mehdi_badawi/proposition-65-watchlist --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mehdi_badawi/proposition-65-watchlist"
        }
    }
}
```

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/8jR5P4Hx3AVI5oOAn/builds/vgR44fZTYpjjsDE9L/openapi.json
