feat(workflow-utils): add withDryRun role wrapper #255

Merged
scottwei merged 3 commits from feat/254-with-dry-run into main 2026-04-29 13:28:23 +00:00
Owner

Extracts repeated dry-run skip + try/catch error handling into withDryRun(role, { label, dryRunMeta, failMeta }).

4 tests added, all passing.

Closes #254

Extracts repeated dry-run skip + try/catch error handling into `withDryRun(role, { label, dryRunMeta, failMeta })`. 4 tests added, all passing. Closes #254
xiaoju added 1 commit 2026-04-29 13:00:23 +00:00
Extracts repeated dry-run skip + try/catch error handling into a
reusable wrapper. Includes tests.

Closes #254
scottwei requested changes 2026-04-29 13:09:43 +00:00
@@ -0,0 +8,4 @@
/** Meta returned when dry-run skips execution. */
dryRunMeta: M;
/** Meta returned when the inner role throws. */
failMeta: M;

failMeta 应该不是 withDryRun 考虑的,或许应该是另外一个decorator。
或许我们是不是应该搞个 decorator chain, e.g.

decorateRole(role, [
  withDryRun(dryRunOpts),
  onFail(failOpts),
]);
failMeta 应该不是 withDryRun 考虑的,或许应该是另外一个decorator。 或许我们是不是应该搞个 decorator chain, e.g. ``` decorateRole(role, [ withDryRun(dryRunOpts), onFail(failOpts), ]); ```
xiaoju added 1 commit 2026-04-29 13:23:44 +00:00
- withDryRun(opts) — only handles dry-run skip
- onFail(opts) — only handles try/catch error wrapping
- decorateRole(role, [...]) — composes decorators left-to-right
- RoleDecorator<M> type for custom decorators

Addresses review feedback on #255
scottwei requested changes 2026-04-29 13:25:53 +00:00
@@ -0,0 +1,168 @@
# RFC-004: Package Architecture — Shareable Workflows, Roles & Senses

这个应该是另一个 PR 吧?

这个应该是另一个 PR 吧?
@@ -0,0 +65,4 @@
// onFail — catch errors and return a structured failure result
// ---------------------------------------------------------------------------
export type OnFailOptions<M> = {

如果这样,这个文件还叫 with-dry-run 就不太合适了。

如果这样,这个文件还叫 with-dry-run 就不太合适了。
xiaoju added 1 commit 2026-04-29 13:27:13 +00:00
scottwei merged commit 554933d43b into main 2026-04-29 13:28:23 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
2 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#255