Repository navigation
fix(x): stream mentions through the Activity API instead of polling - #165337
Conversation
Keep the app bearer for listing subscriptions and opening the Activity stream. Create mention subscriptions with the refreshed user OAuth token, and report bounded, credential-redacted X error details when falling back to polling. Stream HTTP 401 and 403 also fall back with the detailed reason. Document token ownership and fallback status. Validation: 71 X tests passed in 79.67 seconds wall time; extension production and test typechecks, typed lint, formatting, and diff checks passed. Autoreview was scoped-clean through P2.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed October 5, 2026, 1:24 AM ET / 05:24 UTC (Revision 2). ClawSweeper reviewWhat this changesThe X plugin creates mention subscriptions with the bot’s user token, reads the documented Activity event envelope, and reports credential-redacted polling fallback reasons. Merge readiness⛔ Blocked before merge - 2 items remain The prior delivery finding is resolved, and current main still needs this fix. No new actionable code defect was found; authenticated X contract validation remains outstanding. Likely related people: steipete (high confidence, prior merged X plugin work). Priority: P1 Review scores
Verification
How this fits togetherThe X plugin receives mentions through Activity streaming or polling, verifies the recipient, and queues them for an allowlisted agent conversation. The agent’s answer becomes a public X reply. flowchart TD
A[Bot credentials] --> B[Activity subscription setup]
B --> C[Activity stream]
B --> D[Polling fallback]
C --> E[Recipient checks]
D --> F[Durable mention queue]
E --> F
F --> G[Allowlisted agent turn]
G --> H[Public X reply]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +47, Tests +140, Docs +19. Total +206 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one X transport owner with documented token selection, recipient filtering, reconnect backfill, and polling fallback, validated against authenticated X delivery. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main sends an app bearer when creating a private mention subscription, contrary to X’s documented OAuth contract. The captured body also records the original live rejection; this review did not execute X requests. Is this the best way to solve the issue? Yes. Correcting token selection and the event envelope inside the existing transport is a focused repair that preserves recipient checks and fallback; authenticated contract validation is still needed. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 56acd8ce050e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Read mention posts and event types from the documented data envelope, reuse the existing post validator, and preserve recipient checks and reconnect backfill. This prevents successful subscription setup from replacing working polling with a stream that silently ignores mentions. The documented-envelope regression failed on the old parser. All 71 X tests pass in 101.38 seconds wall time; extension typechecks and targeted lint pass. Independent review found no P0-P2 code defects in the final working-tree candidate; its index-only finding was resolved by staging the exact reviewed files.
|
Merged via squash.
|
…penclaw#165337) * fix(x): use user tokens for Activity subscriptions Keep the app bearer for listing subscriptions and opening the Activity stream. Create mention subscriptions with the refreshed user OAuth token, and report bounded, credential-redacted X error details when falling back to polling. Stream HTTP 401 and 403 also fall back with the detailed reason. Document token ownership and fallback status. Validation: 71 X tests passed in 79.67 seconds wall time; extension production and test typechecks, typed lint, formatting, and diff checks passed. Autoreview was scoped-clean through P2. * fix(x): consume documented Activity event envelopes Read mention posts and event types from the documented data envelope, reuse the existing post validator, and preserve recipient checks and reconnect backfill. This prevents successful subscription setup from replacing working polling with a stream that silently ignores mentions. The documented-envelope regression failed on the old parser. All 71 X tests pass in 101.38 seconds wall time; extension typechecks and targeted lint pass. Independent review found no P0-P2 code defects in the final working-tree candidate; its index-only finding was resolved by staging the exact reviewed files.
What Problem This Solves
Fixes X mention subscriptions being rejected with
OauthAccessTokenRequired, forcing the plugin into polling with delays of up to a minute.User Impact
Mentions can use the Activity stream instead of waiting for the polling interval. When X refuses Activity access, channel status includes its actual rejection reason with credentials redacted.
No configuration keys or migration are required. The bot's user OAuth grant must include
tweet.read. Live delivery latency has not been measured after this fix.Why This Change Was Made
X requires user OAuth for
post.mention.createsubscription creation. Create subscriptions with the refreshed user access token while retaining the app bearer for subscription listing and the persistent stream.Successful subscription setup must also preserve delivery: consume X's documented
data.event_typeanddata.payloadenvelope through the existing post validator and recipient checks. Other event types are ignored; reconnect backfill and polling fallback remain intact.Evidence
Maintainer-reported live reproduction on 2026-10-05: X returned HTTP 400
OauthAccessTokenRequiredwhen creating the mention subscription with the app bearer. This establishes the original failure, not a successful post-fix live stream.X's Activity authentication documentation, stream quickstart, and event payloads define the token and envelope contracts used here.
Regression reproduced before the parser correction: both documented-envelope recipient-hydration cases failed because the event transport admitted no posts. The correction passes these cases and tests subscription creation followed by chunked live-stream input, recipient filtering, ignored non-mention events, keep-alives, cursor advancement, and reconnect backfill.
Corrected candidate:
pnpm test extensions/x --maxWorkers=1passed 71 tests in 8 files, 101.38 seconds wall time. Both extension typechecks, targeted typed lint, formatting, and diff checks passed. Individual file runs: 13 event tests in 11.34 seconds wall time; 15 API tests in 9.38 seconds. Native review checkout at89144ec10520: 71 tests in 8 files passed, 107.91 seconds wall time. The supported SDK-build preparation timeout was increased; test deadlines were unchanged.The original implementation passed the same 71 tests in 79.67 seconds, both extension typechecks, typed lint, formatting,
git diff --check, and the full build. The build reported an existing advisory UI bundle overage of 49 bytes. CI run 37264606876 passed on the original authentication-only head; it is prior-head evidence, not validation of the parser correction.ClawSweeper's initial P1 finding was accepted: authentication success could activate a parser that dropped documented events. The correction removes that incompatible parser path. The earlier scoped-clean review covered the authentication-only candidate; fresh review found no P0–P2 code defects in the complete working-tree candidate. Its sole index-only finding was resolved by staging the exact reviewed correction; no source bytes changed after review.
Final-head CI 37267188832 passed at
89144ec10520in 373 seconds elapsed; its changed-test job took 107 seconds including setup. No CI reruns or inherited-red exception were needed.ClawSweeper revision 2 confirms the delivery finding is resolved and reports no new actionable code defect. Its remaining request is authenticated live proof. Maintainer disposition: land within this work order’s non-deployment scope using the reported live rejection, published X contracts, failing-before/passing-after transport regression, local checks, and exact-head CI; retain the post-fix live-proof gap below.
Validation is at the real event-transport boundary with synthetic HTTP/stream inputs matching X's documented contract. No deployment or post-fix authenticated X subscription/delivery test has been performed. No UI layout changes or UI captures.