Skip to content

feat(doctor): check OpenClaw ID member roles and honor an optional roles default - #197785

Merged
jalehman merged 8 commits into
mainfrom
ocf-523-doctor-member-roles
Nov 18, 2026
Merged

jalehman merged 8 commits into
mainfrom
ocf-523-doctor-member-roles

Conversation

@jalehman

@jalehman jalehman commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Doctor does not know that gateway.roles.default is optional or that OpenClaw ID member roles come from gateway.roles.definitions. With role definitions and no default, it wrongly reports that automations will lose owner access. It also has no check for a member whose role is not defined, for missing preset roles, or for role settings that have no effect.

User Impact

User impact: openclaw doctor reports member-role problems in plain words and can write missing preset roles after asking.

  • Fixed: with role definitions and no default, Doctor no longer reports that an automation "will lose access at the next run" or that owner status is unverified.
  • New checks when OpenClaw ID is on:
    • a member whose role has no definition, with the member and role named;
    • a missing preset definition, with a repair that writes it. The repair asks first and says that the config file is rewritten as JSON and loses its comments;
    • a sandbox-required role held by a member, or set as the default, when no sandbox backend is available.
  • New check for any Gateway: stored role assignments with no gateway.roles.default, which means named-role enforcement is off and the assignments have no effect.
  • A Gateway with no gateway.roles, and one with a default set and OpenClaw ID off, get the same Doctor output as before.

Why This Change Was Made

  • The cron ownership checks and the replay script now ask whether named-role enforcement is on, as runtime admission does, and no longer test for the presence of gateway.roles.
  • The member checks read the local claw record, so they work with the Gateway stopped. A claw that has never linked has no record and gets no warning. A record that exists and cannot be read, or whose member list is malformed, is reported with a fixed message that contains nothing from the record.
  • The preset repair uses the same code as turning on OpenClaw ID: it adds only missing presets and never writes default or assignments. Like every Doctor repair that writes config, it also records Doctor's usual last-run metadata.
  • Docs for roles and OpenClaw ID describe the optional default, member presets, which role applies to a connection, and what a sandbox-required role does and does not contain.

Evidence

  • Doctor suites: 31 tests in 3 files pass at the review-fix commit. A reviewer separately ran 94 tests in 6 files, covering Doctor, activation presets, the config schema and Doctor's consent modes, all passing.
  • Core and test typechecks, lint, format and ratchets pass.
  • Independent review found no P0 or P1 and three P2 in the new member check: a corrupt record could put a fragment of an invite key into Doctor's output, a malformed member list passed silently, and a never-linked install got a false warning. The fourth commit fixes all three, with a test that plants a synthetic secret in a corrupt record and asserts none of it is printed. A second review found nothing.
  • Two docs anchor checks fail the same way on main, in pages this PR does not touch.

Not run: a whole-Doctor output comparison against the parent, a repair while a live Gateway reloads, and real Docker or Podman probing.

Rebased onto main (b0b88a8fab94). This PR changes no Gateway runtime behavior: the claw store is identical to main, so a malformed stored member list loads exactly as before. Doctor detects it on its own: it reads the stored claw record through a read-only parser used only by Doctor, and reports a malformed member list or an unreadable record with the fixed message above. What the Gateway itself should do with such a record is a separate follow-up. After the rebase: 156 focused, state-path and storage tests, 197 Doctor and cron tests (2 PostgreSQL-gated skips) and the Doctor tests under CI's pinned Bun pass, with typechecks, static checks and ratchets.

Known, not changed here: the development replay script (scripts/dev/cron-context-replay.mts) fails with "User profile catalog is not ready" when replaying a job under a named gateway.roles.default; it reproduces the same way on main, and Doctor's own checks are unaffected.

Live proof on this head: both builds and an unlinked preflight on a second isolated machine passed (never-linked Doctor silent; consented preset repair adds only the missing preset; declining leaves config byte-identical; Doctor alongside a running Gateway). Two attempts to repeat the linked checks against real staging services stopped on test-harness problems before reaching them; no product failure was found. The linked Doctor checks passed live on the previous head. Because the Gateway's stored-data loading is byte-identical to main in this PR, upgrade compatibility rests on that identity, the exact-head review and the tests; the maintainer chose to land on that basis.

@clawsweeper

clawsweeper Bot commented Nov 12, 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 scripts Repository scripts commands Command implementations size: L labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR corrects Doctor’s optional-default handling and adds member-role diagnostics with consented repair of missing presets.

Example: A Gateway defines a contractor role without gateway.roles.default and has an automation created by an existing profile.

  • Before: Doctor incorrectly predicts that the automation will lose owner-only tools.
  • After: Doctor recognizes that named-role enforcement is disabled and omits that warning.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is coherent and current CI passes, but supplied evidence does not establish the changed shipped behavior or upgrade compatibility.
Proof confidence 🧂 unranked krab (1/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: Feature · Worth it: Yes · Fix scope: Complete
User problem: Doctor incorrectly predicts automation access loss and lacks diagnostics for undefined member roles, missing presets, and unavailable required sandboxes.
Reason: The supplied maintainer-authored direction supports these related diagnostics and consented repairs, and the merged prerequisite confirms the existing diagnostic defect.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR addresses a confirmed Doctor mismatch explicitly deferred by the merged role-enforcement change; no introduced correctness or security blocker was found.

Priority: P2
Reviewed head: bb407c8a52f2d15760b323346f45ecdb4ce45b0a

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

  • Low-value test src/commands/doctor-member-roles.test.ts: Remove the repeated primary-chunk null, array, and number cases from the second malformed-chunk group; retain monolithic, secondary-chunk, read-only, and unchanged-runtime assertions.
  • Missing end-to-end proof: Missing shipped-CLI fresh-install and v2026.11.5 upgrade evidence covering cron output, member diagnostics, declined and accepted preset repair, settings preservation, and real backend probing; base-failing/head-passing regression execution is also not demonstrated.
Agent review details

How this fits together

Doctor reads Gateway configuration, stored profiles, membership records, and sandbox availability, then reports findings and stages accepted repairs through its existing configuration writer.

flowchart TD
  A[Doctor CLI] --> B[Health contributions]
  C[Gateway configuration] --> B
  D[Stored profiles and membership] --> B
  E[Sandbox backend probe] --> B
  B --> F[Findings and repair consent]
  F --> G[Existing configuration writer]
Loading

Technical review

Best possible solution:

Keep the shared enforcement and preset owners, with Doctor performing read-only diagnostics and staging only consented additive repairs through its existing writer.

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

Current-main source demonstrates the false warning for definitions without a default, and the merged prerequisite explicitly acknowledges that scenario; no target code was executed.

Is this the best way to solve the issue?

The change uses existing enforcement, preset, sandbox-probe, storage, and configuration-writing boundaries; the Doctor-only parser exposes malformed records that runtime normalization would conceal without changing Gateway loading.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Cron ownership diagnostics and replay keeps the original intent (c668bc0: Doctor predicts scheduled-run authority changes without changing jobs; the later optional-default change explicitly deferred the presence-check correction to this PR.)
  • Preset activation and definition privacy keeps the original intent (feat(openclaw-id): member roles come from gateway.roles.definitions #197739: Activation installs only missing editable presets while preserving defaults and assignments; the subsequent export cleanup keeps preset definitions private.)
  • Doctor contribution registration keeps the original intent (1ae0dfe: The contribution split preserves explicit legacy repair ownership and configuration-write ordering; the new check retains the existing sandbox runner.)
  • Sandbox and connection-policy documentation keeps the original intent (feat(openclaw-id): guest member role with sandboxed session tools #197748: Member connections select their own role, and required sandboxes contain exec and file tools with explicitly accepted exclusions.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Raw commit 4fc7acf adds src/gateway/openclaw-id/member-role-presets.ts:15 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4fc7acf90a73; files: src/gateway/openclaw-id/member-role-presets.ts)
  • Peter Steinberger: Raw commit 1ae0dfe adds src/flows/doctor-health-contributions-initial.ts:361 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1ae0dfed4d14; files: src/flows/doctor-health-contributions-initial.ts)

PR surface

Source +233, Tests +417, Docs +43, Other +4. Total +697 across 16 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 278 45 +233
Tests 3 417 0 +417
Docs 5 55 12 +43
Config 0 0 0 0
Generated 0 0 0 0
Other 3 6 2 +4
Total 16 756 59 +697

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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Corrects misleading automation diagnostics and adds focused recovery guidance for an optional Gateway feature.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-12T15:00:27.145Z sha 018e915 :: blocked before merge. :: none
  • reviewed 2026-11-16T23:04:48.841Z sha cb970c5 :: blocked before merge. :: none

Reviewed November 18, 2026, 11:10 AM ET / 16:10 UTC (Revision 3).

@jalehman
jalehman force-pushed the ocf-522-admin-members branch from 21f9820 to 234ae46 Compare November 13, 2026 20:06
@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch from 018e915 to 131df1c Compare November 13, 2026 20:06
@jalehman
jalehman force-pushed the ocf-522-admin-members branch from 234ae46 to 7323df8 Compare November 13, 2026 22:14
@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch from 131df1c to e67c5fc Compare November 13, 2026 22:14
@jalehman
jalehman force-pushed the ocf-522-admin-members branch from 7323df8 to b17e13b Compare November 14, 2026 01:19
@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch from e67c5fc to 7663cd5 Compare November 14, 2026 01:19
@jalehman
jalehman force-pushed the ocf-522-admin-members branch from b17e13b to 319316b Compare November 14, 2026 04:00
@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch from 7663cd5 to ca32eb2 Compare November 14, 2026 04:00
@jalehman
jalehman force-pushed the ocf-522-admin-members branch from 319316b to fdf748d Compare November 14, 2026 05:48
@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch from ca32eb2 to 2c6e1eb Compare November 14, 2026 05:48
@jalehman
jalehman force-pushed the ocf-522-admin-members branch from fdf748d to 7fb950c Compare November 14, 2026 06:54
@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch from 2c6e1eb to b3341bd Compare November 14, 2026 06:54
@jalehman
jalehman force-pushed the ocf-522-admin-members branch from 7fb950c to 1f4e77c Compare November 14, 2026 09:12
@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch from b3341bd to 6f002f7 Compare November 14, 2026 09:12
@jalehman
jalehman force-pushed the ocf-522-admin-members branch from 1f4e77c to 4fcf121 Compare November 14, 2026 10:22
@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch from 6f002f7 to 629d462 Compare November 14, 2026 10:23
@jalehman
jalehman force-pushed the ocf-522-admin-members branch from 4fcf121 to 1e6783f Compare November 14, 2026 11:34
@jalehman
jalehman force-pushed the ocf-522-admin-members branch from a6179ed to a953b4f Compare November 16, 2026 11:21
@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch 2 times, most recently from e997900 to 734e1c9 Compare November 16, 2026 16:02
Base automatically changed from ocf-522-admin-members to main November 16, 2026 22:35
@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch from 734e1c9 to cb970c5 Compare November 16, 2026 22:59
@jalehman
jalehman marked this pull request as ready for review November 16, 2026 23:00
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@jalehman
jalehman force-pushed the ocf-523-doctor-member-roles branch from 3e7b45f to bb407c8 Compare November 18, 2026 15:39
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@jalehman
jalehman merged commit d1276e1 into main Nov 18, 2026
204 of 206 checks passed
@jalehman
jalehman deleted the ocf-523-doctor-member-roles branch November 18, 2026 22:38
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…les default (openclaw#197785)

* fix(doctor): honor catalog-only cron owner policy

* feat(doctor): diagnose member roles and repair missing presets

* docs: clarify member role enforcement and sandbox limits

* fix(doctor): safely distinguish unreadable member records

* fix(openclaw-id): reject malformed membership chunks

* fix(doctor): consume missing preset names without exporting definitions

* test: complete Doctor path repair database mock

* fix(doctor): validate stored membership without changing runtime
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

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant