fix(upgrade): create hdb_deployment on 5.0.x→5.1 upgrades, and run upgrade directives without confirmation - #1126
Conversation
…upgrades create the table
The deployment-recorder feature ships in 5.1.0 and depends on
system.hdb_deployment, but its table-creation upgrade directive was tagged
5.2.0. Directives only run when current_version < directive_version <=
upgrade_version, so on every 5.0.x → 5.1.x upgrade the 5.2.0 directive was
filtered out and the table was never created. Replicated deploy_component then
failed on peer nodes ("Deployment tracking is not initialized on this node"),
affecting the entire existing customer base. Fresh 5.1 installs were unaffected
because the table comes from systemSchema.json via mount_hdb.
Renumber the directive (5-2-0.ts → 5-1-0.ts, version 5.1.0) so it runs on the
5.0.x → 5.1.x upgrade path, and add regression tests pinning the directive to
the release that first ships the dependent code.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Investigation notes (canonical) — what CI surfaced and whyRenumbering the directive made a 1. Startup confirmation prompt → fixed in this PRA real upgrade hit the interactive 2.
|
Now that the hdb_deployment directive is versioned 5.1.0, a 4.x->5.x upgrade runs a real upgrade directive, so v5 startup prompts [CONFIRM_UPGRADE] on stdin and blocks until the test's startup timeout. Pass CONFIRM_UPGRADE=yes to the v5 starts (mirroring the existing CONFIRM_DOWNGRADE=yes in the downgrade subtest) so the upgrade proceeds non-interactively. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
kriszyp
left a comment
There was a problem hiding this comment.
I don't think this should constitute a requirement to confirm upgrade (which can be problematic for scripts that start harper that aren't expected that). Can we remove the requirement for upgrade confirmation for directives?
yes ill take a look at that |
A directive-driven upgrade runs on the normal `harper run` startup path, where the upgrade-confirmation prompt (forceUpdatePrompt) blocked on stdin — or, with no TTY, defaulted to "no" and refused to start — breaking unattended/scripted starts (systemd, containers, CI). `upgrade()` only ever runs when an upgrade directive applies (getVersionUpdateInfo returns an object solely when hasUpgradesRequired is true), so this prompt was exclusively a directive-upgrade gate. Remove it; directives now run automatically with a non-blocking notice that keeps the release-notes link. Downgrades still confirm (forceDowngradePrompt). - bin/upgrade.js: drop the forceUpdatePrompt gate + cancel/exit branch. - upgrade/upgradePrompt.ts: remove the now-unused forceUpdatePrompt. - unitTests/bin/upgrade.test.js: remove the obsolete (skipped) upgrade() prompt tests + the vars/imports they owned; runUpgrade() tests unchanged. - integrationTests/upgrade/4.x-upgrade.test.ts: revert the CONFIRM_UPGRADE=yes workaround now that startup no longer prompts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
CI status — which red checks belong to this PR (TL;DR: none of the code-level ones)Re-ran all failing jobs to separate real signal from baseline. Result:
Net: no failure here is caused by this PR's code. This PR's own tests pass — Heads-up for reviewers: Posted by an AI agent (Claude Code). |
Summary
Two related fixes that unblock the 5.0.x → 5.1 upgrade path:
Directive mis-versioned (
5.2.0→5.1.0). Thehdb_deploymenttable-creation directive was tagged5.2.0, so it never ran on a5.0.x → 5.1.xupgrade (directives run only whencurrent < directive_version <= upgrade). The table was never created on upgraded installs → replicateddeploy_componentfailed on peers ("Deployment tracking is not initialized on this node"). Fresh installs were unaffected (table comes fromsystemSchema.jsonviamount_hdb).Upgrade directives no longer require interactive confirmation. Because (1) made a directive actually apply, startup began prompting
[CONFIRM_UPGRADE]on stdin — which hangs, or with no TTY defaults to "no" and refuses to start, breaking unattended/scripted starts (systemd, containers, CI).upgrade()only runs when a directive applies (verified:getVersionUpdateInforeturns an object solely whenhasUpgradesRequiredis true; no non-directive path triggers it), so directive upgrades now run automatically with a non-blocking notice (release-notes link retained). Downgrades still confirm (forceDowngradePrompt).Changes
upgrade/directives/5-2-0.ts→5-1-0.ts,version5.2.0→5.1.0; controller import/registration updated; regression tests inunitTests/upgrade/directivesController.test.js.bin/upgrade.js— removed the blocking upgrade-confirmation prompt; directives run automatically via a non-blocking notice.upgrade/upgradePrompt.ts— removed the now-unusedforceUpdatePrompt(forceDowngradePromptkept).unitTests/bin/upgrade.test.js— removed the obsolete (skipped)upgrade()prompt tests;runUpgrade()tests unchanged.DESIGN.md— documented the directive-versioning rule + comparator caveat.downgrade and startintegration subtest is currently red (separate core fix in progress)After a real 5.x upgrade, the 4.x binary can't read the upgraded system DB and refuses to start. Root-caused to a core storage bug:
system.__dbis__metadata records were saved with the wrong encoder setting, producing msgpackr-2.x records that 4.x's msgpackr 1.x can't decode (the main data flow is unaffected). @kriszyp is fixing this in core; the subtest goes green once that lands. It is not caused by this PR — this PR surfaced it by making the upgrade actually run. Byte-level investigation in the comments.Beta caveat (directive gate)
utility/common_utils.ts:compareVersionsstrips trailing.0, sorting5.1.0-beta.1above5.1.0. So5.0.x → 5.1.x GAand5.0.x → 5.1.0-beta.1both fire the directive ✅, but an install already on5.1.0-beta.xupgrading to GA does not ❌. The GA customer base (the reported impact) is covered.Possible follow-up (not in this PR)
A cross-model review (Gemini) suggested that if a future directive performs a heavy/irreversible migration, we may want confirmation back for that case only — done safely: add a directive metadata flag (e.g.
requiresConfirmation), and for those, prompt if a TTY is present, else fail fast with a clear message (set FORCE_AUTO_UPGRADE=true to proceed) instead of hanging. Not needed for the trivialhdb_deploymentdirective; noted for when a risky directive is introduced.Testing
unitTests/upgrade/directivesController.test.js→ 5 passing;unitTests/bin/**→ 75 passing.upgrade and start/upgrade and migratepass with no prompt (plainenv: {});downgrade and startred pending the core fix above.npm run build/lint(--deny-warnings) /formatclean.🤖 Generated with Claude Code (agent: Claude Opus 4.8). Attention: the
downgradesubtest red-state is expected and tracked to @kriszyp's core metadata-encoding fix; the confirmation removal was verified (directive-only) by code trace + a cross-model review.