Skip to content

fix(control-ui): replace stale logs after Gateway restarts - #172932

Closed
steipete wants to merge 3 commits into
mainfrom
fix/logs-reconnect-boot-cursor
Closed

steipete wants to merge 3 commits into
mainfrom
fix/logs-reconnect-boot-cursor

Conversation

@steipete

@steipete steipete commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #172828 (65023f793e3f4215921cff8dd1d8611e6d0b98e9), which places the same boot-aware cursor behavior in the loadLogs owner. Historical proof is preserved below.

What Problem This Solves

Fixes stale log rows and missing new records after a Gateway restarts with a replaced log file.

User Impact

The Control UI Logs page replaces its old window after a Gateway restart while retaining efficient incremental reads for reconnects to the same known Gateway boot. Failed refreshes keep the existing rows visible and retry safely.

Why This Change Was Made

The reconnect optimization in #172864 reused a byte cursor across Gateway restarts. That cursor can point into an unrelated record when the log file is replaced at the same path. Bind cursor reuse to the existing Gateway boot ID, and clear the cursor before requesting a fresh window when the boot changes or is unknown. Clearing it before the request also keeps a subsequent poll safe if the refresh fails.

Evidence

  • Existing real-Gateway regression: Logs lifecycle failure, on tested merge c3414361b698d0362a2acee00b3eafdd32b8f4fc. The unchanged test replaces the log file while the Gateway is stopped and then verifies the new window after restart.
  • Extended the existing reconnect test to cover the same boot, a changed boot, a missing boot ID, and a failed refresh followed by polling. pnpm test ui/src/pages/logs/logs-page.test.tsx --maxWorkers=1: all 18 tests passed.
  • Production UI types, the exact changed test-file typecheck, two-file lint, pinned formatter, and whitespace checks passed. Independent review found no actionable P0–P2 issues; a subsequent fixture-only correction supplied required hello authentication metadata.
  • Fresh frozen install and UI typecheck passed after merging main 435deb1c1386f0aeb9c42c772233aaf8481ffe30. The complete two-file authored patch is byte-identical to the reviewed patch, so the 18-test result and independent review are reused. No current-head CI result is claimed for b7d07e1c2ffc83f897d47d3fedf080da18b94d39.
  • Previous-head CI run 38712489630, attempt 1 on 4ae97565112a9fad04c321177cac8cb2948dd754, completed with 33 successful, 26 skipped, and 5 failed jobs. The real-Gateway shard containing the unchanged Logs restart regression passed again; security-fast also passed.
  • The five failing test cases are the two spawned-session nesting variants, native-pointer promotion, the session PR reader's hidden #203 chip, and a stale PR-chip label expectation (#103469 versus openclaw/openclaw#103469), plus the aggregate gate. Their complete visible failure blocks match historical scheduled main run 38713991924. All 57 traced failure-determining source, fixture, runner, and configuration inputs are identical across the actual CI base, tested merge, and that main baseline. Provider-redacted values remain unknown. This is historical attribution for the previous head, not current-head gate evidence.
  • No local build or E2E run was performed for this behavior-only correction.

Bind incremental log cursors to the existing Gateway boot ID. Preserve same-boot reconnect reuse, reset for changed or unknown boots, and keep failed reset retries cursor-free. Extend the existing reconnect test across all four cases.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 15, 2026
@clawsweeper

clawsweeper Bot commented Oct 15, 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.

@steipete
steipete marked this pull request as ready for review October 15, 2026 08:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-15T12:08:39.213786Z b7d07e1 New commits
ℹ️ 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 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses log cursors only across reconnects to the same known Gateway boot.

Example: The Logs page holds cursor 100 for /tmp/gateway.log when boot-a restarts as boot-b with a larger replacement file.

  • Before: The page resumes at byte 100, potentially skipping new records and retaining old rows.
  • After: The page requests a fresh window and replaces old rows; a failed refresh preserves visible rows while leaving subsequent polling cursor-free.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported correction with useful lifecycle coverage and no actionable findings; demonstrated after-fix coverage is currently unit-level.
Proof confidence 🦐 gold shrimp (3/6) The host identifies this as maintainer-authored, so the ordinary contributor proof gate does not apply; supplied after-fix evidence covers mocked page lifecycle tests, while real-Gateway restart CI is still running and no live output is supplied.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: After a Gateway restart, the Logs page can retain obsolete rows and omit records from the replacement log file.
Reason: The maintainer-authored correction restores the existing log-window contract without adding settings, APIs, or another state owner.

Regression provenance

Regression provenance — verified: source commit 1f862d198912 by Peter Steinberger; canonical PR #172864 (blame-to-merge-commit).

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it narrowly repairs a source-verifiable restart regression that remains on fetched main, and no introduced correctness or security defect was found.

Priority: P2
Reviewed head: e359f0b25edbd6d3a2a09b33e60f907488a3a896

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The after-fix real-Gateway restart scenario remains pending, and a failing-base run of the extended unit table is not supplied.
Agent review details

How this fits together

The Control UI Logs page consumes Gateway connection snapshots and logs.tail responses, maintaining a bounded visible log window and an in-memory byte cursor.

flowchart LR
  A[Gateway boot identity] --> B[Connection snapshot]
  B --> C[Logs page]
  C --> D[logs.tail request]
  D --> E[Configured log file]
  E --> F[Redacted log window]
  F --> C
Loading

Technical review

Best possible solution:

Keep cursor invalidation in the existing Logs page owner and preserve incremental reads only for the same known boot.

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

Source establishes the failure when a restarted Gateway replaces its log file with one larger than the retained cursor; no target code was executed during this review.

Is this the best way to solve the issue?

The fix addresses cursor ownership directly, retains the intended same-boot optimization, and clears invalid state before an awaited refresh so polling can recover after failure.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Reconnect cursor reuse changes intended behavior with a stated reason (1f862d1: Avoid rereading and redacting the full log window on every same-Gateway reconnect.)
  • Logs page lifecycle and request ownership keeps the original intent (7dd5b52: Port the existing Logs route to Solid while preserving controls and using the shared connection adapter for stale-result rejection.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

PR surface

Source +6, Tests +54. Total +60 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 8 2 +6
Tests 1 71 17 +54
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 79 19 +60

Labels

Label changes:

  • add P2: The regression affects the diagnostic log window after restart; manual refresh provides an existing in-product recovery.
  • 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:

  • P2: The regression affects the diagnostic log window after restart; manual refresh provides an existing in-product recovery.
  • 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.

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 15, 2026, 4:24 AM ET / 08:24 UTC.

Integrate current main after GitHub continued reporting unknown mergeability. Preserve the reviewed Logs restart cursor patch unchanged.
@steipete

Copy link
Copy Markdown
Contributor Author

Superseded by #172828, landed as 65023f7. Its Logs repair places boot tracking in loadLogs, so requests do not reuse a cursor from another boot and the boot is recorded with a new cursor only after a successful response. This covers the cases asserted here: same-boot incremental reads, changed or disappearing boot IDs, and cursor-free polling after a failed refresh while retaining the previous rows.

The upstream regression, retries a changed boot from the start while retaining stale rows until replacement, also exercises the pending refresh, visible error, and successful retry. Comparing both complete fixes against current main found no distinct remaining fix in this PR. The historical 18/18 scoped test result and prior CI evidence remain in the description. Closing in favor of the landed loadLogs owner.

@steipete steipete closed this Oct 15, 2026
@RomneyDa
RomneyDa deleted the fix/logs-reconnect-boot-cursor branch October 22, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui ci:full Keep ordinary native-locale CI selection on the next PR run. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant