@@ -103,7 +103,7 @@ def _iso_z(dt: datetime) -> str:
103103
104104 Normalises through ``astimezone(timezone.utc)`` so a datetime with any
105105 UTC offset (``+00:00``, ``+05:30``, ``-08:00``) emits the same canonical
106- string for the same wall-clock instant. The wildcard server's Pydantic
106+ string for the same wall-clock instant. The predict-api server's Pydantic
107107 ``AwareDatetime`` round-trips through ``model_dump(mode="json")`` which
108108 emits ``...Z`` for UTC; the mech's ``batch_hash`` recompute on the
109109 server side compares byte-for-byte against ours, so leaving the offset
@@ -127,10 +127,10 @@ def _iso_z(dt: datetime) -> str:
127127
128128
129129# Cap on the JSON-serialised size of each ``raw_content`` blob attached to
130- # a wildcard event. The blob rides Tendermint consensus replication into
130+ # a predict-api event. The blob rides Tendermint consensus replication into
131131# ``synchronized_data`` on every agent and the field is requester-influenced
132132# (``params``, ``model``, response body), so an uncapped large payload would
133- # inflate per-node state. 256 KiB matches the wildcard server's ``_MAX_TEXT``
133+ # inflate per-node state. 256 KiB matches the predict-api server's ``_MAX_TEXT``
134134# cap on individual TEXT columns; the analytics ETL drops the row to a
135135# truncated sentinel when the cap is hit so the rest of the event still
136136# lands.
@@ -1533,30 +1533,35 @@ def _finalize_done_task(self, cid: str) -> None:
15331533 # pop the data key value as it's bytes which causes issues
15341534 # with json dumps and not required anywhere
15351535 done_task .pop ("data" , None )
1536- # Attach the offchain wildcard- event payload before the
1536+ # Attach the offchain predict-api event payload before the
15371537 # IN_MEMORY_REQUESTS pop below; the post-settlement behaviour in
15381538 # task_submission_abci reads it off ``synchronized_data.done_tasks``
1539- # (i.e. after consensus replication) and posts it to the wildcard
1539+ # (i.e. after consensus replication) and posts it to the predict-api
15401540 # data lake, but the buffered request metadata it needs is local
15411541 # to this agent's shared_state and goes away at the pop.
15421542 #
1543- # Gated on BOTH ``is_offchain`` AND the ``mech_events_enabled`` flag
1544- # so Phase 1 is genuinely dark: when the flag is off, no payload is
1545- # built and nothing rides Tendermint consensus replication. The flag
1546- # check lives here as well as in the post-settlement behaviour so
1547- # the consensus-state cost is gated, not just the HTTP write.
1548- # Build the wildcard event for both off-chain HTTP deliveries
1549- # (is_offchain=True) and on-chain marketplace deliveries
1550- # (is_offchain=False AND is_marketplace_mech). The ``source`` field
1551- # on the event (set by ``_build_wildcard_event``) is what
1552- # disambiguates the two paths on the wildcard side: ``mech_offchain``
1553- # for the paid HTTP path, ``mech_onchain`` for the on-chain rails.
1554- # See ``autonolas-marketplace/docs/onchain_write_path_scope.md`` for
1543+ # Gate the whole event build on ``use_offchain``. When the flag
1544+ # is off, no payload is built and nothing rides Tendermint
1545+ # consensus replication — so the ingress-side consensus cost
1546+ # matches the egress-side HTTP write cost (nothing on either
1547+ # side). The paired gate in
1548+ # :py:meth:`task_submission_abci.behaviours.PostTxSettlementBehaviour._do_predict_api_write_best_effort`
1549+ # additionally warns if it receives events under a locally-off
1550+ # flag, so a config drift between the two skill copies of
1551+ # ``use_offchain`` is alertable rather than silent.
1552+ # Build the event for both off-chain HTTP deliveries
1553+ # (``is_offchain=True``) and on-chain marketplace deliveries
1554+ # (``is_offchain=False`` AND ``is_marketplace_delivery=True``).
1555+ # The ``source`` field on the event (set by
1556+ # ``_build_predict_api_event``) disambiguates the two paths on
1557+ # the predict-api side: ``mech_offchain`` for the paid HTTP path,
1558+ # ``mech_onchain`` for the on-chain rails. See
1559+ # ``autonolas-marketplace/docs/onchain_write_path_scope.md`` for
15551560 # the agreed shape.
1556- wildcard_mode_enabled = getattr ( self .params , "mech_events_enabled" , False )
1561+ predict_api_mode_enabled = self .params . use_offchain
15571562 is_marketplace_delivery = bool (done_task .get ("is_marketplace_mech" ))
1558- if wildcard_mode_enabled and (is_offchain or is_marketplace_delivery ):
1559- done_task ["wildcard_event " ] = self ._build_wildcard_event (
1563+ if predict_api_mode_enabled and (is_offchain or is_marketplace_delivery ):
1564+ done_task ["predict_api_event " ] = self ._build_predict_api_event (
15601565 done_task = done_task ,
15611566 cid = cid ,
15621567 executing_task = cast (Dict [str , Any ], executing_task ),
@@ -1571,29 +1576,29 @@ def _finalize_done_task(self, cid: str) -> None:
15711576 self .context .shared_state .get (IN_MEMORY_REQUESTS , {}).pop (req_id , None )
15721577 self ._reset_executing_task ()
15731578
1574- def _build_wildcard_event (
1579+ def _build_predict_api_event (
15751580 self ,
15761581 * ,
15771582 done_task : Dict [str , Any ],
15781583 cid : str ,
15791584 executing_task : Dict [str , Any ],
15801585 ) -> Dict [str , Any ]:
1581- """Build the structured wildcard- event payload from on-hand data.
1586+ """Build the structured predict-api event payload from on-hand data.
15821587
15831588 The post-settlement behaviour batches every event from one FSM round
1584- into a single signed POST to the wildcard data lake. Fields are
1589+ into a single signed POST to the predict-api data lake. Fields are
15851590 populated best-effort from the buffered request metadata
15861591 (``IN_MEMORY_REQUESTS``), the offchain response
15871592 (``OFFCHAIN_REQUEST_RESPONSES``), the in-flight ``executing_task``,
15881593 and skill params. Optional fields that aren't readily available are
1589- left ``None``; the wildcard server accepts a NULL there. Required
1594+ left ``None``; the predict-api server accepts a NULL there. Required
15901595 fields default to safe placeholders rather than blocking the row: a
1591- malformed event surfaces as a 422 when the wildcard write fires (and
1596+ malformed event surfaces as a 422 when the predict-api write fires (and
15921597 lands in the local replay buffer so it's recoverable), which is
15931598 preferable to silently dropping analytics data.
15941599
15951600 Datetimes are emitted as ISO 8601 strings with UTC offset so the
1596- wildcard ``AwareDatetime`` parser accepts them; mech ints (Unix
1601+ predict-api ``AwareDatetime`` parser accepts them; mech ints (Unix
15971602 seconds) are converted here so the structured event can ride the
15981603 FSM consensus channel without round-tripping through a custom
15991604 codec.
@@ -1654,15 +1659,15 @@ def _build_wildcard_event(
16541659 delivery_mech = str (
16551660 done_task .get ("mech_address" ) or self .params .mech_marketplace_address or ""
16561661 )
1657- # Wildcard ``source`` derives from the per-task ``is_offchain``
1662+ # The predict-api ``source`` derives from the per-task ``is_offchain``
16581663 # flag: True → ``mech_offchain`` (paid HTTP path); False →
16591664 # ``mech_onchain`` (the on-chain marketplace rails). This is the
1660- # only field that disambiguates the two paths on the wildcard
1665+ # only field that disambiguates the two paths on the predict-api
16611666 # side; the per-row ``is_offchain`` boolean stays on the
16621667 # response payload as well (the lake keeps both because the
16631668 # ipfs_historical backfill describes either path).
16641669 is_offchain_task = bool (executing_task .get ("is_offchain" , False ))
1665- wildcard_source = "mech_offchain" if is_offchain_task else "mech_onchain"
1670+ predict_api_source = "mech_offchain" if is_offchain_task else "mech_onchain"
16661671
16671672 # `start_time` is a perf_counter() value (monotonic, not wall-clock),
16681673 # not suitable as a delivered_at timestamp. Use the current wall-clock
@@ -1698,7 +1703,7 @@ def _build_wildcard_event(
16981703 # the executed_at on the response so the time-leading index entry is
16991704 # always populated for an offchain row. The requester can store the
17001705 # value as a Unix int or as an ISO 8601 string — ``str(int)`` would
1701- # produce ``"1700000000"`` which the wildcard 's ``AwareDatetime``
1706+ # produce ``"1700000000"`` which the predict-api 's ``AwareDatetime``
17021707 # parser rejects with a 422, so coerce int / float explicitly.
17031708 requested_at_raw = request_data .get ("datetime" ) or request_data .get (
17041709 "requested_at"
@@ -1772,7 +1777,7 @@ def _build_wildcard_event(
17721777 nonce_int = int (nonce_raw ) if nonce_raw is not None else None
17731778 except (TypeError , ValueError ):
17741779 nonce_int = None
1775- # The wildcard server requires ``prompt`` to be a non-empty string;
1780+ # The predict-api server requires ``prompt`` to be a non-empty string;
17761781 # placeholder rather than dropping the row. Enforce the cap on the
17771782 # UTF-8 BYTE length, not on ``len()`` (code points) — a CJK prompt
17781783 # of 50k code points encodes to ~150 KB and would otherwise sail
@@ -1788,11 +1793,11 @@ def _build_wildcard_event(
17881793 # Failed-row ``error`` carries the available diagnostic, regardless
17891794 # of which branch put us on the failed arm. When ``invalid`` is set
17901795 # but no ``result_text`` is available (the tool produced no
1791- # response object), the field is ``None``; the wildcard server's
1796+ # response object), the field is ``None``; the predict-api server's
17921797 # CHECK allows a ``failed`` row with empty error so the row still
17931798 # lands as a settled failure.
17941799 error_text = str (result_text ) if status == "failed" and result_text else None
1795- # Strip the result from the failed arm so the wildcard 's
1800+ # Strip the result from the failed arm so the predict-api 's
17961801 # status/error/result shape CHECK accepts the row.
17971802 result_value : Optional [str ] = (
17981803 None if status == "failed" else (str (result_text ) if result_text else "" )
@@ -1819,7 +1824,7 @@ def _build_wildcard_event(
18191824 # which keys the requester as ``requester`` and carries no
18201825 # ``sender`` field. This block now runs for on-chain
18211826 # marketplace deliveries too, so falling back to
1822- # ``requester`` keeps the wildcard row correctly populated
1827+ # ``requester`` keeps the predict-api row correctly populated
18231828 # instead of writing an empty ``requester``.
18241829 "requester" : str (
18251830 executing_task .get ("sender" )
@@ -1878,7 +1883,7 @@ def _build_wildcard_event(
18781883 "response_cid" : None ,
18791884 "delivered_at" : now_iso ,
18801885 },
1881- "source" : wildcard_source ,
1886+ "source" : predict_api_source ,
18821887 }
18831888
18841889 def _reset_executing_task (self ) -> None :
0 commit comments