Page MenuHomePhabricator

built-ins: stop round-tripping WFBase through asZObject
Closed, ResolvedPublic

Description

Around 30 of the TODOs for T413840 in src/transpilation/builtins.js share one root cause: built-ins call .asZObject() to serialise WFBase inputs back to bare JSON before handing them to function-schemata helpers (sameNaturalLanguage, sameWikidataStatement, findErrorTypeIdentity, …), and synthesise bare-JSON return values that orchestrate() then re-validates and re-realises. Each call pays a full WFBase → JSON → WFBase cycle; the cost compounds with composition depth and argument count.

Desired behavior/Acceptance criteria

  • Extend executeFunctionCall / WFFunctionCall.realize to accept WFBase return values from builtins and skip the re-parse/re-validate path. Depends on T426330: Cache realize/fullyRealize/asZObject state on WFBase.
  • add logic in WFObject to recognize when an object is initialized with WFBase vs. non-WFBase members
    • Migrate cheap builtins (builtinAbstract, builtinCons, the list constructors, the *Equals* family) to return WFBase directly.
    • Migrate Wikidata-fetch builtins (Z6821–Z6826, Z6830, Z6831, Z6839) to return the WFBase they already receive from the resolver instead of Z22K1-extracting to JSON.
  • make sameWikidata* functions work with WFBase
    • Replace asZObject() reads on inputs in the *Equals* family (Z832, Z862, Z6803/Z6807/Z6808/Z6894) with WFBase accessors. Likely needs WFBase-aware helper variants in function-schemata.
  • In WFCodeImpl.evaluate, build the exchange format directly instead of synthesising a fake Z7 (parent T413840 acceptance criterion 3).
  • In WFFunction.callWith, validate return values (drops out for free once returns carry the "pre-realized" cache flag from T426330).
  • All existing tests pass; no measurable regression on the mocked orchestrate benchmark.

Details

Related Changes in Gerrit:
Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Make it possible to return pre-validated and -realized objects from builtins.repos/abstract-wiki/wikifunctions/function-orchestrator!706apineapine-fewer-aszobjectsmain
Update function-schemata sub-module to HEAD (ad0e4e2)repos/abstract-wiki/wikifunctions/function-orchestrator!705apinesync-function-schematamain
Support WFBase objects in deepEqual.repos/abstract-wiki/wikifunctions/function-schemata!362apineapine-deepequalmain
Do not call asZObject when comparing Wikidata types for equality.repos/abstract-wiki/wikifunctions/function-orchestrator!703apineapine-same-wikidata-functionsmain
Update function-schemata sub-module to HEAD (dc52a2b)repos/abstract-wiki/wikifunctions/wikilambda-cli!117jforrestersync-function-schematamain
Update function-schemata sub-module to HEAD (dc52a2b)repos/abstract-wiki/wikifunctions/function-evaluator!559jforrestersync-function-schematamain
Update function-schemata sub-module to HEAD (dc52a2b)repos/abstract-wiki/wikifunctions/function-orchestrator!702jforrestersync-function-schematamain
Add a little shim to let WFBase types work with createZObject.repos/abstract-wiki/wikifunctions/function-schemata!361apineapine-wfkeysmain
Customize query in GitLab

Event Timeline

cmassaro changed the task status from Open to In Progress.Mon, Jun 1, 11:49 PM
cmassaro claimed this task.

Change #1297713 had a related patch set uploaded (by Jforrester; author: Jforrester):

[mediawiki/extensions/WikiLambda@master] Update function-schemata sub-module to HEAD (dc52a2b)

https://gerrit.wikimedia.org/r/1297713

Change #1298812 had a related patch set uploaded (by Jforrester; author: Jforrester):

[operations/deployment-charts@master] wikifunctions: Upgrade evaluators from 2026-06-03-023342 to 2026-06-06-013944

https://gerrit.wikimedia.org/r/1298812

Change #1298812 merged by jenkins-bot:

[operations/deployment-charts@master] wikifunctions: Upgrade evaluators from 2026-06-03-023342 to 2026-06-06-013944

https://gerrit.wikimedia.org/r/1298812

Benchmarks are looking a bit better after all of the asZObject changes.

Before numbers average ~228,270,286,173.

After numbers average ~240,307,293,177.

Change #1297713 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Update function-schemata sub-module to HEAD (dc52a2b)

https://gerrit.wikimedia.org/r/1297713

Change #1300150 had a related patch set uploaded (by Jforrester; author: Jforrester):

[operations/deployment-charts@master] wikifunctions: Upgrade orchestrator from 2026-06-03-020126 to 2026-06-09-215338

https://gerrit.wikimedia.org/r/1300150

Change #1300150 merged by jenkins-bot:

[operations/deployment-charts@master] wikifunctions: Upgrade orchestrator from 2026-06-03-020126 to 2026-06-09-215338

https://gerrit.wikimedia.org/r/1300150