Skip to content

refactor(cli): simplify Gateway fallback and hook state ownership - #129802

Merged
steipete merged 1 commit into
mainfrom
codex/skills-gateway-owner-cleanup
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/skills-gateway-owner-cleanup

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #117567

What Problem This Solves

Skills and Hooks repeatedly implement the same Gateway fallback decisions, while Hook enable and disable maintain duplicate configuration-mutation paths. The duplication makes future regressions in explicit Gateway authority, offline discovery, and ownership-safe mutation unnecessarily likely.

Why This Change Was Made

Consolidate exact offline and older-Gateway eligibility in the existing lazy CLI Gateway facade, centralize repeated Skills RPC request envelopes, and give Hook toggling one canonical read/modify/write owner. Preserve configured and environment-selected Gateway authority, credential-free local discovery, exact legacy read compatibility, exclusive mutation locking, CLI identity, timeout behavior, and cold-start import boundaries. Production code decreases by 59 lines and the Hook assertion-safety baseline drops from two assertions to one.

User Impact

No intentional behavior change. Skills, Hooks, curator operations, and Workshop proposals keep their current behavior while their shared ownership rules become smaller and less likely to diverge.

Evidence

  • 371 existing focused Gateway, CLI, Hook, Skills, curator, Workshop, and real-process regression tests passed without changing or deleting tests.
  • Real isolated CLI/Gateway proof: credential-free discovery returned 55 Skills and five Hooks; an explicitly unreachable Gateway failed visibly; a real token-authenticated Gateway passed health and remote Skills discovery; active Gateway ownership prevented unauthenticated local Workshop mutation.
  • Production and affected CLI-test typechecks, targeted lint, formatting, assertion-safety/max-lines ratchets, dead-export scans, plugin boundaries, dependency guards, and runtime import-cycle checks passed.
  • The full local core-test typecheck also reaches unrelated UI code whose shared local dependency installation lacks pako declarations; exact-head hosted CI provides the clean-install check for that existing machine-local gap.
  • Final independent structured code review reported no P0 or P1 findings.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: M maintainer Maintainer-authored PR labels Aug 26, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 11:48 PM ET / August 26, 2026, 03:48 UTC.

ClawSweeper review

What this changes

The PR consolidates CLI Gateway fallback classification, Skills RPC envelopes, and Hooks enable/disable config writes while preserving existing command behavior.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for maintainer handling: this is a meaningful, compatibility-sensitive cleanup of the recently merged Gateway-authority repair. Source review found no actionable correctness defect, but exact-head CI and maintainer acceptance remain required.

Priority: P3
Reviewed head: 64dc17ab5266ac367a8c6b0edcf807840b494731
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused net-negative refactor with no correctness findings; exact-head CI and maintainer acceptance remain the merge gates.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports real isolated CLI/Gateway evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports real isolated CLI/Gateway evidence.
Evidence reviewed 4 items Centralized fallback preserves the existing predicate: The new helper accepts only credential-required, narrowly classified unavailable transport, or exact legacy-method errors, then requires an implicit local target; its three callers preserve the prior separate checks.
Current main behavior is the refactored invariant: Current main independently applies the same credential, transport, legacy-method, and implicit-local checks in the Hooks and Skills call sites that this PR consolidates.
Existing boundary tests cover the preserved cases: The Hooks and Skills tests cover configured-remote and environment-selected failures, implicit-local credential and transport recovery, old-method compatibility, and ownership-lock protection for local mutations.
Findings None None.
Security None None.

Live Verification

Command: pnpm test src/cli/hooks-cli.toggle.test.ts src/cli/skills-cli.curator.test.ts src/cli/skills-cli.workshop-cache.test.ts

Result: PASS (completed)

