Metadata-Version: 2.4
Name: afterai-runner
Version: 0.1.0
Summary: AfterAI Runner — AIS signal emission and agent evaluation on customer infrastructure
Author-email: AfterAI <support@useafter.ai>
License: MIT
Keywords: afterai,ais,runner,eval,signals,evaluation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: pydantic>=2.0.0
Requires-Dist: requests>=2.28.0
Requires-Dist: afterai>=0.1.0
Requires-Dist: pyyaml>=6.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"

# AfterAI Runner v0

Runner v0 collects **pre-aggregated** D1–W5 metrics from customer-controlled artifact files and emits AIS payloads to the AfterAI API. It does not manage baselines, evaluate thresholds, or trigger ACE.

- **Manifest-driven**: you provide a JSON or YAML manifest listing `system` + local artifact paths.
- **Artifact contract**: each artifact file is one signal (required: `signal_key`, `cadence`, `window`, `metrics`).
- **Stateless**: no local state; duplicate sends are allowed. Always sends `external_id`.
- **Local filesystem only (v0)**: artifact paths must be local; no S3, GCS, or HTTPS.

## Install

```bash
pip install afterai-runner
```

Or from source:

```bash
cd afterai-runner && pip install -e .
```

## Config

| Env | Required | Default |
|-----|----------|---------|
| `AFTERAI_API_KEY` | Yes | — |
| `AFTERAI_BASE_URL` | No | `https://api.useafter.ai` |

## Usage

```bash
# Run ingestion from a manifest
afterai-runner run --manifest manifest.yaml

# Print payloads without sending
afterai-runner run --manifest manifest.yaml --dry-run

# Optional: ACE-from-AIS rule (out-of-band). Reads GET /signals/debug, applies threshold, POSTs inferred ACE.
afterai-runner ace-from-ais --min-signals 2 --hours 24
afterai-runner ace-from-ais --min-signals 2 --severity high,critical --dry-run
```

## Manifest example

**manifest.yaml** (or `.json`):

```yaml
version: "2026-02"
artifacts:
  - system: my-system-01
    path: /path/to/D1-2026-02-03.json
  - system: my-system-01
    path: /path/to/W1-2026-W05.json
```

`path` must be a **local filesystem path** (no remote URIs in v0).

## Artifact example

One file = one signal. **D1-2026-02-03.json**:

```json
{
  "signal_key": "D1",
  "cadence": "daily",
  "window": {
    "start": "2026-02-03T00:00:00Z",
    "end": "2026-02-03T23:59:59Z"
  },
  "metrics": {
    "score_mean": 0.87,
    "fail_rate": 0.03
  }
}
```

Optional passthrough: `severity`, `confidence`, `tags`, `source`, `evidence_refs`, `baseline_ref`, `created_at`.  
Runner adds: `system`, `external_id`, `type: "ais"`, and `created_at` if missing; defaults `severity="low"`, `confidence=0.8` if missing.

## external_id format

- **Daily**: `{system}:{signal_key}:{YYYY-MM-DD}`
- **Weekly**: `{system}:{signal_key}:{YYYY-Www}` (ISO week from `window.end`)

## Docs

- [Quickstart](docs/quickstart.md)
- [Deployment recipes](docs/deployment-recipes.md) (cron, GitHub Actions, K8s CronJob)

## License

MIT
