Skip to content

Wizard sync and folder lanes persist immediately despite deferWrite, and the express gate resets a standing folder-ask preference #883

Description

@philcunliffe

Surfaced by an automated review sweep. Structurally verified against origin/master by the reconcile loop (the call sites below all exist as described). Neither end-to-end failure has been reproduced yet; a fix owes failing-then-passing tests.

Two related defects in how the wizard's question lanes persist state. Both are asymmetries with a sibling lane that gets it right, so each fix has a working model in-tree.

1. deferWrite does not cover the lanes that write their own state (medium)

src/core/cli/wizard/index.js:476 sets deferWrite: true so the config write happens after the question lanes, on the stated grounds that "a cancel at the sync lane leaves the existing config untouched".

But those lanes are not themselves deferred:

  • runWizardSyncScope calls writeClientSyncEntries at sync_scope.js:112
  • runWizardFolderAsk calls writeFolderAskMode at folder_ask.js:135

Both fire as soon as the lane is answered. If commitWizardPickedConfig then returns { ok: false } (the user answers n to Continue? [Y/n], or --force is absent on a non-interactive commit), the wizard prints "keeping existing config at ..." and exits 1 -- while this run's local-only opt-outs and new-folder mode are already persisted to the state dir.

The user is told nothing changed while two policy stores did. Local-only opt-outs are a privacy control, so a false "nothing changed" here is worse than an ordinary state leak.

2. The express gate resets a standing ask preference (medium)

folder_ask.js:86, the auto-accept (express gate) branch, records DEFAULT_FOLDER_ASK_MODE ('sync') rather than before. The asked branch on the same file deliberately uses default: before, with the comment "a re-run defaults to the standing answer, so re-entering the wizard round-trips the preference instead of resetting it".

Concrete failure: a user sets hyp policy folders ask (or picks "Ask me about each new folder" in an earlier run), later re-runs hyp init on the same enrolled machine, and accepts the express gate. Their standing ask is overwritten with sync, and the per-folder session-start question stops firing.

The sibling lane on the same express path gets this right: sync_scope.js auto-accept returns { optedOut: [...optedOutBefore].sort() }, preserving prior state. The two lanes disagree about what "accept the default" means for an existing answer.

Acceptance

Two tests, each failing on current master:

  1. Answer the sync and folder lanes, then decline the commit confirm, and assert neither policy store changed on disk.
  2. Set the folder-ask mode to ask, run the wizard through the express gate, and assert the mode is still ask afterwards.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    neutral:fixDelegate this issue to neutral for an autonomous fix attempt (reproduce -> fix -> PR)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions