Skip to content

fix(dashmate): guide recovery from a dashmate helper that is older than the config - #6304

Draft
shumkov wants to merge 11 commits into
v5.2-devfrom
dashmate-outdated-helper-guidance
Draft

shumkov wants to merge 11 commits into
v5.2-devfrom
dashmate-outdated-helper-guidance

Conversation

@shumkov

@shumkov shumkov commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

Paused. This needs a design for certificate guidance with an outdated dashmate helper before it can be finished.

Since #6301, a dashmate helper older than the dashmate that last saved config.json refuses to renew certificates rather than overwrite the newer config. #6301 records that refusal without a cause, so doctor names no cause and prints no repair. This PR carries the guidance that was split out of #6301: a dedicated HELPER_OUTDATED renewal failure code, plus doctor and update advice for recovering from it.

That advice currently tells the operator to restart the node. Review found cases where the restart is unsafe or cannot finish (listed below). Fixing them needs:

  • a way to replace only the helper without reloading the gateway;
  • detection of the running helper's version, independent of the renewal record;
  • node-wide state in the update guidance.

Stacked on #6301 (base branch dashmate-newer-config-guard).

What was done?

Re-applies two commits:

  • c1afc945f0 (re-applied from 8b8e186987, which fix(dashmate): refuse to overwrite a config a newer dashmate migrated #6301 reverts): the HELPER_OUTDATED code with a RESTART_NODE remedy, plus doctor and update endings that tell the operator to restart the node.
  • f529900e7d (from 069f90f6e7): doctor makes that restart conditional when the served sample shows a different disk pair that is not a verified replacement.

Requirements before this can be finished

These are the open review findings from #6301:

  1. A restart can take a working TLS gateway offline. A restart reloads the gateway from the files on disk. The installed-certificate check validates the leaf and key but not the chain, and the served-vs-disk comparison compares leaf fingerprints only. So a disk pair whose chain is incomplete can pass both checks while Envoy serves a good pair from memory. The same advice must not appear in the helper's startup warning or its renewal log.
  2. A repair through update hides the outdated helper. Installing a certificate removes the renewal record, so neither update nor doctor still reports that the running helper will refuse the next renewal. update also returns without reading the record when the certificate passes. The outdated helper needs reporting separately from certificate state, including after a manual repair.
  3. Guidance for a stopped gateway with Core still running. update decides "node running" from the gateway alone. Plain dashmate start is refused while Core runs, and ssl obtain does not reload a stopped gateway. The recovery command has to come from node-wide Compose state and follow the certificate repair.
  4. Doctor on an older dashmate prints repair commands that the same binary refuses (ssl obtain, config set). It should state first that the commands must run with the newer dashmate.
  5. Check the disk certificate before recommending a restart. f529900e7d covers the leaf-mismatch case. Requirement 1 covers the case this does not reach.

How Has This Been Tested?

The full dashmate unit suite (yarn mocha --recursive test/unit) passes on this branch: 1204 passing. Nothing beyond the re-applied commits' own tests has been added for the requirements above.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions (not applicable: JavaScript only)
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any (not applicable)
  • I have made corresponding changes to the documentation if needed (not applicable)
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request (not applicable)
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request (not applicable)

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

Deferred from #6301

  • update shows the recorded newer-config refusal next to the possible-issuance warning while the installed certificate still works, and points to the local dashmate doctor check (thread).
  • The renewal caller marks where the provider task starts, so a refusal during preflight (for example the readAndMigrate() save) is not recorded as possible issuance; an issuance marker from an earlier attempt is kept (thread).

shumkov and others added 9 commits November 26, 2026 00:53
Migration only runs forward, so an older dashmate reads a config.json a
newer one has already stamped without migrating it, and its in-memory
copy keeps the newer stamp. Saving it then writes the older build's
state under that stamp, and every save is followed by rendering all
service files from the older templates. The newer build never migrates
the file again. The usual trigger is the dashmate-helper container: its
image is pinned to the CLI that started it, so after a manual CLI
upgrade without a restart its certificate renewal does exactly this.

ConfigFileJsonRepository now refuses, under the lock, any write over a
file whose configFormatVersion is newer than the format this build
produces:
- in #save, the one point every write path goes through;
- in acquire(), so a renewal or a lock-holding command stops before its
  long work (no certificate issuance is spent first) and the lock is
  released;
- in update(), before reading, so the refusal is not hidden behind a
  schema error for a newer shape.

readAndMigrate() treats a newer file as read-only: the unlocked probe no
longer reports a stock-seed refresh as due, and the locked re-read
returns without rendering when a newer build migrated the file while
this one waited for the lock. Reads are otherwise unchanged, so an
older build can still report. A missing file, an unreadable one or a
stamp that is not semver is left to the existing read path.

The helper's renewal loop already catches the error, logs it and
retries in an hour, so it neither crashes nor spins.

Tests would have caught this: 12 failing on the unfixed repository
(older write/update/acquire accepted, seed refresh rendered, the race
rendered, prerelease order cases, helper renewal went on to issuance),
63 passing after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…is outdated

A dashmate helper older than the dashmate that last saved config.json
now refuses to renew rather than overwrite the newer settings. Its
renewal record classified that refusal as UNKNOWN, so doctor said
dashmate could not work out why, sent the operator to support and
withheld `ssl obtain`. The cause is known and a restart fixes it.

A refusal made when the renewal takes the lock, before it does any
work, is now recorded as HELPER_OUTDATED with a RESTART_NODE remedy. The
same error met at a later save can only follow a lock taken over
mid-renewal, when a certificate may already have been issued, so it is
recorded as RESULT_UNKNOWN and keeps the request withheld.

- doctor tells the operator to restart the node with the dashmate that
  last updated its configuration (or start it if it is stopped) and
  says renewal resumes by itself; it names that dashmate rather than
  "this version" because the dashmate reading the record may itself be
  the outdated one;
- with a broken certificate doctor gives the obtain command first and
  the restart after it, because a restart makes the gateway reload
  whatever pair is on disk;
- while an earlier attempt's issuance marker withholds the request, the
  restart is still given, conditional on the certificate files on disk
  working: an outdated helper never succeeds, so the marker would
  otherwise hide the only fix for good;
- the update command's certificate guidance adds the restart after its
  existing repair, and leaves it out for a stopped node, which it
  already tells to start;
- safe-action derivation treats it like WAIT: wait for the fix while the
  certificate works, obtain after it once it does not.

The record is written by the helper and read by the CLI, and both get
the code in this release, so a helper that can refuse always has a
reader that knows the code.

Tests would have caught this: 11 failing before (classifier gave
UNKNOWN, doctor and update gave no restart, derivation sent the
operator to support, no refusal was marked as made before any work),
263 passing in the touched specs after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he helper

A host or Docker restart brings the dashmate-helper container back with
the image it was created from, which can be older than the CLI that has
since saved config.json. Its certificate renewal then refuses to save
over the newer config, but only says so when a certificate is due,
which can be days later. On a node that renews certificates (SSL
enabled with ZeroSSL or Let's Encrypt), the helper now logs one warning
at startup naming both config formats and the restart command for its
config.

No test: scripts/helper.js is the container entry point and has no unit
harness, and the change only logs. The refusal it warns about is
covered by the repository and renewCertificate tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit 8b8e186 ("fix(dashmate): tell doctor and update
to restart a node whose helper is outdated").

Advising a restart safely for an outdated helper needs more than this
PR provides: a way to replace only the helper without reloading the
gateway, detection of the running helper's version independently of
the renewal record, and node-wide state in the update guidance. That
work moves to a follow-up PR.

Until then, a renewal refused by an outdated helper is recorded as
UNKNOWN again. Doctor names no cause for it, withholds `ssl obtain`
and points to support, and prints no restart command. The refusal
itself, and the reason for it, stay in the helper's log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… a restart

The refusal message and the helper's startup warning told the operator
to run `dashmate restart`. A restart reloads the gateway from the
certificate files on disk, and nothing on these paths has checked that
those files form a working pair with a complete chain, so following the
advice could take a gateway that still serves a good certificate from
memory offline.

Both messages now only state what happened: the two config formats,
that nothing was saved, that the helper runs the version that started
the node, and that downgrading is unsupported. The refusal still names
the newer dashmate and how to find every copy on PATH. Safe recovery
advice for an outdated helper is designed in a follow-up PR.

Test: the refusal-message test now asserts no restart is advised; it
fails against the previous message and passes with this one. The
helper warning has no unit harness and only logs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An older dashmate reading a config a newer one migrated may not save
it, but #buildConfigFile still swapped in its own replacement for stock
seeds it considered obsolete. `config get --raw` and every other
reader of the stored options then reported seeds the file does not
hold.

Seed substitution is skipped when the file records a newer format than
this build produces, so an older build reports the file as saved.

Test would have caught this: the older-build seed tests now assert the
stored seeds and a clean read; both (mainnet, testnet) fail before the
fix and pass after. Full dashmate unit suite: 1189 passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… seed refresh for older files

The helper test now asserts that a renewal refused by an outdated
helper is classified UNKNOWN, so restoring a cause, and with it a
prescribed repair, fails a test until a safe one exists.

The seed refresh skip is for files a newer build owns. New positive
cases keep the refresh for an older stamp, a stamp that is not semver,
and a repository with no format version of its own.

Test-only change; no behaviour changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…is outdated

A dashmate helper older than the dashmate that last saved config.json
now refuses to renew rather than overwrite the newer settings. Its
renewal record classified that refusal as UNKNOWN, so doctor said
dashmate could not work out why, sent the operator to support and
withheld `ssl obtain`. The cause is known and a restart fixes it.

A refusal made when the renewal takes the lock, before it does any
work, is now recorded as HELPER_OUTDATED with a RESTART_NODE remedy. The
same error met at a later save can only follow a lock taken over
mid-renewal, when a certificate may already have been issued, so it is
recorded as RESULT_UNKNOWN and keeps the request withheld.

- doctor tells the operator to restart the node with the dashmate that
  last updated its configuration (or start it if it is stopped) and
  says renewal resumes by itself; it names that dashmate rather than
  "this version" because the dashmate reading the record may itself be
  the outdated one;
- with a broken certificate doctor gives the obtain command first and
  the restart after it, because a restart makes the gateway reload
  whatever pair is on disk;
- while an earlier attempt's issuance marker withholds the request, the
  restart is still given, conditional on the certificate files on disk
  working: an outdated helper never succeeds, so the marker would
  otherwise hide the only fix for good;
- the update command's certificate guidance adds the restart after its
  existing repair, and leaves it out for a stopped node, which it
  already tells to start;
- safe-action derivation treats it like WAIT: wait for the fix while the
  certificate works, obtain after it once it does not.

The record is written by the helper and read by the CLI, and both get
the code in this release, so a helper that can refuse always has a
reader that knows the code.

Tests would have caught this: 11 failing before (classifier gave
UNKNOWN, doctor and update gave no restart, derivation sent the
operator to support, no refusal was marked as made before any work),
263 passing in the touched specs after.

Re-applied from 8b8e186, which #6301 reverts so the advice can be
finished here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fied disk pair

With a working installed certificate and a HELPER_OUTDATED renewal
record, doctor told the operator to restart the node. A restart makes
the gateway load the pair on disk. When the gateway is serving a
different pair and the one on disk is not a verified replacement, the
same report already says not to restart to load it, so the two problems
contradicted each other and the restart could take a working gateway
onto an unverified pair.

The disk-pair verdict the served-certificate branch uses is now one
function, and the helper restart is conditional on the certificate
files on disk working whenever the served sample shows such a pair. A
gateway serving the pair on disk keeps the direct restart.

Test would have caught this: the new doctor test fails before the fix
(direct restart next to "do not restart") and passes after; the
positive control pins the direct restart when served and disk match.
Full dashmate unit suite: 1201 passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@shumkov shumkov added this to the v5.2.0 milestone Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@thepastaclaw

thepastaclaw commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Review not started yet because this PR is a draft.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit 07efd4a. Normal review starts when eligible; priority review starts as soon as a slot is available.

shumkov and others added 2 commits November 26, 2026 03:39
…d without prescribing a repair

A renewal refused by a helper older than the config was recorded as
UNKNOWN, so doctor said dashmate could not work out why, although the
helper knew. It is now recorded as HELPER_OUTDATED with a factual
sentence and the existing SUPPORT remedy. Doctor and update name the
cause, keep withholding `ssl obtain` and point to support, exactly as
before; neither prints a restart. Recovery advice for this cause is
designed separately.

Tests would have caught this: 4 failing before (classifier gave
UNKNOWN; doctor said "could not work out why" for a working and an
expired certificate), passing after, with doctor asserted to print
neither `ssl obtain` nor `dashmate restart`. Full dashmate unit suite:
1195 passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#6301 now records an outdated helper's refusal as HELPER_OUTDATED with
the SUPPORT remedy. This branch already defines HELPER_OUTDATED with the
RESTART_NODE remedy, classifies it only for a refusal made before any
work, and tests doctor's restart advice, so this branch's versions of
the four files that commit touches are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Base automatically changed from dashmate-newer-config-guard to v5.1-dev November 26, 2026 12:41
@github-actions github-actions Bot modified the milestones: v5.2.0, v5.1.0 Nov 26, 2026
@QuantumExplorer
QuantumExplorer changed the base branch from v5.1-dev to v5.2-dev November 26, 2026 18:13
@github-actions github-actions Bot modified the milestones: v5.1.0, v5.2.0 Nov 26, 2026

This branch has not been deployed

No deployments
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.

2 participants