Skip to content

refactor(gateway): refresh session discovery watches in place - #176786

Merged
steipete merged 1 commit into
mainfrom
deslop/z02-20-store-sources-20261015
Oct 19, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/z02-20-store-sources-20261015

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Auxiliary session-history source discovery hands shared watches through a chain
of retired cache generations and keeps an unused synchronous acquisition path.

User Impact

Normal history source selection, external-path refresh, cancellation and shutdown
retain their existing owners. Auxiliary topology can change between preparation
and receiver selection; physical-path and disclosure checks remain mandatory.

Why This Change Was Made

Refresh the existing bounded memo in place. One pending refresh shares its
outcome, retains intersecting watches, and prunes retired unique paths. Delete
the unused synchronous acquisition, unused returned currency closures, and
copies of prepared facts that the producer and receiver do not mutate.

This is one session-history discovery AREA recovered from the parked family,
not a replay of its wider changes. Three paths: production +55/-106, 51 net
lines removed; tests +90/-47, 43 net lines added. Whole packet: eight net lines
removed. The test growth adapts the existing synchronous cases to the actual
async acquisition and adds shared-rejection/next-request recovery coverage.
The worker resolver stays in its existing leaf owner.

No public config, protocol, SDK, persisted shape, schema, permission, retention,
durability or dependency change. Phase E standalone session memory, its factory,
registry, expiry, federation machinery and tests are wholly untouched.

Best-effort tradeoffs accepted

  • The recursive replacement chain came from fix(gateway): requests stall for seconds on macOS when directory watches churn #172838, which measured native
    macOS watch-close stalls of 0.4–19 seconds. Keep that measured performance
    benefit by retaining common watches directly; no generation custody is needed.
    Failure, bounded eviction and root close still release owned observations.
  • The wrapper no longer repeats the registry-token check after the producer
    has validated its canonical snapshot. Auxiliary topology may change afterward;
    the receiver still validates captured physical candidates and primary/live
    disclosure authority. The next request refreshes invalidated auxiliary facts.
  • The synchronous acquisition introduced in fix: hide subagent coordination and stop reply loops #150625 no longer has a production
    caller. Its human coordination-visibility issue Subagent coordination leaks into chat and triggers peer reply loops #150488 does not require this
    dead wrapper: actual history lineage remains on the async worker path.
  • Prepared request facts are shared without an extra deep copy. The sole
    production consumer serializes and forwards them without mutation; the worker
    resolver likewise does not mutate them. Unsupported internal mutation is not
    given a second copy/ownership protocol.

Evidence

Exact-head CI39187864520 attempt1 is failed, not green. The native inherited-only
exception is requested for the following independently attributed baseline break.
All eight failures have the same determining source pair, unchanged between actual
main baseline af1e1fe and tested merge003bc6badbba. CI's informational report
labels these new/unknown against an older scheduled main; actual signature/source
inspection and main repair #176799 establish the later inherited regression.

Failed job ID Attribution
build-artifacts 117854377688 UI MISSING_EXPORT SidebarProjectionMemo, before artifacts finish
checks-ui-e2e (1/2) 117854377704 Same missing export during bundling, not browser-test failure
check-prod-types 117855154539 UI TS2724 missing export plus resulting TS7006 row implicit-any
check-test-types-core-1 117855154509 Same two UI diagnostics
check-test-types-core-2 117855154565 Same two UI diagnostics
check-test-types-core-3 117855154557 Same two UI diagnostics
check-test-types-core-4 117855154569 Same two UI diagnostics
check-test-types-core-5 117855154659 Same two UI diagnostics

Main repair e070647 changes only the stale UI import to the existing cache
module. Its published main-baseline proof reproduces both diagnostics and the
build failure, then passes targeted UI types, four attention cases and UI build.
All three determining UI modules compare byte-identical between our actual CI
baseline, tested merge and that repair's recorded main baseline c2549f8.
No authored source-discovery path changes these modules. Aggregate117855806405
reports exactly these eight executable roots; all63 attempt jobs and192 exact-head
checks are terminal. Independent security-fast117854377690 passes; ancillary
cancelled auto-response has a successful same-head successor. No executable suite
is missing. The last six completed scheduled main failed-job maps and coordinator
flake register were checked; no matching missing-export entry exists. No CI rerun,
green repush, broad local build/typecheck or underlying-UI repair by this lane.

Independent P0-P2 review of the complete fixture-repaired cut completed
scoped-clean in one pass before the coordinator's tooling rebase. The entire
three-file diff and 34 complete source/context files verified unchanged around
that review. The rebase retains main's removal of the custom watcher recovery
interval; no receiver validation is removed. The shared target resolver has
return paths without a physical candidate check, so the final binding check stays.

Pre-rebase formatting passed (three files, 21ms); whitespace checks pass. Final producer
path/registry publication checks remain unchanged, including canonical snapshot
rejection. The adapted pending-publication case requires one shared rejection,
watch release, then successful fresh preparation; it does not promise stale
successful topology or weaken the registry witness.

The first migrated suite reported five failures. One serial exact-base production
control with the same adapted tests reproduced all five: 85 native reads against
the resolver's original 48 bound, three alias cases still allowing the legitimate
canonical fallback, and replacement of a missing-file parent without changing its
physical path string. This is adapted-test diagnosis, not inherited CI clearance.
The repair configures the selected alias, physically redirects the parent through
a symlink, and measures the unchanged original resolver budget after asynchronous
host capture. No numeric bound, timeout, assertion, retry or skip is relaxed.
The earlier repaired runtime attempt was stopped by the coordinator before a verdict.

After the tooling rebase, the refreshed isolated frozen install passes (191.05
seconds; all 1,577 packages reused). The full focused source-owner suite now
passes all 15 cases, including both replaced-candidate negative controls,
discovery budgets, warm zero-FS, watch reuse/pruning, root close, independent
cancellation and shared rejection/recovery. Vitest reports 443.55 seconds;
the isolated wrapper completes in 514.78 seconds, including worker preparation
(264.234 seconds, 16,759 inputs). The owner cases intentionally exercise real
physical-store/state lifetimes and bounded multi-agent discovery; this is not
a latency improvement claim. Current targeted native types pass (23.68 seconds).
The first official lint attempt used the custom targeted-type config, triggering
plugin-SDK declaration preparation that timed out at its unchanged 300-second
deadline before lint diagnostics. The wrapper explicitly supports a maintained
source-backed core config without that unrelated package preparation. Using that
config with the same three explicit files, type-aware lint passes (163.21 seconds).
Three-file formatting passes (49ms; 1.93 seconds wrapper), and the mandatory
suppression audit passes all 14 cases (40.87 seconds configuration; 75.39 seconds
wrapper). No lint rules, suppressions, retries or timeouts were changed.
The selected existing cross-agent dashboard history/disclosure integration case
also passes (49.958 seconds). It exercises worker history pages and deltas;
the other ten cases were excluded by name filter, not changed to skipped tests.
Vitest reports 201.53 seconds and the isolated wrapper completes in 325.61 seconds,
including reused worker preparation (56.582 seconds). Exact-head PR CI remains
pending after publication. No
performance improvement, live Gateway, deployment or real-state
proof is claimed. Broad architecture/build/platform proof belongs to PR CI.

@clawsweeper

clawsweeper Bot commented Oct 19, 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 labels Oct 19, 2026
@steipete
steipete marked this pull request as ready for review October 19, 2026 01:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T02:02:42.414224Z 46c3d24 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR refreshes session-source discovery in its existing memo, retains common watches, prunes unused watches, and removes unused synchronous preparation.

Example: The ops database at /tmp/retired-watch/ops.sqlite is unregistered while main remains registered.

  • Before: Discovery replaces its memo generation and transfers watch custody through the retired generation.
  • After: Discovery refreshes the same memo, retains common watches, and closes observations unique to the retired ops path.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A coherent, source-reviewed simplification with focused integration evidence; exact-head CI failures remain unclassified.
Proof confidence 🦐 gold shrimp (3/6) Ordinary contributor proof gating does not apply to this maintainer-authored refactor; its reported owner and history integration runs support the change, while the inspected historical screenshots provide no watch-refresh evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Session-history discovery carries unnecessary lifecycle machinery around watches whose reuse prevents Gateway stalls.
Reason: The feature-history owner authored and explained this narrow simplification, including its accepted auxiliary-topology tradeoff; no additional direction decision is needed.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: it simplifies discovery ownership while preserving the measured watch-reuse benefit, and no actionable introduced defect was found.

Priority: P3
Reviewed head: 46c3d24e2768519b26af4f57328bebfc302e984b

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No supplied shipped-entry-point run exercises this refactor's refresh and watch-pruning behavior; the reported evidence is owner-suite and history integration coverage.
Agent review details

How this fits together

Gateway history preparation captures routing, registry entries, and physical candidates; the admitted history worker consumes those facts to resolve auxiliary lineage sources.

flowchart LR
  A[History request] --> B[Gateway discovery memo]
  C[Registry snapshot] --> B
  D[Directory observations] --> B
  B --> E[Admitted history worker]
  E --> F[Physical candidate validation]
  F --> G[History projection]
Loading

Technical review

Best possible solution:

Retain the in-place discovery owner and its existing physical validation, cancellation, shutdown, and watch-pruning contracts.

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

This is a behavior-preserving refactor; inspection confirms the retired-generation chain and unused synchronous acquisition on main, but no target code was executed.

Is this the best way to solve the issue?

The change uses the existing bounded memo and observation owner, removes the replaced path, and retains distinct lifecycle and physical-replacement coverage.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Discovery memo and watch lifetime changes intended behavior with a stated reason (ecd2951: Keep shared native watches alive across discovery generations to avoid measured macOS request stalls.)
  • Retained preparation and wrapper currency checks changes intended behavior with a stated reason (3ac0c05: Retain process-owned discovery facts while preserving physical admission and final authority checks.)
  • Synchronous discovery and returned resolver currency closure changes intended behavior with a stated reason (623f22c: Select auxiliary lineage stores for coordination visibility; subsequent async worker ownership leaves the removed acquisition without production callers.)
  • Worker resolver placement keeps the original intent (750d231: Keep host inventory and observation imports outside history-worker warmup.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source -51, Tests +43. Total -8 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 55 106 -51
Tests 1 90 47 +43
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 145 153 -8

Labels

Label changes:

  • add P3: This is a focused internal cleanup preserving existing history behavior, with no demonstrated urgent user-facing regression.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a focused internal cleanup preserving existing history behavior, with no demonstrated urgent user-facing regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Classify the failed exact-head build, type, and UI jobs using their diagnostics, and resolve any patch-caused failures.

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 October 18, 2026, 10:15 PM ET / October 19, 2026, 02:15 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

Exact head 46c3d24e2768519b26af4f57328bebfc302e984b, CI run
39187864520,
attempt 1, remains failed. I have independently attributed every failing job:

Job ID Inherited signature
build-artifacts 117854377688 UI build: missing SidebarProjectionMemo export
checks-ui-e2e (1/2) 117854377704 Same UI bundling failure, before browser tests
check-prod-types 117855154539 UI TS2724 missing export and consequent TS7006 implicit-any
check-test-types-core-1 117855154509 Same two UI diagnostics
check-test-types-core-2 117855154565 Same two UI diagnostics
check-test-types-core-3 117855154557 Same two UI diagnostics
check-test-types-core-4 117855154569 Same two UI diagnostics
check-test-types-core-5 117855154659 Same two UI diagnostics
openclaw/ci-gate 117855806405 Downstream aggregate of those eight roots

The actual tested merge 003bc6badbba5f82e65d3fb8f174b778b591d73e has ordered
parents main af1e1fe8d46549a344dffef1f2f6d710a714f0a2 and the exact PR head;
its tree equals a clean merge of those parents. All three determining UI modules
are byte-identical to that main baseline and to main c2549f8295d, the baseline
reproduced by the independently merged repair #176799.
That repair changes only the stale import to the existing cache module, with
recorded baseline build/type reproduction and passing targeted UI proof. None
of this PR's three Gateway discovery paths changes the failing UI owners.

The automated classification compares an older scheduled main and therefore
labels these new/unknown; that table is not being claimed as matching-signature
evidence. The actual failing diagnostics, unchanged baseline source and merged
main repair establish the inherited regression. I also checked the coordinator
flake register and the last six completed scheduled main failed-job maps.

All 63 attempt jobs and 192 exact-head checks are terminal; independent
security-fast passes. The cancelled ancillary response has a successful
same-head successor, and no executable suite is missing. Focused discovery,
real history/disclosure, native targeted types, maintained lint, formatting and
the suppression audit pass. The original failed CI stays recorded as failed;
no rerun, green repush, broad local build or underlying UI repair is claimed.
Proceeding through the native inherited-only exception with the exact-head guard.

@steipete
steipete merged commit aee5448 into main Oct 19, 2026
193 of 204 checks passed
@steipete
steipete deleted the deslop/z02-20-store-sources-20261015 branch October 19, 2026 04:09
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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