Files
canina/scripts/orchestration/MARKET_PROPOSALS.md
T

9 lines
2.5 KiB
Markdown

# Market opportunity proposal gate (inactive)
Hermes cron `482f37952b74` (`canina-market-opportunity-scout`) currently produces reports in `/opt/data/cron/output/482f37952b74/`; its schedule is enabled. Cron `e95025c84a31` (`canina-opportunity-decomposer-daemon`) is **paused**, with `script: market_opportunity_decomposer.py`, resolved to the untracked Hermes script `/opt/data/scripts/market_opportunity_decomposer.py`. Neither cron definition nor that script is part of this repository. The latter directly inserts model-generated `approval_requests`, uses title-only deduplication, and increments its success count even when `ON CONFLICT DO NOTHING` returns no row. Do not re-enable it.
`market_proposals.py` is a versioned, **unwired** validation/insertion gate. It accepts only paired digital route identifiers, and deliberately ignores model-supplied title, prose, pricing, clinical claims, and payload. Evidence URL and verbatim quote must coexist in a scout report paragraph; this is a syntactic provenance check, **not** independent verification that the URL is genuine or medically correct. The resulting review-only payload links the source and report; no automatic approval, task execution, or publication exists. A transaction-scoped PostgreSQL advisory lock serializes proposals by source URL + exact quote + action fingerprint and the SQL counts only returned UUIDs. The application-level deduplication assumes every writer uses this gate. Consider a schema-level partial unique index on `(payload->>'sourceFingerprint')` after examining existing rows before production rollout; coordinate schema changes with backend ownership.
Before activation, migrate the Hermes entry point into this repository under `scripts/orchestration/`, add an explicit offline parser for actual scout output format and bounded model schema, and have the scheduler invoke the **versioned** script by pinned revision/absolute path after review. Replace its direct SQL write path with this gate; inspect sample scout outputs and test malformed, mismatched, stale, and false-source citations. Add a dry-run mode and staging integration tests with a disposable database, review permissions and audit logging, and require human clinical/pricing review. Do not infer clinical or price facts from model prose. Keep `e95025c84a31` paused until rollout approval; do not change the active scout job as part of this patch.
Tests: `cd scripts/orchestration && python3 -m unittest discover -p 'test_*.py' -v` (no DB access).