Skip to content

chore(cli): deprecate dfx replica in mops bench, mops test, mops watch#555

Merged
Kamirus merged 10 commits into
mainfrom
chore/deprecate-dfx-replica-in-bench
Jun 3, 2026
Merged

chore(cli): deprecate dfx replica in mops bench, mops test, mops watch#555
Kamirus merged 10 commits into
mainfrom
chore/deprecate-dfx-replica-in-bench

Conversation

@Kamirus

@Kamirus Kamirus commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Why

dfx is being deprecated upstream, and for benchmarks and replica tests specifically PocketIC is the better fit anyway — it's deterministic, in-process, and doesn't need a separate background daemon. mops already prefers pocket-ic over dfx when both are configured; this PR starts steering the remaining users off the dfx path across all three commands that use a replica.

What changes for users

A yellow warning now prints when mops bench, mops test --mode replica, or mops watch resolves to a dfx-backed replica. Three variants:

You did Warning
--replica dfx --replica dfx is deprecated and will be removed in a future release.
no --replica, no pocket-ic in [toolchain] Using dfx replica because no pocket-ic version is set in [toolchain]. The dfx replica is deprecated…
--replica pocket-ic, no [toolchain.pocket-ic], dfx ≥ 0.24.1 on PATH (falls back to dfx-bundled PocketIC) Falling back to dfx-bundled PocketIC because no pocket-ic version is set in [toolchain]. This fallback is deprecated…

Each warning ends with: Run `mops toolchain use pocket-ic` to pin a PocketIC version and silence this warning.

