Skip to content

fix: converge Gateway updates with environment-only service overrides - #196371

Merged
RomneyDa merged 1 commit into
mainfrom
fix/update-environment-override-convergence
Nov 12, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/update-environment-override-convergence

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Related: #196321, #196350. Behavioral follow-up to #196342; this is a separate change, not stacked on its guidance-only patch.

What Problem This Solves

Fixes: updating from a different CLI installation keeps the Gateway and CLI split when the only service customization is a named environment override.

User Impact

An owned, writable Node Gateway can converge onto the invoking CLI installation while preserving its operator-owned environment drop-ins. If activation fails, the original managed definition can be restored with those overrides intact.

Explicit launcher/working-directory pins, environment resets, uninspectable overrides, deployment-owned services, Bun and Windows retain their existing routing. The companion #196342 fixes Doctor diagnostic ordering from #196350; explicit ExecStart pins remain untouched. The installed updater must contain the fix; downloading a candidate does not change an older driver's initial target selection.

Why This Change Was Made

Selection, original-service capture and rollback shared an overly broad prohibition on all definition overrides. They now use one preservation predicate based on the existing managed-base and override metadata. Existing definition fingerprints, ownership checks and effective readback remain in place.

Native testing also exposed timeout admission confusing serving installation A with update target B. Executor admission now retains the selected target independently of the service/state admission root; the executor's mismatch guard remains unchanged.

This reuses the existing rebind/rollback owners. No new configuration, schema, migration or installation manager.

Evidence

  • Four regression cases failed before their corresponding fixes: environment-override target selection, retained original-service compensation, and both timed update admission paths (with/without original capture). The admission failures were Update executor installation changed.
  • 90 focused tests passed: 19 service-selection cases, 49 original-service recovery cases, 4 systemd environment-preservation cases, and 18 timeout/admission cases. The strengthened rollback assertion also passed on a focused rerun.
  • Core and CLI-update test typechecks, scoped lint/format, git diff --check, and the test-line budget check passed.
  • Independent AutoReview of the final working-tree candidate: scoped-clean at P0–P2; no actionable findings. Base 3af0560ce1daac4e00a1c9e573af542ba34e2f32; resulting commit daaed29c87f3e.
  • Local ClawSweeper completed the exact range 3af0560ce1da..daaed29c87f3: no findings, “patch is correct” (confidence 0.88). This was read-only source review, not a runtime test.
  • Historical reproduction before companion fix: keep stable updates and recovery free of premature migrations #196474: native Linux/systemd test from stable 2026.11.2: old driver reproduced redirect A; fixed driver selected B and passed candidate Doctor/config/plugin/recovery/startup checks. The actual update failed at package activation with Client credentials require backed-up migration custody, followed by an invalid recovery-result version field. Service remained at A; this is not a passing stable-upgrade or convergence result. No migration guard was bypassed.
  • Native Linux/systemd A → B convergence passed on fresh current-version state. The real openclaw update returned success, moved the effective launcher to B, changed the native PID, matched the candidate serving build, and passed authenticated RPC plus updater health/readiness checks. The operator drop-in was byte-identical, its value remained in systemd and /proc/<pid>/environ, and it was not baked into the managed base. No manual restart/repair after update. The disposable service/user were cleaned up.
  • Stable-upgrade recovery and activation are supplied by fix: keep stable updates and recovery free of premature migrations #196474. Combined native evidence and limits are recorded below.
Focused commands and size
node scripts/run-vitest.mjs src/cli/update-cli/update-command-service-selection.test.ts src/cli/update-cli/update-command-original-service.test.ts src/daemon/systemd.environment-preservation.test.ts --maxWorkers=1
node scripts/run-vitest.mjs src/cli/update-cli/update-command-timeouts.test.ts --maxWorkers=1
node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.cli-update.json --incremental
pnpm check:test-lines-ratchet --base 3af0560ce1daac4e00a1c9e573af542ba34e2f32

Native fixture: systemd PID 1 (not Docker), systemd 255, Node 24.22.1; two isolated npm prefixes, fresh current state, plugins disabled, a synthetic OPENCLAW_REBIND_PROOF environment drop-in, then B's openclaw update --tag <candidate.tgz> --yes --json --timeout 1500. Assertions used the repository's native-systemd survivor contract plus launcher/drop-in/process-environment checks. Candidate tarball integrity passed; SHA-256 3e21d5e435735e77b5aea49fd5eba6a3ab7aefbc642a233f0eb2cbb746605e72. The package was built from a pre-commit Testbox carrier; a source comparison confirmed its production src tree is identical to the reviewed commit.

