Skip to content

fix(x): backfill mentions during Activity streaming and flag unparseable events - #165376

Merged
steipete merged 2 commits into
mainfrom
steipete/x-stream-payload
Oct 5, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/x-stream-payload

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Related: #165337

What Problem This Solves

Fixes missed X mentions when an Activity stream stays connected without delivering every event, and makes repeated unparseable events visible to operators.

User Impact

Streaming checks for missed mentions every four polling intervals (at least 60 seconds; 240 seconds by default), while the existing ingress queue deduplicates posts delivered by both paths. Three consecutive unparseable mention events or malformed lines produce one content-free warning and channel status message, cleared by the next good mention. Blank keep-alives and intentionally ignored event types do not count.

Why This Change Was Made

A connected stream previously backfilled only on connection. Periodic backfill now uses the existing mentions API and ingress admission paths. Only completed backfills advance the durable cursor, so a newer streamed post cannot hide an older missing mention from the next poll. There is no new configuration key; additional reads use the X API pricing described in the channel docs.

The existing documented-envelope parser and recipient verification are unchanged. The rebase also preserves the allowlist revocation fence introduced on main.

No persistent format or schema changes: x.cursor still stores { userId, sinceId }, and ingress payload version 1 is unchanged. The monitor regression starts with the existing saved cursor and proves recovery/deduplication using that state. No migration is required.

Evidence

  • Fake-timer regressions prove 60-second and 240-second backfill intervals, recovery of an older missed mention after a newer stream event, one admission/reply for duplicate delivery, the exact three-line warning threshold, ignored event filtering, content-free diagnostics, and recovery on a good mention. The false-warning regression failed before the correction.
  • Native review checkout at 5529f1f3cac7ccdbec95bcc07236b069a1c9f298: pnpm test extensions/x --maxWorkers=1 passed 81 tests across 9 files in 121.72 seconds wall time. The development checkout also passed all 81 tests in 229.67 seconds.
  • Per-file cost: the event file passed 14 tests in 9.17 seconds wall time; the unchanged monitor file passed 11 tests in 77.55 seconds. Worker preparation dominates monitor wall time; test cases themselves stay below one second.
  • Both extension typecheck lanes, typed lint on all five changed TypeScript files, oxfmt --check, git diff --check, and docs MDX validation passed. SDK declaration preparation needed the supported longer preparation budget after an initial timeout; no checks were skipped.
  • Codex autoreview of the complete corrected candidate was scoped-clean through P2. ClawSweeper revision 2 confirms the previous finding is fixed and reports no actionable code defect. Its remaining generated migration checklist is inapplicable: its own technical review confirms no stored format/schema changes, and compatibility is described above.

CI run 37276033172 tested this exact head merged with main. The X job passed 102 tests across 11 files, including the landed guest-mode tests, in two Vitest shards of 11.65 and 13.49 seconds (106 seconds total job time). X/extension typechecks, typed lint, docs, package boundaries, and security-fast passed.

Inherited CI exception: check-test-types-core-5 failed on src/gateway/server-lifecycle.catalog-write.test.ts:162 with TS2739 because the existing fixture omits resolveGatewayContext and loadSubagentRegistryActivation. The fixture and server-startup-observers.ts signature owner are byte-identical in baseline fdd3a97f23ef, tested merge c20186e44d83, and independently inspected main bbaabd6ced15; this PR changes neither file. Fail-fast then cancelled production types and core test-types stripe 2, and the aggregate failed. Those cancelled checks are not claimed as passing. Native landing retains the exact checkout, source-identity, failure, and cancellation evidence for the authorized inherited-failure exception; no CI rerun or proof-only push was made.

Validation uses simulated X responses and the existing host queue double. No authenticated live X delivery test or deployment was performed, and no full local pnpm build was run.

@clawsweeper

clawsweeper Bot commented Oct 5, 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 docs Improvements or additions to documentation channel: x size: M labels Oct 5, 2026
@steipete
steipete marked this pull request as ready for review October 5, 2026 06:17
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 3:46 AM ET / 07:46 UTC (Revision 3).

ClawSweeper review

What this changes

The X plugin periodically backfills missed mentions during streaming and reports repeated malformed mention events without exposing post content.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still lacks periodic recovery during a connected Activity stream. The prior parser finding is resolved, and this review found no new actionable defect or migration requirement.