--help for both mops bench --replica and mops test --replica reads Which replica to use… (\`dfx\` is deprecated; prefer \`pocket-ic\`). Docs pages for both commands call out the deprecation explicitly.

For mops watch the warning fires once per watch session (not on every recompute).

Behavior is otherwise unchanged. --replica dfx still works, defaults still resolve the same way, the dfx-pocket-ic fallback still falls back. Removal lands in mops v3.

Removal plan

Added under NEXT-MAJOR.md → "Drop dfx coupling":

Remove the dfx and dfx-pocket-ic replica paths from mops bench, mops test --mode replica, and mops watch. Drop the dfx choice from --replica; drop the implicit dfx/dfx-pocket-ic fallback when [toolchain.pocket-ic] is unset. Flip the default so an unpinned pocket-ic auto-resolves to a mops-controlled DEFAULT_POCKET_IC_VERSION (download-on-demand), so users never need to know dfx exists. User-visible break: implicit-dfx benchmark baselines drift on first run because PocketIC and dfx-replica report different instruction/heap counts; call out in release notes and recommend re-recording with --save.

Pocket-ic compatibility note (out of scope here)

While verifying I confirmed mops works with PocketIC 9.x — 12.0.0. PocketIC 13.0.0 fails (pic-js-mops@0.14.8 doesn't send the new cloud_engine field). Bumping pic-js-mops is tracked separately — this PR is scoped to the dfx deprecation.

Test plan

  • mops bench --replica dfx → explicit-dfx warning
  • mops bench with no [toolchain.pocket-ic] → default-fallback warning
  • mops bench --replica pocket-ic with no [toolchain.pocket-ic] → dfx-pocket-ic fallback warning
  • mops bench with pocket-ic = "12.0.0" → no warning, bench runs
  • mops test --mode replica --replica dfx → explicit-dfx warning
  • mops test --mode replica with no [toolchain.pocket-ic] → default-fallback warning
  • mops test --mode replica --replica pocket-ic with no [toolchain.pocket-ic] → dfx-pocket-ic fallback warning
  • mops test --mode replica with pocket-ic = "12.0.0" → no warning, tests pass
  • npm run check passes (tsc + svelte-check)
  • Watch warning manually exercised (one-shot per session) — code-inspected; not in automated suite

dfx itself is being deprecated and PocketIC is the better fit for
benchmarks (deterministic, in-process, no background daemon). Print a
yellow warning when `mops bench` resolves to `dfx` or to the
`dfx-pocket-ic` fallback, and call out the deprecation in `--help` and
the docs. Behavior is unchanged for now; the `dfx` replica will be
removed in a future release.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Kamirus Kamirus requested a review from a team as a code owner May 27, 2026 12:17
@github-actions

github-actions Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Cursor AI review

👍 APPROVE — looks safe to merge

Category Assessment Details
Summary Adds one-shot yellow deprecation warnings when mops bench, replica-mode mops test, or mops watch resolve to dfx or dfx-pocket-ic; updates help text, docs, changelog, skills, and NEXT-MAJOR.md. Runtime replica selection is unchanged.
Code Quality Shared warnIfDfxReplica helper; publish no longer passes replica: "dfx" so warnings use the correct implicit-fallback message instead of a false explicit---replica variant.
Consistency Matches existing chalk warning patterns; --help, docs, changelog, and skill updated together.
Security No auth, signing, or registry changes.
Tests ⚠️ No automated assertions for the three warning variants; manual checklist in PR body. Acceptable given no existing bench/test CLI Jest coverage, but regressions in warning text would not be caught in CI.
Maintainability Removal tracked in NEXT-MAJOR.md; alreadyWarned gives once-per-process semantics for watch debounces.

Verdict

Decision: APPROVE
Risk: Low
Reason: Deprecation warnings only; replica resolution and command behavior are unchanged. Docs/changelog/skills are in sync, and the publish bench call change correctly avoids mislabeling the warning as an explicit --replica dfx choice.


Generated for commit 88a700b

… removal in NEXT-MAJOR

- Extract the warning into a shared `helpers/deprecate-dfx-replica.ts`
  and wire it through `mops bench`, `mops test --mode replica`, and
  `mops watch` (one-shot per watch session).
- Recommend `mops toolchain use pocket-ic` in the warning text and docs,
  matching the existing wasmtime hint pattern in `test.ts`.
- Annotate `mops test --replica`'s `--help` with the deprecation note,
  mirroring what `mops bench --replica` already says.
- Add a NEXT-MAJOR.md item under "Drop dfx coupling" to remove the dfx
  replica paths entirely and flip the default to a mops-pinned
  PocketIC version. Calls out the bench-baseline drift for release notes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Kamirus Kamirus changed the title chore(cli): deprecate --replica dfx in mops bench chore(cli): deprecate dfx replica in mops bench, mops test, mops watch May 27, 2026
Kamirus and others added 8 commits May 27, 2026 14:43
`mops toolchain use pocket-ic` (no version) calls `promptVersion`,
which is interactive and hangs agents / non-TTY callers. Pin a known-
good version in the hint (`mops toolchain use pocket-ic 12.0.0`) so
the command is copy-pasteable in both human shells and agent loops.

`latest` would self-update but currently resolves to 13.0.0, which
the shipped `pic-js-mops@0.14.8` does not support (missing
`cloud_engine` in `subnet_config_set`), so an explicit pin is the
right answer until `pic-js-mops` is bumped.

Same interactive-hint footgun exists for the wasmtime warning in
`cli/commands/test/test.ts:281`; left for a follow-up since it
predates this PR.

Co-authored-by: Cursor <cursoragent@cursor.com>
…e forms

Surfaces a catalogue of commands that prompt for input (and hang in
non-TTY agent loops) and the flag/argument form that bypasses each
prompt. Triggered by the dfx-replica deprecation hint in this PR —
`mops toolchain use pocket-ic` (no version) hits a `promptVersion`
call and traps agents.

Also adds guidance for future commands: prefer non-interactive
defaults, and recommend the explicit form in any hint text.

Co-authored-by: Cursor <cursoragent@cursor.com>
…eplica-in-bench

# Conflicts:
#	cli/CHANGELOG.md
Drop `mops user import` row and the encrypted-identity paragraph
(security: don't suggest unencrypted PEMs). Tighten intro and the
template/toolchain cells.
`mops publish --bench` passed `replica: "dfx"` programmatically when
no `[toolchain.pocket-ic]` was set. The deprecation warning treats
that as a user-supplied `--replica dfx` flag and prints the wrong
lead message.

Drop the explicit `replica` field — `bench` does the same toolchain
lookup internally, so the duplicated resolution becomes unreachable
and the correct "Using `dfx` because no `pocket-ic` set" warning
fires.
The previous unconditional `warnIfDfxReplica` at the top of `test()`
fired even when no test would run in replica mode (interpreter-only
or wasi-only projects without `[toolchain.pocket-ic]`). Move the
call inside `testWithReporter`, gated on `hasReplicaTests`, so the
warning only fires when at least one test file is detected as actor
or `// @Testmode replica`.

Add a module-level `alreadyWarned` flag so `mops watch` (which calls
`testWithReporter` on every recompute) prints the warning at most
once per process. Drop the now-redundant `warnedDfx` field and
explicit call from `watch/tester.ts`.

Plumb `explicitReplica` through `runAll`/`testWithReporter` so the
"`--replica dfx`" lead message still fires when the user actually
passed the flag.

Bug surfaced by AI review on the prior commit.
AI review flagged that the dfx-replica deprecation warning is hooked
up in code but not surfaced in the two places agents/users discover
it: the `.agents/skills/mops-cli/SKILL.md` skill and the `mops watch`
docs page.

- SKILL.md: extend the "No dfx" principle to recommend pinning
  `pocket-ic`, add the pin to the minimal `[toolchain]` block, list
  `mops toolchain use pocket-ic 12.0.0` in the toolchain command
  cheatsheet, and add a short replica/deprecation note under
  `mops test`.
- `mops watch` docs: add an info admonition under `--test` mirroring
  the test/bench pages, so users reading the watch docs learn about
  the deprecation and the one-line remediation.

No code change. The hardcoded `12.0.0` in the warning text is
intentional (see PR #555 / commit 3ed9624: `latest` currently
resolves to 13.0.0 which the shipped `pic-js-mops@0.14.8` doesn't
support) and is already documented in AGENTS.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Kamirus Kamirus enabled auto-merge (squash) June 3, 2026 15:12
@Kamirus Kamirus merged commit b824ff1 into main Jun 3, 2026
26 checks passed
@Kamirus Kamirus deleted the chore/deprecate-dfx-replica-in-bench branch June 3, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant