Skip to content

refactor(context-engine): remove owner cleanup helper - #128143

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/context-engine-owner-clear
Aug 23, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/context-engine-owner-clear

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Context-engine registry production code exported an owner-specific cleanup helper solely for test fixture cleanup. Gateway health tests used that helper to delete selected registrations instead of restoring the complete registry state they inherited.

Why This Change Was Made

The owner cleanup export and its quarantine-lifecycle test are removed. Gateway health tests now capture the complete context-engine registry state before registering the legacy engine and resetting quarantine state, then restore that snapshot after each test.

This keeps fixture ownership in the existing test-support boundary without changing runtime context-engine registration, selection, or quarantine behavior. Production delta: +1/-11 (net -10). Test delta: +8/-43 (net -35).

User Impact

No intended user-visible change. Context-engine registry production surface is smaller, and gateway health tests restore shared registry state instead of applying owner-specific cleanup.

Evidence

  • node scripts/run-vitest.mjs src/context-engine/quarantine-health.test.ts - 3 passed, 3 Linux-only skipped
  • node scripts/run-vitest.mjs src/context-engine/context-engine.test.ts - 65 passed
  • node scripts/run-vitest.mjs src/context-engine/host-param-projection.test.ts - 7 passed
  • node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts -t "merges live context-engine quarantine state into cached health responses" - 2 passed, 422 skipped; 12.55s wall time
  • Full server-methods.test.ts run: 422 passed in 655.46s; two unrelated exec-approval tests failed before the changed health block. The timeout reproduced alone in 669.94s without touching the changed fixture.
  • Targeted oxfmt, git diff --check, privacy scan, and autoreview passed
  • check-changed passed source guards, formatting, dead-export scanning, core typecheck, and lint. Core-test typecheck stopped on missing shared-install UI dependencies (@panzoom/panzoom and pako typings).

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Aug 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 23, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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 Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 4:14 AM ET / 08:14 UTC.

ClawSweeper review

What this changes

The PR deletes an owner-specific context-engine registry cleanup helper and changes gateway health tests to snapshot and restore the complete registry state.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking findings: the PR removes a production-only test cleanup export and uses the existing full-registry snapshot boundary for fixture restoration. It remains open for explicit maintainer handling because it is member-authored and carries the protected maintainer label.

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

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative refactor with an appropriate existing test-support boundary and reported exact-head validation.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored internal test-isolation refactor is exempt from the external-contributor proof gate; the PR nevertheless includes focused exact-head Testbox and sanitized Crabbox validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored internal test-isolation refactor is exempt from the external-contributor proof gate; the PR nevertheless includes focused exact-head Testbox and sanitized Crabbox validation.
Evidence reviewed 7 items Current-main behavior: Current main still exports the owner-specific helper; the PR removes only that helper, not registration or runtime quarantine behavior.
Existing test-support owner boundary: The existing test-support helper snapshots all registrations and quarantine records, restores both maps, and mirrors the restored quarantine state back to the process store.
Changed fixture uses complete restoration: The health suite captures state before registering the legacy engine and restores it in afterEach, replacing selective cleanup of only one test owner.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts -t "merges live context-engine quarantine state into cached health responses"

Result: PASS (completed)

node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts -t "merges live context-engine quarantine state into cached health responses"
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128143-RRkTeR/target$ node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts -t "merges
live context-engine quarantine state into cached health responses"
node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts -t "merges live context-engine quarantine state into cached health responses"
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128143-RRkTeR/target

 ✓  gateway-server-isolated  ../../src/gateway/server-methods/server-methods.test.ts (212 tests | 211 skipped) 378ms
 ✓  gateway-methods  ../../src/gateway/server-methods/server-methods.test.ts (212 tests | 211 skipped) 414ms
     ✓ merges live context-engine quarantine state into cached health responses  315ms

 Test Files  2 passed (2)
      Tests  2 passed | 422 skipped (424)
   Start at  08:15:19
   Duration  16.33s (transform 12.72s, setup 727ms, import 14.52s, tests 791ms, environment 0ms)

[test] passed 1 Vitest shard in 20.38s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128143-RRkTeR/target$ node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts -t "merges
live context-engine quarantine state into cached health responses"































Assertions:

  • PASS expect_output: merges live context-engine quarantine state into cached health responses

How this fits together

Context engines are registered in a process-wide plugin registry and feed gateway health reporting. Gateway health tests temporarily register engines and reset quarantine state, then must restore the registry so subsequent tests inherit the original process state.

flowchart LR
  A[Gateway health tests] --> B[Context-engine registry]
  B --> C[Legacy and test engines]
  C --> D[Quarantine state]
  D --> E[Gateway health response]
  A --> F[Registry snapshot and restore]
  F --> B
Loading

Decision needed

Question Recommendation
Should this member-authored registry-cleanup refactor be accepted after exact-head required checks complete? Approve after checks: Accept the existing snapshot/restore test boundary once required exact-head checks are green.

Why: The protected maintainer label and member authorship require explicit maintainer handling even though the code review found no repairable defect.

Before merge

  • Complete next step (P2) - No mechanical repair is needed; explicit maintainer review and exact-head required checks are the remaining gate for this protected member PR.
Agent review details

Security

None.

PR surface

Source -10, Tests -35. Total -45 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 11 -10
Tests 2 8 43 -35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 9 54 -45

Review metrics

Metric Value Why it matters
Production versus test LOC production +1/-11 (net -10); tests +8/-43 (net -35) The PR materially reduces both production and test surface while moving fixture cleanup to existing test support.

Stored data model

Persistent data-model change detected: serialized state: src/context-engine/quarantine-health.test.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Merge the narrow deletion after normal maintainer approval and exact-head required checks, retaining the existing full-state test-support helper as the sole fixture cleanup mechanism.

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

Not applicable: this PR is a behavior-neutral fixture-ownership cleanup, not a report of a user-facing failure.

Is this the best way to solve the issue?

Yes. Reusing the existing complete registry snapshot avoids retaining a production export used solely by tests and restores more state than selective owner deletion.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 79e675521f7c.

Labels

Label justifications:

  • P3: This is a small internal cleanup with no intended user-visible behavior change.
  • 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: This member-authored internal test-isolation refactor is exempt from the external-contributor proof gate; the PR nevertheless includes focused exact-head Testbox and sanitized Crabbox validation.

Evidence

What I checked:

  • Current-main behavior: Current main still exports the owner-specific helper; the PR removes only that helper, not registration or runtime quarantine behavior. (src/context-engine/registry.ts:445, 79e675521f7c)
  • Existing test-support owner boundary: The existing test-support helper snapshots all registrations and quarantine records, restores both maps, and mirrors the restored quarantine state back to the process store. (src/context-engine/registry.test-support.ts:29, b4e5c9a1812a)
  • Changed fixture uses complete restoration: The health suite captures state before registering the legacy engine and restores it in afterEach, replacing selective cleanup of only one test owner. (src/gateway/server-methods/server-methods.test.ts:4514, b4e5c9a1812a)
  • Obsolete test removal: The deleted quarantine test asserted behavior of the removed test-only production helper; remaining quarantine tests continue to cover persisted-record lifecycle and cross-process visibility. (src/context-engine/quarantine-health.test.ts:79, b4e5c9a1812a)
  • Feature provenance: Blame attributes both the current-main helper and the complete-state test-support helper to the same recent area commit, making the replacement an informed consolidation rather than a new runtime mechanism. (src/context-engine/registry.ts:445, 844e781ca409)
  • Validation supplied by the member author: The PR discussion reports exact-head Testbox coverage for 87 focused tests and the two changed health tests, plus a sanitized direct Crabbox run covering 96 context-engine tests and the changed health tests.

Likely related people:

  • shakkernerd: Current-main blame attributes both the removed helper and the snapshot/restore support seam to this contributor's recent context-engine work. (role: recent area contributor; confidence: high; commits: 844e781ca409; files: src/context-engine/registry.ts, src/context-engine/registry.test-support.ts)
  • Peter Steinberger: History shows repeated context-engine and plugin-registry refactors, including the registry-bundle move that owns this shared registration surface. (role: major context-engine refactor contributor; confidence: medium; commits: e4d1b7e0d38c, 40dd08a0a6eb; files: src/context-engine/registry.ts, src/context-engine/registry.test-support.ts)
  • vincentkoc: The member author is assigned to and has supplied exact-head validation for this focused refactor. (role: current PR owner; confidence: high; commits: b4e5c9a1812a; files: src/context-engine/registry.ts, src/gateway/server-methods/server-methods.test.ts)

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-23T07:47:27.065Z sha b4e5c9a :: needs maintainer review before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer decision: mark ready and keep the exact reviewed head.

ClawSweeper merge-risk item handled: meaningful exact-head validation is complete. The stored-data-model flag is a filename false positive; this patch deletes a production helper and test setup only, with no schema, serialization, migration, or persisted-state format change.

The two full-suite exec-approval failures reproduce outside the changed path and on unchanged base/head production blobs. They are not a regression from this PR and should be repaired separately.

@vincentkoc
vincentkoc marked this pull request as ready for review August 23, 2026 08:11
@vincentkoc
vincentkoc merged commit bfad1bf into main Aug 23, 2026
301 checks passed
@vincentkoc
vincentkoc deleted the refactor/context-engine-owner-clear branch August 23, 2026 08:34
@vincentkoc

Copy link
Copy Markdown
Member 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. size: S 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