Commit 113b764
feat: detect + agent-resolve merged-bill duplicate events (#257)
* refactor(clean-duplicates): extract EventMergeHelper for pairwise merge reuse
Pulls the trash+ticket-url forward-merge logic out of CleanDuplicatesCommand
into a single helper so the upcoming merged-bill resolver (issue #256) can
reuse the same primitive without copy-paste.
Behavior is unchanged: same trash semantics, same ticket-URL merge rule
(only fill when the winner has none and the loser has one).
* feat(merged-bills): detector ability + CLI for merged-bill candidate scanning
Adds the deterministic detection layer for issue #256: same venue +
same start_datetime + different title pairs scored on lineup overlap.
Detector logic (inc/Abilities/MergedBillDetectAbilities.php):
- SQL groups upcoming published events by (venue_term_id, start_datetime)
using the datamachine_event_dates and datamachine_post_identity indexes.
- Pairwise scoring per issue #256:
+5 mutual body-lineup mention (whole-word, 3-char min, both directions)
+2 identical end_datetime
+1 matching price (normalized)
+1 matching source URL host
- Pairs at or above the threshold (default 5 = mutual lineup minimum)
are persisted to the datamachine_pending_actions queue with kind
'merged_bill_resolve'. The agent decision step drains the queue.
- Already-decided pair_keys are skipped on subsequent runs.
CLI surface (inc/Cli/Check/CheckMergedBillsCommand.php):
- 'wp data-machine-events check merged-bills' mirrors CleanDuplicatesCommand.
- Supports --dry-run, --threshold, --limit, --days-ahead, --format.
Bootstrap wires the ability into the abilities registry. The chat tool,
merge executor, and resolver flow are gated on class_exists() so they
remain inert until their commits land later in this PR.
Refs #256.
* feat(abilities): merge_event_posts ability uses shared EventMergeHelper
Adds 'data-machine-events/merge-event-posts' ability — the pairwise
merge executor for the merged-bill resolver (issue #256).
- Input: winner_post_id, loser_post_id, optional merge_ticket_url + reason.
- Validates both posts are event post type so generic agents cannot
misuse the ability to trash arbitrary posts.
- Delegates to EventMergeHelper::merge() so behavior is identical to
'wp data-machine-events check clean-duplicates'.
- Emits a datamachine_log 'info' entry for audit.
Refs #256.
* feat(merged-bills): merged-bill inspect + decide chat tools
Adds the agent decision layer for issue #256:
- inc/Abilities/MergedBillDecideAbilities.php
Two abilities: 'merged-bill-inspect' (read-only post bodies + signals)
and 'merged-bill-decide' (commit verdict). The decide ability handles
merge / distinct / needs_human and writes the resolution into the
datamachine_pending_actions row so subsequent detector runs skip the
pair.
- inc/Api/Chat/Tools/MergedBillInspect.php
- inc/Api/Chat/Tools/MergedBillDecide.php
Thin BaseTool wrappers that expose the abilities to the chat agent.
Chat tool files live in inc/Api/Chat/Tools/ to follow the existing
convention in this plugin (DataMachineEvents has no inc/Steps/<X>/Tool
pattern — that path in the issue body was the architectural sketch,
not the established convention).
Decision contract per issue #256:
- merge: requires winner_post_id; invokes the merge-event-posts ability
and records resolution=accepted.
- distinct: records resolution=rejected, no post mutations.
- needs_human: records resolution=expired with verdict metadata so the
detector treats it as decided-skip and the pair surfaces in operator
pending-actions tooling for review.
Refs #256.
* feat(merged-bills): resolver flow + scoring tests + production fixtures
Last piece of the issue #256 stack:
- inc/Steps/MergedBills/MergedBillResolverFlow.php
Action Scheduler wiring. Schedules a daily recurring detector run via
as_schedule_recurring_action() (gated on AS availability so the CLI
remains usable without AS). Fires
'datamachine_events_merged_bill_pair_queued' for each high-confidence
pair so external orchestrators (chat agents, pipelines) can drain the
queue. Cadence configurable via
'datamachine_events_merged_bill_scan_interval' filter.
- tests/Unit/EventMergeHelperTest.php
Covers the shared trash + ticket_url forward-merge primitive
extracted in the first commit. Invalid IDs, same winner/loser, missing
posts, basic merge, ticket URL behavior (fill-when-empty / preserve /
opt-out).
- tests/Unit/MergedBillDetectScoringTest.php
Covers the lineup-mention heuristic — the strongest signal in the
scoring table. Asserts the two production repro pairs from issue #256
score as mutual mentions, asserts one-sided mentions and distinct
lineups do not, asserts sub-3-char artist names are filtered.
- tests/Fixtures/merged-bills/
Production post_content for the two repro pairs cited in issue #256
(5366/6504 Maraluso/Emma Grace, 12359/219469 Local Nomad/Babe Club),
pulled live from events.extrachill.com.
Refs #256.
---------
Co-authored-by: homeboy-ci[bot] <266378653+homeboy-ci[bot]@users.noreply.github.com>1 parent b18e1dd commit 113b764
17 files changed
Lines changed: 1966 additions & 10 deletions
File tree
- inc
- Abilities
- Api/Chat/Tools
- Cli/Check
- Core/DuplicateDetection
- Steps/MergedBills
- tests
- Fixtures/merged-bills
- Unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| |||
438 | 439 | | |
439 | 440 | | |
440 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
441 | 472 | | |
442 | 473 | | |
443 | 474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
0 commit comments