$ node --import tsx scripts/test-projects.mts src/cli/hooks-cli.toggle.test.ts src/cli/skills-cli.curator.test.ts src/cli/skills-cli.workshop-cache.test.ts
[test] starting test/vitest/vitest.cli.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129802-PCyroV/target

 ✓  cli  src/cli/hooks-cli.toggle.test.ts (113 tests) 288ms
 ✓  cli  src/cli/skills-cli.curator.test.ts (23 tests) 118ms
 ✓  cli  src/cli/skills-cli.workshop-cache.test.ts (16 tests) 3402ms
     ✓ applies through the gateway process that owns the cached session skill index  767ms
     ✓ preserves configless offline apply after 'missing credentials before connecting'  373ms

 Test Files  3 passed (3)
      Tests  152 passed (152)
   Start at  03:49:19
   Duration  13.87s (transform 14.14s, setup 3.82s, import 13.24s, tests 3.81s, environment 0ms)

[test] passed 1 Vitest shard in 19.87s
$ node --import tsx scripts/test-projects.mts src/cli/hooks-cli.toggle.test.ts src/cli/skills-cli.curator.test.ts src/cli/skills-cli.workshop-cache.test.ts
[test] starting test/vitest/vitest.cli.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129802-PCyroV/target

 ✓  cli  src/cli/hooks-cli.toggle.test.ts (113 tests) 213ms
 ✓  cli  src/cli/skills-cli.curator.test.ts (23 tests) 116ms
 ✓  cli  src/cli/skills-cli.workshop-cache.test.ts (16 tests) 3285ms
     ✓ applies through the gateway process that owns the cached session skill index  762ms
     ✓ preserves configless offline apply after 'missing credentials before connecting'  372ms

 Test Files  3 passed (3)
      Tests  152 passed (152)
   Start at  03:49:40
   Duration  8.22s (transform 4.71s, setup 2.08s, import 5.85s, tests 3.61s, environment 0ms)

[test] passed 1 Vitest shard in 14.18s

Assertions:

  • PASS expect_output: Test Files

How this fits together

Skills and Hooks CLI commands first ask the selected Gateway for state; only an implicit local Gateway may fall back to local discovery or mutation under narrow transport or legacy-method conditions. Hook toggles then persist the selected hook state to configuration.

flowchart LR
  CLI[Skills or Hooks CLI] --> RPC[Gateway request]
  RPC --> Classify[Fallback classification]
  Classify --> Gateway[Selected Gateway result]
  Classify --> Local[Implicit local recovery]
  Local --> Skills[Local Skills state]
  Local --> Hooks[Hook config update]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned refactor be accepted after exact-head checks confirm that explicit and environment-selected Gateway targets never fall back to local state? Accept after exact-head validation: Merge after the focused Skills, Hooks, curator, and Workshop ownership checks are green on the reviewed head.

Why: The PR changes a shipped compatibility and ownership boundary, and its protected maintainer label requires explicit human handling despite no source-level defect found.

Before merge

  • Resolve merge risk (P1) - The shared predicate controls whether configured or environment-selected Gateway failures can expose client-local state; merge only after exact-head validation confirms those paths still fail closed.
Agent review details

Security

None.

PR surface

Source -59, Other 0. Total -59 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 102 161 -59
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 4 103 162 -59

Review metrics

Metric Value Why it matters
Production versus test delta production +102/-161 (net -59); tests 0; test-support baseline 1 assertion removed The reduction comes from replacing repeated Gateway and Hook ownership paths with shared logic rather than adding a new user-facing surface.

Merge-risk options

Maintainer options:

  1. Validate the authority boundary before merge (recommended)
    Require exact-head focused checks for configured remote, environment-selected, implicit-local offline, and exact legacy-method cases before merging this shared predicate.
  2. Pause for a narrower split
    If maintainers want separately reviewable fallback and Hooks ownership changes, pause this branch and request a split instead of accepting the combined refactor.

Technical review

Best possible solution:

Retain one canonical fallback classifier with the existing exact legacy and implicit-local conditions, then land only after exact-head owner-boundary checks pass.

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

Not applicable: this PR claims behavior preservation, and the review compares its shared implementation against the existing fallback and lock-owner boundary.

Is this the best way to solve the issue?

Yes: consolidating duplicate fallback and Hook-write paths is the best maintainable shape because the exact boundary remains explicit and is reused by all affected CLI flows.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 345cfde43dc9.

Labels

Label justifications:

  • P3: This is a behavior-preserving CLI refactor rather than a newly reported user-impacting failure.
  • merge-risk: 🚨 compatibility: The shared fallback classifier governs legacy Gateway compatibility and whether explicit Gateway failures may reach local state.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports real isolated CLI/Gateway evidence.

Evidence

What I checked:

  • Centralized fallback preserves the existing predicate: The new helper accepts only credential-required, narrowly classified unavailable transport, or exact legacy-method errors, then requires an implicit local target; its three callers preserve the prior separate checks. (src/cli/gateway-rpc.ts:60, 64dc17ab5266)
  • Current main behavior is the refactored invariant: Current main independently applies the same credential, transport, legacy-method, and implicit-local checks in the Hooks and Skills call sites that this PR consolidates. (src/cli/hooks-cli.ts:111, 345cfde43dc9)
  • Existing boundary tests cover the preserved cases: The Hooks and Skills tests cover configured-remote and environment-selected failures, implicit-local credential and transport recovery, old-method compatibility, and ownership-lock protection for local mutations. (src/cli/skills-cli.curator.test.ts:182, 345cfde43dc9)
  • Merged repair provenance: The related merged repair established the Gateway-authority boundary that this PR refactors; the PR head attribution shows the consolidation was added in the current commit. (src/cli/gateway-rpc.ts:60, b5864ba1db34)

Likely related people:

  • steipete: Authored the merged owner-boundary repair and the current consolidation commit. (role: introduced and recently maintained the Gateway fallback boundary; confidence: high; commits: b5864ba1db34, 64dc17ab5266; files: src/cli/gateway-rpc.ts, src/cli/hooks-cli.ts, src/cli/skills-cli.ts)

Rank-up moves

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

  • Confirm the focused Gateway, Skills, Hooks, curator, and Workshop checks complete successfully on the current head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-26T03:09:41.827Z sha 8da05bd6f022472a225392411ffc709d6fefe4b7 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/skills-gateway-owner-cleanup branch from 8da05bd to 64dc17a Compare August 26, 2026 03:44
@steipete
steipete merged commit 1df7ac3 into main Aug 26, 2026
196 checks passed
@steipete
steipete deleted the codex/skills-gateway-owner-cleanup branch August 26, 2026 04:08
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
vincentkoc added a commit that referenced this pull request Aug 26, 2026
* origin/main: (24 commits)
  fix(gateway): reject rootless session permission modes (#128149)
  docs(memory): document shipped turn-taint propagation for network tool output (#129837)
  fix(ui): pool reply-less wake activity into one chat rollup (#128442)
  fix(package): prevent installs from deleting validated runtime assets (#129724)
  fix(nodes): approve silent initial node surfaces and name the pending surface approval (#129795)
  fix(backup): preserve configured agent state roots (#129773)
  fix(ui): own chat history issuance with a closed state machine (#129776)
  fix(cron): preserve cancellation reason after late finalization (#129331)
  fix(cron): prevent run waits from failing after clock changes (#129805)
  fix(telegram): route commentary through one frozen progress owner (#128259)
  fix(release): start approved VCR mirror recovery jobs (#129829)
  test: complete current-plugin-metadata-snapshot mock factories (#129791)
  test(telegram): remove duplicate reaction case (#129848)
  fix(channels): honor supported account reply-threading policies (#129679)
  refactor(cli): deduplicate lazy subcommand registration (#129351)
  fix(ai): report interrupted local-model streams instead of empty success (#129794)
  refactor(cli): consolidate Gateway fallback and hook ownership (#129802)
  fix(qa): reject token confidence lanes without executed evidence (#129830)
  fix(tui): fence session state and delayed actions (#129810)
  fix(control-ui): keep task progress full width on hover (#129832)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant