Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- api/automation_engine.py +34 -7
RELEASES.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v14",
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "8cf15d2",
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v14",
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
8cf15d2
|
api/automation_engine.py
CHANGED
|
@@ -5728,7 +5728,7 @@ def _predicate_sentence(preds, operator="and"):
|
|
| 5728 |
MAX_FLOW_RECORDS = MAX_UT_ROWS
|
| 5729 |
|
| 5730 |
|
| 5731 |
-
def run_plain(rt, defn, username="automation", log=print, step=_no_step, rows=None):
|
| 5732 |
"""β WAVE 24 / R6 β the runner for an automation with NO machine step: its flow IS the whole
|
| 5733 |
automation. Returns the same 5-tuple every other runner does, so `run_now` needs no special
|
| 5734 |
case and `apply_actions` still runs at the ONE call site that already exists.
|
|
@@ -5750,16 +5750,38 @@ def run_plain(rt, defn, username="automation", log=print, step=_no_step, rows=No
|
|
| 5750 |
{}, [], {})
|
| 5751 |
ensure_stage_field(rt, table, defn, username)
|
| 5752 |
all_rows = (ut_get(rt, table) or {}).get("rows") or {}
|
| 5753 |
-
# β THE TRIGGER'S RECORDS WIN OVER THE WHOLE TABLE, and getting this wrong is a day-one bug
|
| 5754 |
# on the kind every new automation now has. `plain` has no machine step, so it has nothing of
|
| 5755 |
# its own to call "the records this run touched" β and walking the WHOLE table would mean
|
| 5756 |
# "When a record is CREATED in ut_leads -> set status = New" writes `New` onto every lead the
|
| 5757 |
# first time one is added. The trigger knows exactly which rows fired; `run_now` threads them
|
| 5758 |
# here. `rows=None` (manual, schedule, Run now) still means the whole table, which is what
|
| 5759 |
# those genuinely mean.
|
| 5760 |
-
ids = ([r for r in (rows or []) if str(r) in all_rows] if rows
|
| 5761 |
-
else sorted(all_rows, key=_rid_num))
|
| 5762 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5763 |
counts = {"records": len(ids)}
|
| 5764 |
if len(ids) > MAX_FLOW_RECORDS:
|
| 5765 |
# The cap is DISCLOSED, never silent ([[no-unverifiable-aggregates]]): the summary names
|
|
@@ -5781,8 +5803,13 @@ def run_plain(rt, defn, username="automation", log=print, step=_no_step, rows=No
|
|
| 5781 |
# database, and a per-STEP narrowing (an enrich step's `fromView`) is a different count that
|
| 5782 |
# this sentence never claimed to report. What was wrong was that nothing said so.
|
| 5783 |
label = str((ut_get(rt, table) or {}).get("label") or "").strip() or table
|
| 5784 |
-
scope = ("the records that fired the trigger" if rows
|
| 5785 |
-
else "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5786 |
return ("ok", f"{n} record{'' if n == 1 else 's'} walked in {label}: {scope}",
|
| 5787 |
counts, ids, {})
|
| 5788 |
|
|
|
|
| 5728 |
MAX_FLOW_RECORDS = MAX_UT_ROWS
|
| 5729 |
|
| 5730 |
|
| 5731 |
+
def run_plain(rt, defn, username="automation", log=print, step=_no_step, rows=None):
|
| 5732 |
"""β WAVE 24 / R6 β the runner for an automation with NO machine step: its flow IS the whole
|
| 5733 |
automation. Returns the same 5-tuple every other runner does, so `run_now` needs no special
|
| 5734 |
case and `apply_actions` still runs at the ONE call site that already exists.
|
|
|
|
| 5750 |
{}, [], {})
|
| 5751 |
ensure_stage_field(rt, table, defn, username)
|
| 5752 |
all_rows = (ut_get(rt, table) or {}).get("rows") or {}
|
| 5753 |
+
# β THE TRIGGER'S RECORDS WIN OVER THE WHOLE TABLE, and getting this wrong is a day-one bug
|
| 5754 |
# on the kind every new automation now has. `plain` has no machine step, so it has nothing of
|
| 5755 |
# its own to call "the records this run touched" β and walking the WHOLE table would mean
|
| 5756 |
# "When a record is CREATED in ut_leads -> set status = New" writes `New` onto every lead the
|
| 5757 |
# first time one is added. The trigger knows exactly which rows fired; `run_now` threads them
|
| 5758 |
# here. `rows=None` (manual, schedule, Run now) still means the whole table, which is what
|
| 5759 |
# those genuinely mean.
|
| 5760 |
+
ids = ([r for r in (rows or []) if str(r) in all_rows] if rows
|
| 5761 |
+
else sorted(all_rows, key=_rid_num))
|
| 5762 |
+
|
| 5763 |
+
# An enrichment-only flow is the one exception to the ordinary manual-run rule above. Its
|
| 5764 |
+
# saved View and quota are not merely how the action decides whether to spend; they ARE the
|
| 5765 |
+
# set of records the automation was asked to process. Walking every row first meant a run
|
| 5766 |
+
# bound to a 10-record "Pending" view announced (and needlessly visited) all 61 table rows.
|
| 5767 |
+
# Besides being misleading, that shape made the runtime scale with unrelated historical rows.
|
| 5768 |
+
#
|
| 5769 |
+
# Keep this deliberately narrow: any flow with another action must still hand that action the
|
| 5770 |
+
# whole manual/scheduled scope. Only one direct, enabled enrich action has no other record
|
| 5771 |
+
# semantics to preserve, so it can begin at its selected records safely.
|
| 5772 |
+
flow_actions = list((defn.get("flow") or {}).get("actions") or [])
|
| 5773 |
+
enabled_direct = [a for a in flow_actions if isinstance(a, dict) and a.get("enabled", True)]
|
| 5774 |
+
enrich_scope_note = ""
|
| 5775 |
+
if rows is None and len(enabled_direct) == 1 \
|
| 5776 |
+
and enabled_direct[0].get("kind") == "enrich_instagram":
|
| 5777 |
+
enrich_cfg = enabled_direct[0].get("config") or {}
|
| 5778 |
+
profile_key = profile_field_key(ut_get(rt, table), enrich_cfg.get("profileField"))
|
| 5779 |
+
if profile_key:
|
| 5780 |
+
selected, enrich_scope_note = enrich_selection(rt, table, enrich_cfg, profile_key)
|
| 5781 |
+
if enrich_scope_note.startswith("the enrich step names a view it cannot read"):
|
| 5782 |
+
return ("partial", f"nothing walked in {table} β {enrich_scope_note}", {}, [], {})
|
| 5783 |
+
ids = selected
|
| 5784 |
+
step(f"Walking {len(ids)} record{'' if len(ids) == 1 else 's'} in {table}")
|
| 5785 |
counts = {"records": len(ids)}
|
| 5786 |
if len(ids) > MAX_FLOW_RECORDS:
|
| 5787 |
# The cap is DISCLOSED, never silent ([[no-unverifiable-aggregates]]): the summary names
|
|
|
|
| 5803 |
# database, and a per-STEP narrowing (an enrich step's `fromView`) is a different count that
|
| 5804 |
# this sentence never claimed to report. What was wrong was that nothing said so.
|
| 5805 |
label = str((ut_get(rt, table) or {}).get("label") or "").strip() or table
|
| 5806 |
+
scope = ("the records that fired the trigger" if rows
|
| 5807 |
+
else ("the records selected for Instagram enrichment"
|
| 5808 |
+
if len(enabled_direct) == 1
|
| 5809 |
+
and enabled_direct[0].get("kind") == "enrich_instagram"
|
| 5810 |
+
else "every record β this run was started by hand, so nothing narrowed it"))
|
| 5811 |
+
if enrich_scope_note:
|
| 5812 |
+
scope += f" ({enrich_scope_note})"
|
| 5813 |
return ("ok", f"{n} record{'' if n == 1 else 's'} walked in {label}: {scope}",
|
| 5814 |
counts, ids, {})
|
| 5815 |
|