fsanyoto commited on
Commit
9486685
Β·
verified Β·
1 Parent(s): 051f280

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "current": "e4041c9",
3
  "releases": [
4
  {
5
  "version": "v24",
 
1
  {
2
+ "current": "1be950d",
3
  "releases": [
4
  {
5
  "version": "v24",
VERSION CHANGED
@@ -1 +1 @@
1
- e4041c9
 
1
+ 1be950d
api/automation_engine.py CHANGED
@@ -3568,6 +3568,25 @@ TT_TABLE_LABELS = {
3568
  #: defect, not the intent.
3569
  TT_LOCKED_TABLES = frozenset({TT_SNAPSHOTS_TABLE, TT_POSTS_TABLE, TT_POST_SNAPSHOTS_TABLE,
3570
  TT_COMMENTS_TABLE})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3571
 
3572
 
3573
  def tt_record_mode(table_key):
@@ -7922,6 +7941,26 @@ FIND_LIMIT_MAX = 100
7922
  #: ceiling nearly unreachable. That is E's own PENDING row; this bound is what stops the damage
7923
  #: until it lands.
7924
  MAX_WEB_JOBS_PER_RUN = 50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7925
  #: ⭐ W31-T38 (C5) β€” the web step's own clamps. `20000` matches the default E's seam documents;
7926
  #: the ceiling exists because this blocks the record walk (~9-32 s of cold start ALREADY), and an
7927
  #: automation that can be configured to wait ten minutes per record is a stalled run, not a slow one.
@@ -7944,25 +7983,35 @@ ACTION_CATALOG = [
7944
  # own promises has to be re-read by whoever misses the date, and a stale date is worse than
7945
  # none because it reads as a commitment somebody already broke. The replacement names the
7946
  # missing CAPABILITY, like its four siblings always did; D-51 carries the schedule.
7947
- {"kind": "web_goto", "label": "Open a page", "group": "Web action", "ready": False,
7948
- "detail": "Needs the browser job β€” a real browser running inside an ephemeral worker"},
7949
- {"kind": "web_fill", "label": "Fill a field", "group": "Web action", "ready": False,
7950
- "detail": "Needs the recorder that captures a selector instead of a coordinate"},
7951
- {"kind": "web_click", "label": "Click something", "group": "Web action", "ready": False,
7952
- "detail": "Needs the recorder that captures a selector instead of a coordinate"},
7953
- # ⭐⭐ WAVE 31 Β· T38 (C5, owner ruling R10) β€” THE ONE ROW THAT FLIPS. `web_read` is the
7954
- # unattended READ: it fetches a real page in an ephemeral HF Job and writes one value into one
7955
- # column. Its four siblings stay `ready:False` because each WRITES to a third party, and D-51/R5
7956
- # defaults any such action to needs-approval β€” a gate this wave does not build. The runner
7957
- # refuses them by kind as well, so flipping one here would ship an action that is addable and
7958
- # inert, which is worse than a faded row that says why.
7959
  # ⚠ THE FADED ROW IS A WALL, NOT A STYLE: `clean_actions` refuses an unready kind with a
7960
- # sentence, so this flag is what makes the action storable at all.
 
 
 
 
 
 
 
 
 
 
 
7961
  {"kind": "web_read", "label": "Read from the page", "group": "Web action", "ready": True,
7962
  "detail": "Reads one value off a live page in a browser job β€” expect ~10-30 s per step"},
7963
  {"kind": "web_repair", "label": "Repair a broken step", "group": "Web action",
7964
- "ready": False,
7965
- "detail": "Self-healing selectors arrive with the browser engine (Scrapling)"},
7966
  # ── 2. DATABASE ──────────────────────────────────────────────────────────────────────────
7967
  {"kind": "update_record", "label": "Update record", "group": "Database", "ready": True,
7968
  "detail": "Write values onto the record walking the flow"},
@@ -8335,9 +8384,18 @@ def _clean_action_config(kind, cfg, depth, seen, count):
8335
  if limit < 1 or limit > FIND_LIMIT_MAX:
8336
  return None, f"the find records limit is between 1 and {FIND_LIMIT_MAX}"
8337
  return {"table": table, "cond": cond, "limit": limit}, None
8338
- if kind == "web_read":
8339
  # ⭐⭐ WAVE 31 Β· T38 (C5 / R10) β€” AND THIS ARM IS THE HALF THAT WOULD HAVE SHIPPED MISSING.
8340
  #
 
 
 
 
 
 
 
 
 
8341
  # β›” FOUND BY THE GATE, NOT BY REVIEW, AND IT IS THE TICKET'S OWN FAILURE MODE. Flipping
8342
  # `ready:True` and mounting the dispatch arm is not enough: with no branch here the
8343
  # function falls through to `return {}, None` below, so a stored `web_read` action keeps
@@ -8383,6 +8441,22 @@ def _clean_action_config(kind, cfg, depth, seen, count):
8383
  wait = _s(cfg.get("waitFor"), 200).strip()
8384
  if wait:
8385
  out["waitFor"] = wait
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8386
  return out, None
8387
  return {}, None
8388
 
@@ -9176,17 +9250,21 @@ def apply_actions(rt, defn, table_key, row_ids, username="automation", log=print
9176
  # the table would silently apply one action's uniqueness rule to the other's rows.
9177
  creates.setdefault((target, str(cfg.get("uniqueOn") or "")), []).append(vals)
9178
  counts["created"] += 1
9179
- elif kind == "web_read":
9180
- # ⭐⭐ WAVE 31 Β· T38 (C5, owner ruling R10) β€” THE WEB-BROWSING AGENT'S ONE LIVE ARM.
9181
  #
9182
  # β›” WHY THIS ARM EXISTS SEPARATELY FROM THE RUNNER: session E built
9183
  # `web_agent.run_step` and **could not verify its own mounting**. An unmounted
9184
  # runner is a whole, correct, unreachable feature β€” the exact class five wave-29
9185
  # features shipped as β€” so the mount and its `verify_wiring` row are C's, in one
9186
- # change. `web_read` is the ONLY kind flipped to `ready:True`;
9187
- # `web_goto`/`web_fill`/`web_click`/`web_repair` WRITE to a third party and D-51/R5
9188
- # defaults those to needs-approval, which this wave does not build. The runner also
9189
- # refuses them by kind, so flipping one would ship an addable, inert action.
 
 
 
 
9190
  #
9191
  # β›” IT BLOCKS FOR ~9-32 s (E measured it; `proto/web-agent-job.md` Β§4). That is
9192
  # tolerable HERE and nowhere else: this is the automation RUNNER, already a
@@ -9200,15 +9278,22 @@ def apply_actions(rt, defn, table_key, row_ids, username="automation", log=print
9200
  # per RUN and not per record: the missing config is a property of the flow, so a
9201
  # 100-record walk would otherwise print the same sentence a hundred times and bury
9202
  # everything else. The same shape the enrich arm's `unbound` note uses.
9203
- _missing = [n for n, v in (("a URL", cfg.get("url")),
9204
- ("a CSS selector", cfg.get("selector")),
9205
- ("a column to write into", cfg.get("field")))
9206
- if not str(v or "").strip()]
 
 
9207
  if _missing:
9208
- if "web_read_unconfigured" not in web_notes:
9209
- web_notes.append("web_read_unconfigured")
9210
- log("[aios-auto] web_read: this step still needs "
9211
- + ", ".join(_missing) + " β€” nothing was read")
 
 
 
 
 
9212
  counts["webBlocked"] += 1
9213
  continue
9214
  # β›”β›” THE PER-RUN JOB CEILING (E-4). One browser job per RECORD, ~9-32 s each,
@@ -9229,13 +9314,26 @@ def apply_actions(rt, defn, table_key, row_ids, username="automation", log=print
9229
  _url = interpolate(str(cfg.get("url") or ""), row)
9230
  _sel = interpolate(str(cfg.get("selector") or ""), row)
9231
  _wait = cfg.get("waitFor")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9232
  result, why = _web_agent().run_step(
9233
- {"kind": "web_read", "id": str(act.get("id") or ""),
9234
- "url": _url, "selector": _sel,
9235
- "attr": str(cfg.get("attr") or "text"),
9236
- "all": bool(cfg.get("all")),
9237
- "waitFor": interpolate(str(_wait), row) if _wait else None,
9238
- "timeoutMs": int(cfg.get("timeoutMs") or 20000)},
9239
  {"tenant": str(defn.get("tenant") or ""),
9240
  "automationId": str(defn.get("id") or ""),
9241
  "runId": str(defn.get("id") or ""), "log": log})
 
3568
  #: defect, not the intent.
3569
  TT_LOCKED_TABLES = frozenset({TT_SNAPSHOTS_TABLE, TT_POSTS_TABLE, TT_POST_SNAPSHOTS_TABLE,
3570
  TT_COMMENTS_TABLE})
3571
+ #: ⭐ THE INSTAGRAM HALF, NAMED. It was only ever the four keys `ensure_ig_graph`'s loop happens to
3572
+ #: iterate, which is a set that exists but cannot be ASKED β€” so nothing could assert that IG and
3573
+ #: TikTok lock the same shape, and the QA sweep below could not be written at all.
3574
+ IG_LOCKED_TABLES = frozenset({IG_SNAPSHOTS_TABLE, IG_POSTS_TABLE, IG_POST_SNAPSHOTS_TABLE,
3575
+ IG_COMMENTS_TABLE})
3576
+ #: ⭐⭐ W31 QA β€” OWNER, VERBATIM (2026-08-13): *"just like Instagram Post database (which is
3577
+ #: locked), only the IG Profile and TT Profile should be editable."* That is this set plus its
3578
+ #: complement: every `ut_ig_*`/`ut_tt_*` child is locked, and `ut_ig_profile` / `ut_tt_profile` are
3579
+ #: the two a person types handles into. Registered into `core.user_tables` at import so the lock is
3580
+ #: a DECLARATION rather than a flag some past automation run happened to stamp β€” see that module's
3581
+ #: `_LOCKED_RECORD_KEYS` for why the stored flag alone left production unlocked.
3582
+ #: β›” THE REGISTRATION ITSELF IS IN `main.py`, NOT HERE, and that is this module's own rule rather
3583
+ #: than a preference: it imports NOTHING from `core` at module level (see `MAX_UT_ROWS` and
3584
+ #: `MACHINE_OWNERS`, both local literals "so this module stays dependency-light for the API's boot
3585
+ #: path"). Adding `import core.user_tables` at line 3570 would put `core` on the import path of
3586
+ #: every process that touches the engine, to run one line. The composition root wires it, and
3587
+ #: `verify_automation` asserts that main.py CARRIES that call β€” a declaration whose registrar is
3588
+ #: missing is [[flag-shipped-without-its-writer]], which is the defect class this whole fix is in.
3589
+ LOCKED_CHILD_TABLES = IG_LOCKED_TABLES | TT_LOCKED_TABLES
3590
 
3591
 
3592
  def tt_record_mode(table_key):
 
7941
  #: ceiling nearly unreachable. That is E's own PENDING row; this bound is what stops the damage
7942
  #: until it lands.
7943
  MAX_WEB_JOBS_PER_RUN = 50
7944
+ #: ⭐⭐ W31 QA β€” THE FIVE WEB KINDS THE ENGINE DISPATCHES, and this is the THIRD list that names
7945
+ #: them (`web_agent.RUNNABLE_KINDS` is the seam's, `jobs/web_agent_job.py::RUNNABLE_KINDS` is the
7946
+ #: runner's). β›” IT IS DELIBERATELY NOT AN IMPORT: `_web_agent()` resolves the seam LAZILY so an
7947
+ #: absent module cannot break the engine, and a module-level `from web_agent import RUNNABLE_KINDS`
7948
+ #: would throw that property away for a tuple of five strings. The three lists are held in step by
7949
+ #: `verify_web_agent.py::section_one_kind_only`, which reds if any pair disagrees β€” a per-kind
7950
+ #: allow-list in three places that CAN disagree is the defect, whichever way it points.
7951
+ WEB_KINDS = ("web_read", "web_goto", "web_fill", "web_click", "web_repair")
7952
+ #: What each kind cannot run WITHOUT. Absence is never refused at SAVE (a step is addable before it
7953
+ #: is configured β€” see `_clean_action_config`'s web arm); it is refused at RUN with a sentence
7954
+ #: naming what is missing. `url` is required only by `web_goto`: every other kind acts on the page
7955
+ #: the flow is already on, and the runner supplies its own refusal when it genuinely needs one.
7956
+ WEB_REQUIRED = {
7957
+ "web_read": (("a URL", "url"), ("a CSS selector", "selector"),
7958
+ ("a column to write into", "field")),
7959
+ "web_goto": (("a URL", "url"),),
7960
+ "web_click": (("a CSS selector", "selector"),),
7961
+ "web_repair": (("a CSS selector", "selector"),),
7962
+ "web_fill": (("a CSS selector", "selector"), ("a value to type", "value")),
7963
+ }
7964
  #: ⭐ W31-T38 (C5) β€” the web step's own clamps. `20000` matches the default E's seam documents;
7965
  #: the ceiling exists because this blocks the record walk (~9-32 s of cold start ALREADY), and an
7966
  #: automation that can be configured to wait ten minutes per record is a stalled run, not a slow one.
 
7983
  # own promises has to be re-read by whoever misses the date, and a stale date is worse than
7984
  # none because it reads as a commitment somebody already broke. The replacement names the
7985
  # missing CAPABILITY, like its four siblings always did; D-51 carries the schedule.
7986
+ # ⭐⭐ WAVE 31 Β· T38 + QA (C5) β€” ALL FIVE ROWS ARE READY, AND THE RULING IS WHY.
7987
+ #
7988
+ # β›” THIS REVERSES T38's ORIGINAL `how:`, ON THE OWNER'S OWN WORDS. T38 shipped `web_read`
7989
+ # alone and held the other four at `ready:False`, citing PRD R10 ("the ones that WRITE to a
7990
+ # third party do not flip without R5's approval gate existing"). **R5 was REVOKED the same
7991
+ # day, and the revocation is recorded as an amendment on this wave's board**
7992
+ # (`TICKETS.md:1418`, `mailbox/E.md:278`, `web_agent.py:103`) β€” owner, verbatim:
7993
+ # *"make sure we unblock all web actions, we don't need approval step first wtf, I never ask
7994
+ # for that."* Session C declined E's ask against the superseded half of R10, so four actions
7995
+ # the owner asked for shipped unusable, and `verify_web_agent` was RED on correct-by-ruling
7996
+ # code for the whole wave. Confirmed at QA against four independent recordings of the quote.
 
7997
  # ⚠ THE FADED ROW IS A WALL, NOT A STYLE: `clean_actions` refuses an unready kind with a
7998
+ # sentence, so this flag is what makes the action storable at all β€” which is exactly why a
7999
+ # row left `False` against a ruling is a feature that does not exist.
8000
+ # ⚠ THE `detail` STRINGS CHANGED WITH THE FLAGS, deliberately. They said *"Needs the browser
8001
+ # job"* and *"Needs the recorder that captures a selector"* β€” both false since E's runner
8002
+ # landed. A menu that dates its own promises is this module's own recorded complaint one
8003
+ # comment up; a row that advertises a missing prerequisite it already has is the same defect.
8004
+ {"kind": "web_goto", "label": "Open a page", "group": "Web action", "ready": True,
8005
+ "detail": "Opens a page in a browser job and reports the title it landed on"},
8006
+ {"kind": "web_fill", "label": "Fill a field", "group": "Web action", "ready": True,
8007
+ "detail": "Types a value into a field β€” mark it secret and the value is masked in the log"},
8008
+ {"kind": "web_click", "label": "Click something", "group": "Web action", "ready": True,
8009
+ "detail": "Clicks the element a selector names, and reports where it landed"},
8010
  {"kind": "web_read", "label": "Read from the page", "group": "Web action", "ready": True,
8011
  "detail": "Reads one value off a live page in a browser job β€” expect ~10-30 s per step"},
8012
  {"kind": "web_repair", "label": "Repair a broken step", "group": "Web action",
8013
+ "ready": True,
8014
+ "detail": "Follows a label to its control when a selector has gone stale, and proposes one"},
8015
  # ── 2. DATABASE ──────────────────────────────────────────────────────────────────────────
8016
  {"kind": "update_record", "label": "Update record", "group": "Database", "ready": True,
8017
  "detail": "Write values onto the record walking the flow"},
 
8384
  if limit < 1 or limit > FIND_LIMIT_MAX:
8385
  return None, f"the find records limit is between 1 and {FIND_LIMIT_MAX}"
8386
  return {"table": table, "cond": cond, "limit": limit}, None
8387
+ if kind in WEB_KINDS:
8388
  # ⭐⭐ WAVE 31 Β· T38 (C5 / R10) β€” AND THIS ARM IS THE HALF THAT WOULD HAVE SHIPPED MISSING.
8389
  #
8390
+ # ⭐⭐ W31 QA WIDENED IT FROM `web_read` TO ALL FIVE KINDS, AND THAT IS THE SAME DEFECT THIS
8391
+ # ARM'S OWN COMMENT DESCRIBES, ARRIVING A SECOND TIME. When the four write kinds flipped to
8392
+ # `ready:True` on the owner's revocation of R5, they became storable β€” and with this arm
8393
+ # still testing `kind == "web_read"` they fell through to `return {}, None` below, keeping
8394
+ # their KIND and losing `url` / `selector` / `value` / `hint` **silently, with no error
8395
+ # anywhere**. Addable, storable, runnable, and forever unconfigured. The paragraph below
8396
+ # was written about exactly this, one kind earlier; widening the test is what makes it
8397
+ # true of the feature rather than of one row in it.
8398
+ #
8399
  # β›” FOUND BY THE GATE, NOT BY REVIEW, AND IT IS THE TICKET'S OWN FAILURE MODE. Flipping
8400
  # `ready:True` and mounting the dispatch arm is not enough: with no branch here the
8401
  # function falls through to `return {}, None` below, so a stored `web_read` action keeps
 
8441
  wait = _s(cfg.get("waitFor"), 200).strip()
8442
  if wait:
8443
  out["waitFor"] = wait
8444
+ # ⭐ THE FOUR WRITE KINDS' OWN KEYS. Carried for EVERY web kind rather than switched on
8445
+ # `kind`, because the cost of carrying an unused key is nothing and the cost of dropping a
8446
+ # used one is a step that runs forever against a value the user typed and cannot see.
8447
+ # `value` is the text `web_fill` types; `secret` masks it in the run log; `hint` is the
8448
+ # human label `web_repair` follows when a selector has gone stale; `dryRun` rehearses a
8449
+ # write without performing it (E measured the field reading back empty afterwards).
8450
+ value = _s(cfg.get("value"), 500)
8451
+ if value:
8452
+ out["value"] = value
8453
+ hint = _s(cfg.get("hint"), 200).strip()
8454
+ if hint:
8455
+ out["hint"] = hint
8456
+ if cfg.get("secret"):
8457
+ out["secret"] = True
8458
+ if cfg.get("dryRun"):
8459
+ out["dryRun"] = True
8460
  return out, None
8461
  return {}, None
8462
 
 
9250
  # the table would silently apply one action's uniqueness rule to the other's rows.
9251
  creates.setdefault((target, str(cfg.get("uniqueOn") or "")), []).append(vals)
9252
  counts["created"] += 1
9253
+ elif kind in WEB_KINDS:
9254
+ # ⭐⭐ WAVE 31 Β· T38 (C5) β€” THE WEB-BROWSING AGENT'S LIVE ARM, ALL FIVE KINDS.
9255
  #
9256
  # β›” WHY THIS ARM EXISTS SEPARATELY FROM THE RUNNER: session E built
9257
  # `web_agent.run_step` and **could not verify its own mounting**. An unmounted
9258
  # runner is a whole, correct, unreachable feature β€” the exact class five wave-29
9259
  # features shipped as β€” so the mount and its `verify_wiring` row are C's, in one
9260
+ # change.
9261
+ # ⭐⭐ W31 QA WIDENED THIS ARM FROM `web_read` TO ALL FIVE KINDS on the owner's
9262
+ # revocation of D-51/R5 (`TICKETS.md:1418`). ⚠ IT NEEDS NO PER-KIND HANDLING, and
9263
+ # that is E's design rather than an omission: the runner normalises EVERY kind to
9264
+ # set `result["value"]` (read β†’ the text Β· goto β†’ the title Β· click β†’ the title it
9265
+ # landed on Β· fill β†’ the typed value, masked when secret Β· repair β†’ the proposed
9266
+ # selector), precisely so this one arm does not grow a switch that would be a
9267
+ # second copy of the runner's table living in another lane's file.
9268
  #
9269
  # β›” IT BLOCKS FOR ~9-32 s (E measured it; `proto/web-agent-job.md` Β§4). That is
9270
  # tolerable HERE and nowhere else: this is the automation RUNNER, already a
 
9278
  # per RUN and not per record: the missing config is a property of the flow, so a
9279
  # 100-record walk would otherwise print the same sentence a hundred times and bury
9280
  # everything else. The same shape the enrich arm's `unbound` note uses.
9281
+ # ⚠ PER KIND, because they do not need the same things: `web_goto` needs a url and
9282
+ # no selector; `web_fill` needs a value nobody else takes; only `web_read` needs a
9283
+ # column to write into. One shared three-field test would have blocked every
9284
+ # `web_goto` ever configured for want of a selector it does not use.
9285
+ _missing = [n for n, key in WEB_REQUIRED.get(kind, ())
9286
+ if not str(cfg.get(key) or "").strip()]
9287
  if _missing:
9288
+ # ⚠ THE NOTE KEY CARRIES THE KIND. It used to be the literal
9289
+ # `"web_read_unconfigured"`, so a flow with an unconfigured `web_goto` AND an
9290
+ # unconfigured `web_fill` would have reported the first and swallowed the
9291
+ # second β€” once-per-RUN is the property, not once-per-FLOW.
9292
+ _note = f"{kind}_unconfigured"
9293
+ if _note not in web_notes:
9294
+ web_notes.append(_note)
9295
+ log(f"[aios-auto] {kind}: this step still needs "
9296
+ + ", ".join(_missing) + " β€” nothing was done")
9297
  counts["webBlocked"] += 1
9298
  continue
9299
  # β›”β›” THE PER-RUN JOB CEILING (E-4). One browser job per RECORD, ~9-32 s each,
 
9314
  _url = interpolate(str(cfg.get("url") or ""), row)
9315
  _sel = interpolate(str(cfg.get("selector") or ""), row)
9316
  _wait = cfg.get("waitFor")
9317
+ _step = {"kind": kind, "id": str(act.get("id") or ""),
9318
+ "url": _url, "selector": _sel,
9319
+ "attr": str(cfg.get("attr") or "text"),
9320
+ "all": bool(cfg.get("all")),
9321
+ "waitFor": interpolate(str(_wait), row) if _wait else None,
9322
+ "timeoutMs": int(cfg.get("timeoutMs") or 20000)}
9323
+ # ⚠ `value` IS INTERPOLATED LIKE THE URL AND THE SELECTOR β€” a `web_fill` typing
9324
+ # `{{Email}}` is the whole point of running it over a record walk. β›” AND IT IS
9325
+ # ADDED ONLY WHEN PRESENT: the seam distinguishes a key that is absent from one
9326
+ # that is empty, and an empty `value` on a `web_read` would be a typed blank.
9327
+ if cfg.get("value"):
9328
+ _step["value"] = interpolate(str(cfg.get("value")), row)
9329
+ if cfg.get("hint"):
9330
+ _step["hint"] = interpolate(str(cfg.get("hint")), row)
9331
+ if cfg.get("secret"):
9332
+ _step["secret"] = True
9333
+ if cfg.get("dryRun"):
9334
+ _step["dryRun"] = True
9335
  result, why = _web_agent().run_step(
9336
+ _step,
 
 
 
 
 
9337
  {"tenant": str(defn.get("tenant") or ""),
9338
  "automationId": str(defn.get("id") or ""),
9339
  "runId": str(defn.get("id") or ""), "log": log})
api/main.py CHANGED
@@ -594,6 +594,16 @@ def _store_resync_loop():
594
  # would be a second thing to keep in step, and the two would answer differently on the
595
  # next ruling β€” the exact shape the Views top-up was just fixed for on the other side of
596
  # this wave.
 
 
 
 
 
 
 
 
 
 
597
  _rebuild_odoo_relational("resync")
598
 
599
 
 
594
  # would be a second thing to keep in step, and the two would answer differently on the
595
  # next ruling β€” the exact shape the Views top-up was just fixed for on the other side of
596
  # this wave.
597
+ # β›” THE META PULL RIDES THE RESYNC TOO, AND LEAVING IT OUT WAS A REAL GAP β€” caught by
598
+ # reading the deploy's own boot log rather than by any gate. `_pull_meta` was wired into
599
+ # `_seed_and_sync_store` ALONE, i.e. it ran exactly once per container, at boot, behind a
600
+ # full Odoo sync. So a boot where the Graph call was rate-limited, slow or simply after the
601
+ # thread died left the mirror empty with NOTHING to retry it: the relational rebuild below
602
+ # would then find no `meta_*` tables every 30 minutes forever and skip, silently and
603
+ # correctly. A connector that can only ever be established at boot is one bad boot away
604
+ # from being permanently absent.
605
+ # ⚠ Cheap when there is nothing to do: no token => one line and return.
606
+ _pull_meta("resync")
607
  _rebuild_odoo_relational("resync")
608
 
609
 
api/routes_automation.py CHANGED
@@ -945,3 +945,19 @@ import core.user_tables as _ut_hooks # noqa: E402
945
 
946
  if engine.grid_hook not in _ut_hooks.ROW_HOOKS:
947
  _ut_hooks.ROW_HOOKS.append(engine.grid_hook)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
945
 
946
  if engine.grid_hook not in _ut_hooks.ROW_HOOKS:
947
  _ut_hooks.ROW_HOOKS.append(engine.grid_hook)
948
+
949
+ # ⭐⭐ W31 QA β€” DECLARE THE MACHINE-OWNED CHILD DATABASES, for the same reason and in the same
950
+ # place as the hook above: this module already imports both sides, so neither the engine nor
951
+ # `platform/core` grows a dependency on the other. Idempotent by construction (a set).
952
+ #
953
+ # β›” THE OWNER FOUND WHAT THIS FIXES, IN PRODUCTION, AFTER THE TICKET READ GREEN. W31-T32 locked
954
+ # the TikTok children by stamping `recordMode` at the two SPAWN sites, and proved the stamp
955
+ # arrives "on the next write". That is true and it is not the `done-when`: every TikTok database
956
+ # already sitting in a tenant kept offering "+ New record" until somebody re-ran a TikTok
957
+ # automation, and nobody had. Owner, verbatim (2026-08-13): *"the databases for Tiktok do not have
958
+ # the small lock icon as I asked"* β€” and the rule, restated: *"just like Instagram Post database
959
+ # (which is locked), only the IG Profile and TT Profile should be editable."*
960
+ # ⚠ A DECLARATION NEEDS NO WRITE, so it is true for EVERY tenant the moment the API boots β€” no
961
+ # migration, no boot ordering, no per-tenant walk, and nothing that a stale store can undo. The
962
+ # stored flag still locks a table nobody declares; the two are OR'd.
963
+ _ut_hooks.register_locked_records(engine.LOCKED_CHILD_TABLES)
api/routes_tables.py CHANGED
@@ -105,23 +105,45 @@ def _refresh_relations(session):
105
  name=f"rel-refresh:{tenant or 'default'}").start()
106
 
107
 
108
- def _defn_or_refuse(session, table_key):
109
  """The per-table wall: 404 for a key that does not exist, 403 for one this session may not
110
  open. 404-before-403 leaks nothing useful β€” ut keys are guessable slugs, and 'exists but
111
- not yours' is exactly what may_open is for."""
 
 
 
 
 
112
  ut = _ut()
113
- defn = ut.get(table_key, st=session.runtime)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  if not defn:
115
  raise err(404, "unknown_table", "that database does not exist")
116
- if not ut.may_open(table_key, session.uname, session.admin, st=session.runtime):
117
  raise err(403, "forbidden", "that database belongs to another user")
118
  return defn
119
 
120
 
121
- def _records_or_refuse(session, table_key):
122
  """The human record-write wall for a database the automation engine owns."""
123
- defn = _defn_or_refuse(session, table_key)
124
- if not _ut().records_mutable(table_key, st=session.runtime):
 
 
 
125
  raise err(403, "records_read_only",
126
  "records in this automation-owned database are read-only β€” add Instagram "
127
  "handles in a Profile database and let enrichment populate this database")
@@ -1207,9 +1229,23 @@ def delete_field(table_key: str, fkey: str, session: Session = Depends(require_s
1207
 
1208
  @router.delete("/tables/{table_key}/rows/{rid}")
1209
  def delete_row(table_key: str, rid: str, session: Session = Depends(require_session)):
1210
- _records_or_refuse(session, table_key)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1211
  try:
1212
- ok = _ut().delete_row(table_key, rid, st=session.runtime)
1213
  except Exception:
1214
  raise err(503, "store_unavailable", "the delete did not land β€” try again")
1215
  if not ok:
 
105
  name=f"rel-refresh:{tenant or 'default'}").start()
106
 
107
 
108
+ def _defn_or_refuse(session, table_key, st=None):
109
  """The per-table wall: 404 for a key that does not exist, 403 for one this session may not
110
  open. 404-before-403 leaks nothing useful β€” ut keys are guessable slugs, and 'exists but
111
+ not yours' is exactly what may_open is for.
112
+
113
+ ⭐ `st` LETS A CALLER LEND THE SNAPSHOT IT IS ALREADY HOLDING (W31 QA), the same `lend()` the
114
+ nav and `/tables` use since W31-T10/T12. The WALL is untouched β€” the same `may_open`, asked
115
+ about the same table β€” it is simply not re-reading a 28.5 MB document to ask it.
116
+ """
117
  ut = _ut()
118
+ # ⭐⭐ W31 QA β€” THE SWEEP, AND IT IS ONE LINE BECAUSE IT IS DONE HERE RATHER THAN PER ROUTE.
119
+ # Owner: *"this is just one case, I need you to check and apply the fix everywhere too."*
120
+ # This guard has FOURTEEN call sites and cost TWO whole-document deep copies at every one
121
+ # (`get`, then `may_open`) β€” on tenant #0 that is 2 x 28.5 MB (D-185) to answer two questions
122
+ # about ONE table. Lending here fixes every caller at once, including the eight routes the
123
+ # sweep enumerated (`PATCH /shared/{pid}` Β· `DELETE /shared/fields/{k}` Β· `GET|POST /rows` Β·
124
+ # `POST /rows/import` Β· `POST|PATCH /fields` Β· `PATCH /rows/{pid}`).
125
+ # β›” WHY IT IS SAFE HERE AND WOULD NOT BE IN THE ROUTES: a lend is a PRE-WRITE snapshot. The
126
+ # guard runs before any mutation and returns only the DEFINITION, so the snapshot never
127
+ # survives to serve a read-back. Blanket-replacing `st=session.runtime` inside the routes
128
+ # would hand that stale snapshot to `patch_row`'s and `add_row`'s post-write read-back, which
129
+ # is [[refetch-eats-its-own-write]] with the sign flipped β€” a write that reports the value it
130
+ # replaced. The remaining in-route reads are deliberately untouched and booked instead.
131
+ st = st if st is not None else ut.lend(session.runtime)
132
+ defn = ut.get(table_key, st=st)
133
  if not defn:
134
  raise err(404, "unknown_table", "that database does not exist")
135
+ if not ut.may_open(table_key, session.uname, session.admin, st=st):
136
  raise err(403, "forbidden", "that database belongs to another user")
137
  return defn
138
 
139
 
140
+ def _records_or_refuse(session, table_key, st=None):
141
  """The human record-write wall for a database the automation engine owns."""
142
+ # One lend for BOTH questions this wall asks β€” the definition wall and the record-mode wall β€”
143
+ # so the two are answered from one read instead of two. Same reasoning as `_defn_or_refuse`.
144
+ st = st if st is not None else _ut().lend(session.runtime)
145
+ defn = _defn_or_refuse(session, table_key, st=st)
146
+ if not _ut().records_mutable(table_key, st=st):
147
  raise err(403, "records_read_only",
148
  "records in this automation-owned database are read-only β€” add Instagram "
149
  "handles in a Profile database and let enrichment populate this database")
 
1229
 
1230
  @router.delete("/tables/{table_key}/rows/{rid}")
1231
  def delete_row(table_key: str, rid: str, session: Session = Depends(require_session)):
1232
+ # ⭐⭐ W31 QA β€” ONE SNAPSHOT FOR THE WHOLE DELETE, and the owner reported what it cost.
1233
+ # Owner, verbatim (2026-08-13): *"it still takes forever to delete a record from TT Profile."*
1234
+ # A single DELETE was FIVE whole-document deep copies before the commit even began β€” three in
1235
+ # the guard (`get` + `may_open` + `records_mutable`) and two more inside
1236
+ # `core.user_tables.delete_row` (`is_user_table` + `records_mutable` again). MEASURED: 2 reads
1237
+ # cost 45 ms on an 0.8 MB fixture, and tenant #0's `user_tables` document is **28.5 MB**
1238
+ # (D-185), so the guard alone was seconds of copying to answer questions about one row.
1239
+ # ⚠ THE LEND IS READ-ONLY AND THE WRITE STILL GOES THROUGH THE REAL RUNTIME β€” `_Lent`
1240
+ # `__getattr__`-passes `update` straight to it, and `_drop` runs against the LIVE document
1241
+ # under the store lock, so a lent snapshot can never be the thing written back.
1242
+ # ⚠ `flush='sync'` IS DELIBERATELY UNTOUCHED (D-118): nobody spams a delete, and an eventually
1243
+ # consistent delete is indistinguishable from one that did not work. This makes the guard
1244
+ # cheap; it does not make the commit optimistic.
1245
+ lent = _ut().lend(session.runtime)
1246
+ _records_or_refuse(session, table_key, st=lent)
1247
  try:
1248
+ ok = _ut().delete_row(table_key, rid, st=lent)
1249
  except Exception:
1250
  raise err(503, "store_unavailable", "the delete did not land β€” try again")
1251
  if not ok:
platform/core/user_tables.py CHANGED
@@ -352,15 +352,50 @@ AUTOMATION_RECORD_MODE = 'automation'
352
  KEY_PREFIX = 'ut_'
353
 
354
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  def records_mutable(table_key, st=None):
356
  """May a human add/edit/delete records in this database?
357
 
358
- Ordinary and Profile databases default open. Automation-owned child datasets opt out with a
359
- table-level mode; engine writers use their direct coalesced path and are intentionally not
360
- routed through this human-door predicate.
 
361
  """
362
  table = get(table_key, st) or {}
363
- return bool(table) and table.get('recordMode') != AUTOMATION_RECORD_MODE
 
 
 
 
364
 
365
  #: The field types a user table may declare. ⚠ Kept a SUBSET of
366
  #: `aios_grid.CUSTOM_FIELD_TYPES` (gated in verify_api's W18-UT section). `created_time` stays
 
352
  KEY_PREFIX = 'ut_'
353
 
354
 
355
+ #: ⭐⭐ W31 QA β€” KEYS WHOSE RECORDS ARE MACHINE-OWNED **BY DECLARATION**, registered by the layer
356
+ #: that owns the connector (`automation_engine` at import), exactly as `register_connected_prefix`
357
+ #: is. `core` never imports up, so the engine pushes its list down here rather than this module
358
+ #: reaching for it.
359
+ #:
360
+ #: β›” WHY A REGISTRY AND NOT THE STORED FLAG ALONE β€” THE OWNER FOUND THIS IN PRODUCTION.
361
+ #: `recordMode` is stamped by `ut_ensure`, so a table only became locked THE NEXT TIME AN
362
+ #: AUTOMATION WROTE TO IT. W31-T32 proved that migration works and read it as done; it means every
363
+ #: TikTok database already sitting in a tenant stayed unlocked β€” offering "+ New record" β€” until
364
+ #: somebody re-ran a TikTok automation, which nobody had. Owner, verbatim: *"the databases for
365
+ #: Tiktok do not have the small lock icon as I asked."* A lock that arrives on the next write is a
366
+ #: lock that is absent exactly while a person is looking at it.
367
+ #: ⚠ THE REGISTRY IS THE AUTHORITY AND THE STORED FLAG STILL COUNTS β€” either one locks. The flag
368
+ #: keeps working for tables nobody declares, and the declaration needs no store write, no boot
369
+ #: order and no per-tenant migration, so it is true for every tenant the moment the module loads.
370
+ #: ⚠ LOCKED DATABASE, NOT READ-ONLY (DESIGN.md §4): this predicate governs RECORDS. Adding a FIELD
371
+ #: must still work, and `may_edit_field` is a different wall.
372
+ _LOCKED_RECORD_KEYS = set()
373
+
374
+
375
+ def register_locked_records(*keys):
376
+ """Declare table keys whose records are machine-owned. Idempotent; -> the registered set."""
377
+ for k in keys:
378
+ for one in (k if isinstance(k, (set, frozenset, list, tuple)) else (k,)):
379
+ if str(one or '').strip():
380
+ _LOCKED_RECORD_KEYS.add(str(one).strip())
381
+ return frozenset(_LOCKED_RECORD_KEYS)
382
+
383
+
384
+
385
  def records_mutable(table_key, st=None):
386
  """May a human add/edit/delete records in this database?
387
 
388
+ Ordinary and Profile databases default open. Automation-owned child datasets opt out β€” by
389
+ DECLARATION (`register_locked_records`, which needs no write) or by the stored table-level
390
+ mode; engine writers use their direct coalesced path and are intentionally not routed through
391
+ this human-door predicate.
392
  """
393
  table = get(table_key, st) or {}
394
+ if not table:
395
+ return False
396
+ if str(table_key) in _LOCKED_RECORD_KEYS:
397
+ return False
398
+ return table.get('recordMode') != AUTOMATION_RECORD_MODE
399
 
400
  #: The field types a user table may declare. ⚠ Kept a SUBSET of
401
  #: `aios_grid.CUSTOM_FIELD_TYPES` (gated in verify_api's W18-UT section). `created_time` stays
web/src/automation/AutomationBuilder.tsx CHANGED
@@ -613,6 +613,31 @@ export default function AutomationBuilder({
613
  if (kind === "web_read")
614
  return { url: "", selector: "", field: firstField || "",
615
  attr: "text", all: false, timeoutMs: 20000 };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
616
  /*
617
  ⭐⭐ 2026-08-07 (owner report) β€” THE ENRICH ACTION HAD NO BRANCH HERE, SO IT WAS
618
  PERMANENTLY UNCLICKABLE. `disabled={!c.ready || busy || !seedFor(c.kind)}` and this
 
613
  if (kind === "web_read")
614
  return { url: "", selector: "", field: firstField || "",
615
  attr: "text", all: false, timeoutMs: 20000 };
616
+ /*
617
+ ⭐⭐ W31 QA β€” THE OTHER FOUR WEB KINDS, and the comment above predicted this exactly one
618
+ kind early. When the owner's revocation of D-51/R5 flipped `web_goto`/`web_fill`/`web_click`/
619
+ `web_repair` to `ready:True`, the catalog-derived seed check went red with
620
+ `MISSING: ['web_click','web_fill','web_goto','web_repair']` β€” all four would have painted
621
+ faded and PERMANENTLY UNCLICKABLE while the server, the seam and the runner all offered them.
622
+ Three out of four is still an invisible feature.
623
+
624
+ ⚠ BLANK FOR THE SAME REASON `web_read` IS BLANK: `url` / `selector` / `value` are what a
625
+ person types in the panel, so seeding them with anything real would either lie or refuse
626
+ itself at validation time. `_clean_action_config` stores the unconfigured step and the RUNNER
627
+ fails closed naming what is missing (`WEB_REQUIRED`, per kind) β€” which is why these seeds
628
+ carry no field the validator would reject and no field the runner would silently ignore.
629
+ ⚠ `web_fill` seeds `secret: false` EXPLICITLY rather than omitting it: the flag decides
630
+ whether the typed value is masked in the run log, and a masking control that only exists
631
+ once somebody discovers it is a control most people never turn on.
632
+ */
633
+ if (kind === "web_goto")
634
+ return { url: "", timeoutMs: 20000 };
635
+ if (kind === "web_click")
636
+ return { url: "", selector: "", timeoutMs: 20000 };
637
+ if (kind === "web_fill")
638
+ return { url: "", selector: "", value: "", secret: false, timeoutMs: 20000 };
639
+ if (kind === "web_repair")
640
+ return { url: "", selector: "", hint: "", timeoutMs: 20000 };
641
  /*
642
  ⭐⭐ 2026-08-07 (owner report) β€” THE ENRICH ACTION HAD NO BRANCH HERE, SO IT WAS
643
  PERMANENTLY UNCLICKABLE. `disabled={!c.ready || busy || !seedFor(c.kind)}` and this