pr-simplify: +17 net production lines, +88 net test/support lines, +6 documentation lines, and a justified test allocation. The growth covers shared override preservation and real two-root admission/rollback regressions; no parallel update owner or state machinery was introduced.

Combined native verification

Native Linux/systemd (PID 1, Node 24.22.1) proof used the three companion fixes together on focused Testbox run 42765103716.

  • Stable 2026.11.2 Gateway/state at A upgraded successfully through fixed driver B: actual update exit 0/status ok, effective launcher moved to B, PID changed, candidate serving build matched, and authenticated RPC plus health/readiness passed.
  • Sessions, approvals, and workspace survived. The environment-only drop-in remained byte-identical, remained effective in systemd and the running process, and was not copied into the managed base. No manual post-update restart or repair.
  • The fixed CLI also restarted the unchanged stable service successfully before upgrading it.
  • Package build and integrity checks passed. Upgrade-stage package SHA-256: 3b0757080aedfec5b322c2241fe9fc67237698ca08bbefb321f0537ee8208975; frozen combined source tree: 77289499c424e1ab9162b12bea7d8f1a6b6f19ab. Production files were reconciled against the PR heads, including the shared activation file.
  • Permission-blocked Doctor was proved separately on fresh candidate state: exact unsafe directory reported, service/drop-in unchanged, no false repair-success claim, and authenticated Gateway health/readiness retained. Disposable services/users/runtime files were cleaned up.

Limits: the fixed driver was bootstrapped into B before the actual upgrade. This is not proof that an unmodified released updater fixes its own first hop. No agent/model inference or external channel round trip was tested. The first combined harness finished with a later Doctor-fixture failure after its upgrade stage passed; the isolated Doctor run then exposed an early launcher-guidance defect. Those full runs are not described as passing. The final launcher-specific proof is recorded separately below.

Final launcher-specific native proof

The final candidate passed package build/integrity and the isolated systemd explicit-launcher Doctor case: override-aware guidance and systemctl cat inspection instructions were present, circular Doctor advice was absent, and both managed base and operator drop-in remained unchanged. Summary flow: native-systemd-explicit-launcher-doctor-guidance; status: passed. Disposable user/runtime cleanup passed.

Package SHA-256: ca1f3b0ea7e9f7532f2b0162e93d16e8bd98dd221779bb8d1f5d89c332f1fdf6; combined source tree: 8dbfb8fad7567c41106d76b766f870b2eb7f8713. This tree differs from the successful stable-upgrade/permission proof only in the early Doctor guidance message; unchanged upgrade and permission results were reused. This final run is a launcher-specific proof, not another stable-upgrade run. Full PR CI remains separate from these focused checks.

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes size: S labels Nov 10, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Allow updates to converge managed Gateway installations with named environment-only overrides while preserving those overrides during activation and recovery.

Example: A systemd Gateway runs from prefix A, the invoking CLI uses prefix B, and an operator drop-in sets OPENCLAW_REBIND_PROOF=preserved.

  • Before: The updater redirects to A, leaving the invoking CLI installation at B unchanged.
  • After: The updater targets B and can rebind the Gateway while retaining the operator drop-in.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused source and regression coverage support the implementation, but the required upgrade gate remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: An environment-only service customization makes updates advance the service installation while leaving the invoking CLI installation behind.
Reason: The maintainer-authored direction restores the existing convergence contract for preservable overrides; the PR correctly uses Related links because explicit launcher pins and Doctor diagnostics remain outside its scope.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it is a useful maintainer-authored repair for a current source-level defect, and this review found no introduced correctness bug.

Priority: P2
Reviewed head: daaed29c87f3e3aea34b203d3dc4262f22660926

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: A successful latest-stable upgrade through the fixed updater, preserving existing settings and data while converging the native service, remains unproved.
Agent review details

How this fits together

CLI update planning consumes inspected native-service metadata, selects the package target, and passes separate target and retained-service roots to the existing executor, installer, and recovery owners.

flowchart TD
  A[Invoking CLI] --> B[Service inspection]
  B --> C[Update target selection]
  C --> D[Executor and retained root custody]
  D --> E[Native service installer]
  E --> F[Gateway verification]
  E --> G[Original service recovery]
Loading

Technical review

Best possible solution:

Use the existing rebind and recovery owners with one override-preservation predicate and distinct executor-target and service-admission roots.

Do we have a high-confidence way to reproduce the issue?

Current source deterministically redirects a writable split-install service when named environment overrides are present; the PR also reports base-failing regressions and native reproduction, while this review executed no target code.

Is this the best way to solve the issue?