Priority: P2
Reviewed head: 5529f1f3cac7ccdbec95bcc07236b069a1c9f298

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused reliability repair with useful regression coverage, resolved prior feedback, and no new actionable defect.
Proof confidence 🌊 off-meta tidepool Not applicable: Verified repository-admin authorship exempts this PR from the external-contributor proof gate. The event and monitor regressions exercise simulated stream/backfill recovery and warning output, not authenticated live X delivery. Existing cursor and ingress formats remain compatible, with saved-cursor coverage supporting the no-migration case.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Verified repository-admin authorship exempts this PR from the external-contributor proof gate. The event and monitor regressions exercise simulated stream/backfill recovery and warning output, not authenticated live X delivery. Existing cursor and ingress formats remain compatible, with saved-cursor coverage supporting the no-migration case.
Evidence reviewed 10 items Pinned introduction: Reviewed the complete merge-base-to-head patch. Production changes are confined to event recovery, parser diagnostics, and the monitor warning callback; current-main guest-mode changes are base drift, not PR-introduced removals.
Still necessary on main: Current main backfills only when opening a stream and advances the cursor on individual streamed posts. It does not contain the introduced periodic backfill or parser-warning streak.
Prior finding resolved: The corrected parser skips intentionally ignored event types before incrementing the failure count. The regression exercises ignored events, blank keep-alives, the third-failure threshold, content-free warnings, and recovery after a valid mention.
Findings None None.
Security None None.

How this fits together

The X plugin receives bot mentions through Activity streaming and the mentions API. Both paths feed the existing deduplicating ingress queue, which checks sender access before dispatching agent turns and public replies.

flowchart TD
  A[Activity stream] --> C[Mention validation]
  B[Periodic mentions backfill] --> D[Deduplicating ingress queue]
  C --> D
  C --> E[Parser warning and channel status]
  D --> F[Current sender authorization]
  F --> G[Agent turn and public reply]
  B --> H[Completed backfill cursor]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +45, Tests +186, Docs +10. Total +241 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 2 53 8 +45
Tests 3 190 4 +186
Docs 1 11 1 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 254 13 +241

Review metrics

Metric Value Why it matters
Streaming recovery interval 240 seconds by default; 60-second minimum; 0 new settings The recurring API reads reuse the existing polling setting, and their cost is documented.
Production versus test growth production net +45 lines; tests and support net +186 lines Production growth implements periodic recovery and bounded diagnostics; regressions cover missed-post recovery, deduplication, and warning behavior.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/x/src/events.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Keep recovery in the existing mentions and ingress owners, with only completed backfills advancing the cursor and diagnostics excluding intentionally ignored events.

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

Yes, from source: a connected stream can omit an older mention while a newer streamed post advances main's cursor past it. The saved-cursor regression exercises that scenario; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. Reusing the existing mentions API and deduplicating ingress queue avoids a competing delivery owner, and retaining the cursor until backfill completes addresses the gap directly.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded X transport reliability repair with focused regression coverage and no demonstrated core outage.
  • 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: Verified repository-admin authorship exempts this PR from the external-contributor proof gate. The event and monitor regressions exercise simulated stream/backfill recovery and warning output, not authenticated live X delivery. Existing cursor and ingress formats remain compatible, with saved-cursor coverage supporting the no-migration case.

Evidence

What I checked:

  • Pinned introduction: Reviewed the complete merge-base-to-head patch. Production changes are confined to event recovery, parser diagnostics, and the monitor warning callback; current-main guest-mode changes are base drift, not PR-introduced removals. (extensions/x/src/events.ts:118, 5529f1f3cac7)
  • Still necessary on main: Current main backfills only when opening a stream and advances the cursor on individual streamed posts. It does not contain the introduced periodic backfill or parser-warning streak. (extensions/x/src/events.ts:116, 599bcd79e5ae)
  • Prior finding resolved: The corrected parser skips intentionally ignored event types before incrementing the failure count. The regression exercises ignored events, blank keep-alives, the third-failure threshold, content-free warnings, and recovery after a valid mention. (extensions/x/src/events.ts:175, 5529f1f3cac7)
  • Existing-state compatibility: The cursor remains { userId, sinceId }, and raw ingress payload version 1 is unchanged. The added monitor regression starts from saved cursor 500, streams newer post 502, recovers missing post 501, and asserts one reply per post plus cursor 502. This supports compatibility without a migration; the fixture does not establish SQLite crash durability. (extensions/x/src/monitor.test.ts:63, 5529f1f3cac7)
  • Security and authority boundary: Periodic polling uses the existing mentions client and ingress admission callback. Recipient verification, current sender authorization, and final reply authorization remain unchanged; no dependency, permission, credential, or public plugin API changes are introduced. (extensions/x/src/monitor.ts:242, 5529f1f3cac7)
  • Trusted-author proof exemption: GitHub verifies steipete has repository admin access, resolving the inconsistent association fields in the supplied context. The captured PR body explicitly describes simulated X responses and queue doubles and states that no authenticated after-fix X delivery test occurred. (5529f1f3cac7)

Likely related people:

  • steipete: 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-10-05T06:22:15.258Z sha 966663c :: blocked before merge. :: [P2] Exclude intentionally ignored event types from parser failures
  • reviewed 2026-10-05T07:14:35.751Z sha 5529f1f :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 5, 2026
@steipete
steipete merged commit fbdb27a into main Oct 5, 2026
119 of 124 checks passed
@steipete
steipete deleted the steipete/x-stream-payload branch October 5, 2026 07:52
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…ble events (openclaw#165376)

* fix(x): backfill mentions during Activity streaming and flag unparseable events

* fix(x): ignore unrelated Activity events in parse diagnostics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: x docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. 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