#!/usr/bin/env python3 """ gen_implementer_synthetic.py Generates synthetic implementer training examples with explicit positive signals. Problem: gen_worker_type_data.py labels implementer by keyword ABSENCE (anything that isn't reviewer/architect/qa). This produces noisy boundaries — the model never sees strong positive implementer signal, so tasks like "Build review moderation" get misclassified as reviewer because "review" is in the text. Fix: generate examples where: 1. Explicit construction verbs are present (Implement, Build, Add, Write, etc.) 2. Ambiguous nouns appear as OBJECTS of construction, not as the action e.g., "Build audit log service" = implementer (building it), NOT reviewer (doing audit) Output: writes synthetic rows to data/generated/worker_type_implementer_synthetic.tsv and a new combined file worker_type_v2_{train,eval}.tsv that includes the existing combined data + synthetic implementer. Usage: python3 specialists/scripts/gen_implementer_synthetic.py (run from whetstone_DSL root) """ import random import sys from pathlib import Path ROOT = Path(__file__).parent.parent.parent OUT_DIR = ROOT / "specialists" / "data" / "generated" COMBINED_TRAIN = OUT_DIR / "worker_type_combined_train.tsv" COMBINED_EVAL = OUT_DIR / "worker_type_combined_eval.tsv" SYNTH_OUT = OUT_DIR / "worker_type_implementer_synthetic.tsv" V2_TRAIN = OUT_DIR / "worker_type_v2_train.tsv" V2_EVAL = OUT_DIR / "worker_type_v2_eval.tsv" IMPLEMENTER_LABEL = 0 # --------------------------------------------------------------------------- # Short title templates (sprint-plan style) # These are the critical ones — they teach the model that "Build X", "Add X", # "Implement X" = implementer even when X contains ambiguous words. # --------------------------------------------------------------------------- SHORT_TITLES = [ # Clear construction verbs — unambiguous "Implement authentication middleware", "Implement rate limiter with sliding window", "Implement JWT token refresh endpoint", "Implement password reset flow", "Implement webhook dispatcher with retry logic", "Implement idempotency keys for payment API", "Implement session store with expiry", "Implement background job worker", "Implement batch processing pipeline", "Implement file upload endpoint with validation", "Implement pagination for list endpoints", "Implement soft delete for user records", "Implement caching layer with TTL", "Implement event sourcing for order state", "Implement circuit breaker for external calls", "Add authentication to all protected routes", "Add request validation middleware", "Add retry logic to job processor", "Add structured logging to API handlers", "Add metrics collection to request pipeline", "Add database connection pooling", "Add rate limiting to public endpoints", "Add health check endpoint", "Add gzip compression to response middleware", "Add CORS policy to API gateway", "Build webhook dispatcher with backoff", "Build order state machine with transitions", "Build notification fanout service", "Build background task scheduler", "Build file processing pipeline", "Build token bucket rate limiter", "Build ledger reconciliation service", "Build event deduplication processor", "Build incremental snapshot service", "Build search index synchronization worker", "Write parser for incoming event payloads", "Write serialization layer for queue messages", "Write migration script for schema v3", "Write batch loader for warehouse ingestion", "Write retry wrapper for flaky external calls", "Write adapter for third-party payment provider", "Create database schema for subscription billing", "Create index for high-frequency query paths", "Create worker pool for parallel job execution", "Create shared serialization core for all services", "Extend billing API with proration support", "Extend user profile with privacy settings", "Extend search with fuzzy match and ranking", "Extend notification service with quiet hours", "Port request validator to use shared schema library", "Port legacy sync logic to new event bus", "Develop inventory reservation endpoint", "Code the ledger double-entry enforcement layer", "Wire up SMTP adapter to notification service", "Integrate carrier rate API into shipping worker", "Hook telemetry collector into request pipeline", "Expose GraphQL subscription for live updates", "Stand up gRPC service for internal messaging", "Scaffold CRUD endpoints for product catalog", "Generate typed client from OpenAPI spec", # Ambiguous-noun implementer — these are the hardest cases # "Build/Implement X" where X sounds like audit/review/check/scan work "Build audit log service", "Build audit trail persistence layer", "Implement audit event schema and writer", "Add audit log endpoint to admin API", "Write audit log retention policy enforcer", "Build review queue backend", "Build review moderation pipeline", "Implement review scoring engine", "Add review status transitions to moderation API", "Build code review comment threading API", "Implement peer review assignment logic", "Build inspection endpoint for object metadata", "Implement diagnostic data collection service", "Build diagnostic report export endpoint", "Write scan queue worker for document processing", "Implement scan result aggregation service", "Build check endpoint for idempotent replay safety", "Implement liveness check handler", "Implement readiness check with dependency probes", "Build validation pipeline for incoming records", "Implement validator chain for form submissions", "Add constraint validation to execution contract", "Write schema validation middleware", "Build compliance data export endpoint", "Implement compliance record writer", "Build analysis batch job for feature distributions", "Implement drift analysis worker", "Write data quality check runner", "Build quality scoring endpoint for artifacts", "Implement quality gate enforcer in build pipeline", "Build assessment result storage API", "Implement evaluation batch processor", "Build evaluation harness runner", "Implement triage queue persistence layer", "Build triage result export service", "Implement monitoring probe for SLO windows", "Build monitor agent for heartbeat tracking", # More construction verbs on mixed topics "Implement RBAC permission check middleware", "Build RBAC role assignment API", "Add permission enforcement to resource endpoints", "Write access policy evaluation engine", "Implement access control grant/revoke API", "Build fraud score persistence and query API", "Implement fraud detection rule evaluator", "Write rule engine for fraud signal aggregation", "Build PII redaction pipeline", "Implement PII scanner for log output", "Add PII masking to export endpoints", "Build secret rotation scheduler", "Implement credential refresh worker", "Write certificate expiry checker worker", "Build security event publisher", "Implement security policy enforcement layer", "Add encryption at rest for sensitive fields", "Implement key derivation service", "Build compliance report generator", "Write regulatory data export endpoint", "Implement GDPR deletion request handler", "Build consent management API", ] # --------------------------------------------------------------------------- # Title | intent templates (projects-pipeline style) # Format: "