Skip to content

Commit d450258

Browse files
committed
feat(054-fix-16-test-regressions-caused-by-item-051-bytecod): Fix 16 test regressions caused by item 051 bytecode format change. wf_exec:new/1 now expects {Bytecode, MetadataMap} tuple but many callers still pass plain [opcode()] lists. The fix: make wf_exec:new/1 accept both formats — if passed a plain list, wrap it as {List, #{}} with empty metadata. This ensures backward compatibility. All 16 failures are function_clause errors in wf_exec:new/1 called from wf_case_runner and other test modules. After fixing, rebar3 eunit must show 0 failures. Also implement real loop condition evaluation: currently the loop_check opcode handler always continues without evaluating the loop policy. For {count, N} loops, track iteration count per loop scope and exit when count is reached. ACCEPTANCE TEST: Add to test/wf_acceptance_tests.erl a loop_count_test that compiles wf_term:loop({count, 3}, wf_term:task(counter, #{function => fun(Ctx) -> N = maps:get(n, Ctx, 0), {ok, Ctx#{n => N + 1}} end})). Execute it. Assert the result is {done, _} not {yield, _}. Assert final context has n => 3.
2 parents 585fd72 + 1fba0c8 commit d450258

6 files changed

Lines changed: 1169 additions & 3 deletions

File tree

.wreckit/items/051-implement-real-task-function-dispatch-in-wfexec-cu/item.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
"schema_version": 1,
33
"id": "051-implement-real-task-function-dispatch-in-wfexec-cu",
44
"title": "Implement real task function dispatch in wf_exec. Currently lookup_task_function/2 is a hardcoded mock that ignores the task name and returns fun(Ctx) -> {ok, maps:put(task_result, ok, Ctx)} end. Fix this so the executor actually calls the task function from the wf_term metadata. The compiler must propagate task metadata (the function field from task_metadata map) into the bytecode or a side-table accessible by the executor. The executor must call the real function when it encounters a task_exec opcode. ACCEPTANCE TEST: Create an escript that compiles wf_term:seq(wf_term:task(a, #{function => fun(Ctx) -> {ok, Ctx#{a_ran => true}} end}), wf_term:task(b, #{function => fun(Ctx) -> {ok, Ctx#{b_ran => true}} end})), executes it, and asserts the final context contains both a_ran and b_ran keys set to true. The test must fail with the current mock and pass after the fix. Do NOT use mocks or stubs. Write a real eunit test in test/wf_acceptance_tests.erl that verifies this.",
5-
"state": "critique",
5+
"state": "done",
66
"overview": "",
7-
"branch": null,
7+
"branch": "wreckit/051-implement-real-task-function-dispatch-in-wfexec-cu",
88
"pr_url": null,
99
"pr_number": null,
1010
"last_error": null,
1111
"created_at": "2026-02-11T23:59:37.615Z",
12-
"updated_at": "2026-02-12T00:09:25.850Z"
12+
"updated_at": "2026-02-12T00:09:28.330Z",
13+
"rollback_sha": "738a54d22a9ce4c23e8b054cafcdba3a69242725",
14+
"completed_at": "2026-02-12T00:09:28.330Z"
1315
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"schema_version": 1,
3+
"id": "054-fix-16-test-regressions-caused-by-item-051-bytecod",
4+
"title": "Fix 16 test regressions caused by item 051 bytecode format change. wf_exec:new/1 now expects {Bytecode, MetadataMap} tuple but many callers still pass plain [opcode()] lists. The fix: make wf_exec:new/1 accept both formats — if passed a plain list, wrap it as {List, #{}} with empty metadata. This ensures backward compatibility. All 16 failures are function_clause errors in wf_exec:new/1 called from wf_case_runner and other test modules. After fixing, rebar3 eunit must show 0 failures. Also implement real loop condition evaluation: currently the loop_check opcode handler always continues without evaluating the loop policy. For {count, N} loops, track iteration count per loop scope and exit when count is reached. ACCEPTANCE TEST: Add to test/wf_acceptance_tests.erl a loop_count_test that compiles wf_term:loop({count, 3}, wf_term:task(counter, #{function => fun(Ctx) -> N = maps:get(n, Ctx, 0), {ok, Ctx#{n => N + 1}} end})). Execute it. Assert the result is {done, _} not {yield, _}. Assert final context has n => 3.",
5+
"state": "critique",
6+
"overview": "",
7+
"branch": null,
8+
"pr_url": null,
9+
"pr_number": null,
10+
"last_error": null,
11+
"created_at": "2026-02-12T00:10:54.767Z",
12+
"updated_at": "2026-02-12T00:18:49.490Z"
13+
}

0 commit comments

Comments
 (0)