Skip to content

refactor(gateway): consolidate session method policy - #156071

Merged
steipete merged 1 commit into
mainfrom
codex/session-method-policy-consolidation
Sep 23, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/session-method-policy-consolidation

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Six separate Gateway method-classification collections repeat the same method names, making their session policies harder to keep aligned.

User Impact

This is an internal refactor with no intended behavior change. Session target fields, required targets, profile dependence, approval handling, and run-start participation keep their existing behavior. No schema or protocol changes are introduced.

Why This Change Was Made

One per-method map now supplies the existing narrow policy predicates. The conditional goal-resume rule and batch-patch special case remain explicit. This removes 79 application lines from one file without changing tests or consumers. Related: #150153.

Evidence

The qualified head is 49c83c855987445ff973cb3eedb196134178aad1, tree 8462c04bd9f1dbce2a6377b0ec2e3a0678e5fdce, based on landed main 9e998a3a3c7aafa29381ef48f06a22750de677cc. The policy file on the later lookup landing is unchanged from that base.

All 31 existing Gateway tests passed before and after the refactor. The classification comparison passed 7,452 assertions, and the full selected changed-file gate passed in 500.93 seconds. Independent P0–P2 review found no actionable issue. The only post-review difference restores an existing explanatory comment; executable source is unchanged. Formatting and diff checks pass.

Exact-head CI run 35807889504 passed: 119 successful jobs, 17 skipped, and the required CI gate succeeded. Preflight checked merge 3d12e2b0d245ca4c2315a4c3f6374e7d1024b817, with the exact candidate as its second parent. The completed ClawSweeper review found no correctness or security issue. Native preparation and merge admission passed, and the exact candidate landed as f08559c33cb2c3214566cd3e61d3d495ba9fa4a1. The actual one-file merge-parent delta is byte-identical to the qualified patch; native receipt and ownership-scoped cleanup are complete. No package publication or deployment is claimed.

@clawsweeper

clawsweeper Bot commented Sep 23, 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 gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Sep 23, 2026
@clawsweeper clawsweeper Bot added 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 Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 10:41 PM ET / September 23, 2026, 02:41 UTC (Revision 3).

ClawSweeper review

What this changes

Consolidates Gateway session-method classifications into one table while preserving session targeting, profile requirements, approval handling, and run-start checks.

Merge readiness

✅ Ready for maintainer review

Keep open as a useful, behavior-preserving refactor. The pinned diff preserves the existing classifications and special cases; no actionable correctness or security finding remains, and current main still uses the separate collections.

Priority: P3
Reviewed head: 49c83c855987445ff973cb3eedb196134178aad1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable consolidation with preserved semantics, successful exact-head CI, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal refactor preserves the policy consumed by Gateway admission and target resolution. Reported classification comparisons and verified exact-head CI are supplemental validation; no material authority or stored-data contract change triggers additional proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal refactor preserves the policy consumed by Gateway admission and target resolution. Reported classification comparisons and verified exact-head CI are supplemental validation; no material authority or stored-data contract change triggers additional proof.
Evidence reviewed 9 items Pinned introduced change: The introduced patch replaces six classification collections with one Map. Field lists and membership flags match the original collections; the conditional goal-resume rule, batch-patch profile requirement, unknown-method behavior, and read-only exclusions remain intact.
Authorization consumers: Session authorization consumes the unchanged predicates for pending profiles, required targets, and participation checks even for administrators. Target resolution retains approval lookup and special batch/group handling. The patch does not change authority issuance, persistence, revocation, or final-effect guards.
Current-main necessity: The policy file is unchanged between the pinned introduction base and fetched main, which still contains the separate collections. This consolidation remains distinct unlanded work.
Findings None None.
Security None None.

How this fits together

The Gateway classifies incoming RPC methods before resolving session targets and applying authorization. This shared policy also supplies method metadata without loading session storage.

flowchart TD
  A[Incoming RPC method] --> B[Shared session policy]
  B --> C[Profile requirement metadata]
  B --> D[Session target resolution]
  B --> E[Approval and run-start classification]
  C --> F[Gateway authorization]
  D --> F
  E --> F
  F --> G[Reject or dispatch request]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -79. Total -79 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 82 161 -79
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 82 161 -79

Review metrics

None.

Technical review

Best possible solution:

Keep one lightweight policy table behind the existing predicates, preserving all current authorization classifications and explicit special cases.

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

Not applicable: this PR addresses duplicated policy definitions rather than a reported runtime defect; source comparison confirms the duplication and preserved classifications.

Is this the best way to solve the issue?

Yes. Consolidating the existing data behind unchanged predicates removes repeated policy ownership without expanding APIs or coupling metadata discovery to storage.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is an internal consolidation with preserved behavior and no new user-facing capability or urgent defect.
  • 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 maintainer-authored internal refactor preserves the policy consumed by Gateway admission and target resolution. Reported classification comparisons and verified exact-head CI are supplemental validation; no material authority or stored-data contract change triggers additional proof.

Evidence

What I checked:

  • Pinned introduced change: The introduced patch replaces six classification collections with one Map. Field lists and membership flags match the original collections; the conditional goal-resume rule, batch-patch profile requirement, unknown-method behavior, and read-only exclusions remain intact. (src/gateway/session-method-policy.ts:14, 49c83c855987)
  • Authorization consumers: Session authorization consumes the unchanged predicates for pending profiles, required targets, and participation checks even for administrators. Target resolution retains approval lookup and special batch/group handling. The patch does not change authority issuance, persistence, revocation, or final-effect guards. (src/gateway/session-sharing.ts:148, 49c83c855987)
  • Current-main necessity: The policy file is unchanged between the pinned introduction base and fetched main, which still contains the separate collections. This consolidation remains distinct unlanded work. (src/gateway/session-method-policy.ts:5, 718027889d76)
  • Latest-release comparison: The supplied latest release, v2026.9.5, also contains separate policy collections rather than the proposed consolidated table. (src/gateway/session-method-policy.ts:5, ec9c1a13db89)
  • Verified merge scope: Raw test-merge records contain the pinned base followed by the exact PR head. Its comparison against that base changes only the policy file; unrelated endpoint drift is not attributed to this PR. (src/gateway/session-method-policy.ts, 3d12e2b0d245)
  • Validation and review continuity: GitHub confirms the linked CI run completed successfully on the exact reviewed head. The captured body reports 31 existing tests passing before and after and 7,452 classification assertions; these were not rerun during this read-only review. Previous completed reviews cover the same head and retain no findings or published rank-up moves. (49c83c855987)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • roboclaw-bot: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (2 earlier review cycles)
  • reviewed 2026-09-23T01:48:12.426Z sha 49c83c8 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-23T01:56:08.243Z sha 49c83c8 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 23, 2026 01:49
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 49c83c855987445ff973cb3eedb196134178aad1
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/session-method-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@steipete
steipete merged commit f08559c into main Sep 23, 2026
264 checks passed
@steipete
steipete deleted the codex/session-method-policy-consolidation branch September 23, 2026 02:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed 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