The patch is a focused repair: it shares existing preservation metadata across all three affected decisions and fixes target-root admission without weakening the executor mismatch guard.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5df392447e95.

Provenance checked

  • Override eligibility in selection, capture, and restoration changes intended behavior with a stated reason (b855e24: Distinguish known-empty metadata from real or unknown overrides and preserve safe restoration; earlier systemd work explicitly supported environment-only customization.)
  • Executor admission root changes intended behavior with a stated reason (26e1b25: Timeout admission retained update-wide budgeting and service-root context; the later admission-owner refactor carried those calls forward. The PR explains why executor target B must remain separate from service/state root A.)
  • Service-selection and recovery regressions keeps the original intent (7468fce: Consolidate low-value test layers while retaining owner-boundary assertions; the patch extends those existing suites for distinct failures.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 501e165 adds src/cli/update-cli/update-command-admitted.ts:104 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 501e165d7e42; files: src/cli/update-cli/update-command-admitted.ts)

PR surface

Source +17, Tests +88, Docs +6, Other +2. Total +113 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 41 24 +17
Tests 4 98 10 +88
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 11 147 34 +113

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression growth Production +41/-24 lines; tests/support +98/-10 lines The modest production growth centralizes preservation eligibility; regression growth covers distinct selection, compensation, and two-root admission failures.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The repair affects advanced multi-install systemd update workflows with limited scope and no established emergency outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the stable-state native upgrade proof described in realBehaviorProof.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 9, 2026, 8:33 PM ET / November 10, 2026, 01:33 UTC.

@RomneyDa
RomneyDa marked this pull request as ready for review November 10, 2026 06:45
@RomneyDa
RomneyDa merged commit fd6fa47 into main Nov 12, 2026
234 checks passed
@RomneyDa
RomneyDa deleted the fix/update-environment-override-convergence branch November 12, 2026 06:53
RomneyDa added a commit that referenced this pull request Nov 12, 2026
Preserve inspected named environment overrides while converging the managed
service definition. Keep invoking executor identity distinct from retained
service/state custody during bounded update admission.

Adapted to retain this branch's strict inspection verdict and remaining
activation budget. Regression fixtures retain source-equivalent coverage.
Independent local review omitted at the release owner's explicit direction.

(cherry picked from commit fd6fa47)

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 13, 2026
Follow #196371: named environment overrides permit rebinding to the invoking installation; launcher overrides retain the original package target. Model observed initial health and the native installation effect, and retain exact version, entrypoint, target root, override and restart assertions.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…aw#194058)

Failed-update triage now captures the operator's environment before managed candidate admission, so a coding agent installed only on the operator's PATH is still offered when the Gateway service's PATH differs. Restores the operator-environment contract from openclaw#134490 and keeps the launch confirmation from openclaw#143139.

Proof: shipped CLI on isolated Linux (Crabbox) with a running systemd Gateway: accept launches the operator-only agent, decline starts nothing, base 18bee8e reports no agent found; published 2026.11.1 upgrades to the fix with settings intact.

Co-authored-by: TorstenW <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: steipete <[email protected]>

(cherry picked from commit 7c702c3)

Release adaptation: Capture invoking operator env before candidate admission, forward to interactive triage only; preserve latest target selectors, confirmation and lease cleanup ordering. Exact three authorized production paths plus real lifecycle regression.

Follow-up dispositions: ad4863d fix: preserve the running installation when an agent updates its Gateway (openclaw#201570); dc73ec0 fix: let updates finish when another tool briefly reads OpenClaw's databases (openclaw#202541); d07b530 fix: clarify PostgreSQL schema upgrades for Git installs (openclaw#202098); e60ea9f test(update): add a Git release upgrade-survivor scenario (openclaw#201956); 2ef6f7b fix(update): build and serve Git releases outside node_modules (openclaw#201917); dbc1aa0 fix: keep the openclaw command and Gateway working after updating a pnpm install (openclaw#201735); f5e7641 fix: Git checkout updates across a schema change no longer end as post-update-failed after the new release starts (openclaw#201600); 2183caf fix: Git checkout updates no longer fail before the new release starts on a schema change or a busy database (openclaw#201463); 47e8649 fix: explain why Doctor cannot restore a scheduled job’s account (openclaw#201550); 8f2cfd4 fix: remove updater-only restrictions from agent maintenance guidance; cb5cfb2 fix: keep a doubtful killed-update recovery on the repair path (openclaw#201361); 24cb734 fix: keep carried-over scheduled jobs running after updates (openclaw#200653); d1276e1 feat(doctor): check OpenClaw ID member roles and honor an optional roles default (openclaw#197785); 0a39956 fix: finish updates when another tool reads OpenClaw's databases during the update (openclaw#201330); ea1c9d5 fix(update): settle remounted package publications before admission (openclaw#201336); 66b5212 fix(update): isolate malformed retained-install markers (openclaw#201199); 7e79c83 fix: let the next update finish a killed source checkout update (openclaw#201009); d905d8a fix: let the next update finish a killed update after the machine restarted (openclaw#200994); fdf0c95 fix: let the next update finish a killed update that had already installed the new version (openclaw#200866); 0c19bcd chore(release): close out 2026.11.5 on main (openclaw#200577); a1940e0 fix(matrix): keep explicit recovery available during deferred migration (openclaw#200805); 18b4776 improve: explain package baseline drift during updates (openclaw#200802); 1ad4cad fix(doctor): reclaim macOS updater runtimes blocked by non-updater processes (openclaw#200732); 427c857 fix: keep one missing archived transcript from blocking every update (openclaw#200733); 802e3f7 fix(update): keep valid cold archives from blocking updates (openclaw#200659); 23fca1a fix: let the next update continue after a killed update when nothing is left to repair (openclaw#200680); 3afe212 fix: let Doctor publish unchanged plugin migrations in any order (openclaw#200658); f65e4db fix(doctor): reclaim runtimes blocked by unrelated Linux processes (openclaw#200657); dab086c fix(update): let candidate Doctor read plugin dependencies from the staged package (openclaw#200595); 3447bee fix(update): keep updates going when the predecessor writes during its stop (openclaw#200569); 0ce9c77 fix: let the next update settle a package publication that a killed update left behind (openclaw#200550); ae31ea3 fix(update): repair handoffs in the journal-pinned lease store (openclaw#200532); 74020ea fix: continue updates when initial SQLite capture is stale (openclaw#200328); 6747b1e feat(update): run Git checkout installs from releases behind the release link (openclaw#199706); e3f8a67 fix(state): keep completed retained agent stores out of startup upgrade (openclaw#200284); 3c512c5 fix(gateway): move managed update lease operations off the main thread (openclaw#200169); ea69fcb chore(release): close out 2026.11.4 on main (openclaw#199956); 618bf31 fix(state): bound startup upgrade copies and pruning to owned state (openclaw#199929); e4a3093 perf(update): replace the candidate canary with a runtime contract check (openclaw#198268); 5dbf569 fix(update): plugin failures never fail an update or Gateway health; 764761e fix(update): refuse missing host prerequisites in one line and record a cause per attempt; 4c4fef4 fix(ui): update dialog claims installation before progress is confirmed (openclaw#199254); 136e1f6 fix(update): retrying an update from a dev checkout is refused after a killed update (openclaw#198673); 3bd03da fix(update): avoid duplicate database copies while the Gateway is stopped (openclaw#198148); 68a839b fix: isolate held agent databases until explicit restoration (openclaw#198180); e333f7e chore(ci): drop retired test-lines allocation records (3/3) (openclaw#197657); fd6fa47 fix: converge Gateway updates with environment-only service overrides (openclaw#196371); 7cf5e75 fix: clarify split-install updates and blocked Doctor repairs (openclaw#196342); 6ff8c86 fix(update): retain lazy sqlite catalog generation (openclaw#197095); 930e1f7 fix: keep stable updates and recovery free of premature migrations (openclaw#196474); a15f737 fix: preserve external plugin data during update rehearsal (openclaw#196301); 92798ae fix: updates survive interrupted heartbeat runs (openclaw#195656); c1e55e2 fix(update): restore LaunchAgent registration after repair contention (openclaw#195406); 715c610 fix(doctor): repair retained ISO session end timestamps (openclaw#194685); 689cfc8 fix(update): reclaim dead closing triage repair leases (openclaw#194503); 86bc89e fix(doctor): keep standing Codex parameter advice out of retirement blockers (openclaw#193650); 691bc8d fix(backup): read the backup engine without copying the live database (openclaw#194234); 000542f fix(backup): backups and updates fail on slow storage when a header probe batch misses its deadline (openclaw#194239); 31a65d5 fix(update): skip --no-lazy-fetch on Git versions without it (openclaw#194198); e45e99d fix(update): preserve dev update sources in tag-only Git clones (openclaw#193109)

Validation: Baseline2 intended operator-agent failures/32 controls passed; candidate34/34passed (194058-green.log). Accept launches synthetic operator-only CLI with expected env, decline starts nothing. Isolated updater flow, not live systemd/upgrade qualification.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 6689fd575ada8fe40a9593784deac18ec73041cd)
(cherry picked from commit 92e7a9fa223b0dc35801f25f70be90b472d9a6b7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant