Digital Marketing Audience Segmentation
Domain: business_finance — Sales & Marketing

Summary: Segment customer profiles into a high-transaction email-disengaged cohort for re-engagement via SMS and push, applying governance rules and overlap analysis.

Task prompt:
You are a digital marketing analyst performing audience segmentation for a re-engagement campaign.

## Task Directory
`base`

## Your Task
1. Read the segmentation brief at `base/input/segmentation_brief.md` and the governance policies at `base/input/governance_policies.yaml`. Use `base/input/data_dictionary.tsv` for field reference.
2. Load customer profiles from `base/input/unified_profiles.parquet`.
3. Identify customers matching the target criteria in the brief (high-transaction but email-disengaged).
4. Apply governance rules: suppress customers with active support tickets, respect channel opt-in/opt-out, compute per-customer SMS and push eligibility.
5. Strip geo/demographic identifier columns (age, gender, city, state) from the output roster for PII compliance.
6. Analyze overlap between the qualifying audience and each existing audience in `base/input/existing_audiences.csv`.
7. Produce three output files.

## Output Files
Save all files to `base/output/`:

**`segment_definition.json`** — JSON object with keys:
- `segment_name`: descriptive name
- `created_date`: date string
- `version`: version string
- `filter_predicates`: list of {field, operator, value}
- `suppression_rules`: list of {field, operator, value, reason}
- `activation_channels`: mapping of channel name → {eligibility_field, required_value}
- `governance_applied`: {pii_fields_removed: [...], opt_out_compliance: bool, support_suppression: bool}
- `audience_stats`: {total_qualifying, sms_eligible, push_eligible, any_channel_eligible, pct_of_total_profiles}

**`audience_roster.csv`** — CSV, one row per qualifying customer after suppression. Include customer_id and profile/engagement columns, but exclude age, gender, city, state. Add columns: `sms_eligible`, `push_eligible`, `any_channel_eligible` (1 or 0).

**`overlap_report.tsv`** — TSV with columns: existing_audience_id, existing_audience_name, overlap_count, overlap_pct, flag_high_overlap. One row per existing audience. overlap_pct = (overlap_count / total qualifying audience size) * 100.

## Environment
Python 3.12 and `uv` are available on this machine. A dependency manifest is at `base/input/runtime_env/pyproject.toml`. Install with: `cd base/input/runtime_env && uv sync`
Then run scripts with: `uv run --project base/input/runtime_env python your_script.py`


The agent must:
Filter unified_profiles.parquet to high-transaction email-disengaged customers per the brief.
Apply governance suppression (active support tickets) and channel opt-in/out rules.
Strip geo/demographic PII columns (age, gender, city, state) from the output roster.
Compute per-customer SMS, push, and any-channel eligibility.
Produce overlap_report.tsv with overlap_pct = overlap_count / qualifying audience size * 100.
Save segment_definition.json, audience_roster.csv, and overlap_report.tsv to output/.

Software: Python
pandas
pyarrow

Input files:
name: unified_profiles.parquet
format: Parquet
description: ~10,000 customer profiles with demographics, purchase, and engagement fields.
name: segmentation_brief.md
format: Markdown
description: Target audience definition and activation channels.
name: governance_policies.yaml
format: YAML
description: PII restrictions, opt-out compliance, minimum audience size, suppression rules.
name: existing_audiences.csv
format: CSV
description: Six existing audience definitions for overlap analysis.
name: data_dictionary.tsv
format: TSV
description: Field names, types, and permitted values for the profile data.