Repository navigation
fix(feishu): keep probe and streaming-backoff windows on elapsed time - #192308
wangmiao0668000666 wants to merge 3 commits into
Conversation
|
🦞👀 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: needs real behavior proof before merge. What this changesThis PR measures Feishu probe-cache expiration and streaming-start backoff with monotonic time. Example: The host clock moves forward 20 minutes immediately after a successful Feishu health probe.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR narrowly fixes clock-sensitive Feishu windows that remain on current main, and both earlier findings are addressed. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Feishu plugin caches health-probe responses and temporarily suppresses streaming-card starts after failures; these windows control subsequent Lark API requests. flowchart TD
A[Gateway health checks] --> B[Feishu probe cache]
B --> C[Lark HTTP client]
D[Agent reply] --> E[Streaming backoff]
E --> F[Streaming card or fallback]
F --> C
Technical reviewBest possible solution: Keep the paired monotonic deadline substitutions in the existing Feishu owners, preserving durations, credential scoping, and epoch-based message checks. Do we have a high-confidence way to reproduce the issue? Current main derives both process-local deadlines from Date.now(), so forward and backward wall-clock corrections directly alter their effective lifetime; the contributor also reports a discriminating base/candidate probe transport run. Is this the best way to solve the issue? The patch is the smallest complete clock-domain repair: each existing deadline writer and reader moves together, with one distinct probe regression and an updated streaming fixture. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 40b3be0b302d. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests +22, Other +2. Total +24 across 5 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 3, 2026, 7:54 PM ET / November 4, 2026, 00:54 UTC (Revision 2). |
The streaming-start failure backoff window is monotonic (performance.now); the old Date.now spy no longer advances it. Point the spy at performance.now and add a test-lines allocation for the new probe clock-step coverage. Co-Authored-By: nebulacoder-v8.0 <[email protected]>
|
@clawsweeper re-review — the Evidence section now includes real-transport proofs (shipped RequestClient/DISCORD_API_URL stub for Discord, shipped Lark SDK over HTTPS_PROXY CONNECT tunnel for Feishu, real imsg CLI subprocess via runCommandWithTimeout for iMessage), red on base / green on candidate with stub hit counts. Voice/streaming changes remain honestly noted as not remotely runnable (missing libopus/mdast in the remote dependency closure). |
|
🦞👀 Re-review progress:
|
…192469) fix: measure three more cache and retry deadlines with the monotonic clock Three more deadlines used the wall clock: the Claude catalog filesystem scan cache, a browser extension cache with a 5-minute expiry, and Feishu streaming fallback retry. After the clock moved, they expired early or too late. They now use the monotonic clock. Behavior without a clock change is unchanged. This sweep includes #192122, #192422 and #192308, with the contributors' commits kept for credit. Evidence: built shipped entry points, stepping only the process wall clock (no system clock change). Each member was wrong on main twice and right with this change twice, with no-step controls: real Claude catalog filesystem scans; real Chromium with an unpacked extension and a 301-second real expiry; and a signed Feishu webhook with real agent dispatch and a natural streaming HTTP 400 fallback with a 61-second real retry. Details: #192469 (comment). Thanks @wangmiao0668000666. Co-authored-by: wangmiao0668000666 <wangmiao0668000666> Co-authored-by: nebulacoder-v8.0 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#192469) fix: measure three more cache and retry deadlines with the monotonic clock Three more deadlines used the wall clock: the Claude catalog filesystem scan cache, a browser extension cache with a 5-minute expiry, and Feishu streaming fallback retry. After the clock moved, they expired early or too late. They now use the monotonic clock. Behavior without a clock change is unchanged. This sweep includes openclaw#192122, openclaw#192422 and openclaw#192308, with the contributors' commits kept for credit. Evidence: built shipped entry points, stepping only the process wall clock (no system clock change). Each member was wrong on main twice and right with this change twice, with no-step controls: real Claude catalog filesystem scans; real Chromium with an unpacked extension and a 301-second real expiry; and a signed Feishu webhook with real agent dispatch and a natural streaming HTTP 400 fallback with a 61-second real retry. Details: openclaw#192469 (comment). Thanks @wangmiao0668000666. Co-authored-by: wangmiao0668000666 <wangmiao0668000666> Co-authored-by: nebulacoder-v8.0 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Maintainer edits
Maintainer edits to this branch are welcome and will not be overwritten; the author will not force-push over them.
Maintainer options
extensions/feishu), behavior-preserving clock-domain substitution at four private timestamp sites, deterministic red/green on base. No config, API, schema, or state change.monotonicNow()owner (extensions cannot depend on core internals — the established extension shape is inlineperformance.now(), e.g. fix: keep probe timings and cache windows stable across clock corrections #190894, fix(codex): keep plugin metadata cache on elapsed time #191533); change TTL durations (out of scope — durations unchanged).probe.ts, 10-min success / 60-s error TTL) and the streaming-start failure backoff (reply-dispatcher.ts, 60 s). The message-create epoch comparison inreply-dispatcher.ts:190(Date.now() - messageCreateTimeMs) is deliberately untouched — it is an epoch-vs-epoch elapsed check on a stored message timestamp, which the fix: keep probe timings and cache windows stable across clock corrections #190894 sweep keeps on the wall clock.What Problem This Solves
A host wall-clock correction while the Gateway runs makes two Feishu process-local cache/backoff windows jump with it: the health-probe result cache (
probe.ts) and the streaming-start failure backoff (reply-dispatcher.ts). A forward step expires a fresh 10-minute probe entry and reissues thebot/v3/infoAPI call (burning Feishu's free-tier quota on duplicate health checks), and clears the 60-second streaming backoff early; a backward step keeps entries and backoff alive far past their intended elapsed windows.Precedent: #190894 (same shape — wall-clock cache/backoff windows →
performance.now()in extensions; this PR covers the Feishu sites that sweep left behind). Sibling: #191911, #191916 (same Feishu extension, bot-name/sender-name caches), #191210, #192122, #192144, #192293, #192296.Why This Change Was Made
extensions/feishu/src/probe.tskeepsprobeCacheas a process-local map whose timestamps never leave the module;extensions/feishu/src/reply-dispatcher.ts'sstreamingStartBackoffUntilByAccount(inreply-dispatcher-state.ts) is the same. The read and write sites now share the elapsed-time domain (performance.now()), the only domain a wall-clock step cannot shift; switching one side alone would mix clock domains, so each window's sites move together. Known trade-off, identical to the core stale-while-revalidate cache owner: monotonic windows measure awake time, so system suspend pauses them. Fix classification: behavior-preserving (clock domain only; no TTL, owner, config, or API change).User Impact
On a long-running Gateway whose clock is corrected (NTP step, manual change, VM resume), Feishu health checks either lose the cached probe result and spend free-tier API quota on duplicate
bot/v3/infocalls (or a failed probe is retried immediately instead of after its 60-second error window), or keep serving stale probe verdicts and suppressing streaming beyond their windows. TTL values and backoff durations are unchanged.Evidence
Base
be881a7f8b1ff5af7ff7783340c98ed9047ea450→ candidate8773efbdc3a6f00d95fa4fbb40fb258db6c3c651, same commands. The wall step is a process-localDate.nowoffset under fake timers (the #190894/#188293 preload method), never an OS clock jump.Deterministic regression in the existing suite (remote Node 24.22.1 container,
vitest.extension-feishu.config.ts):extensions/feishu/src/probe.test.tsexpected "vi.fn()" to be called 1 times, but got 2 times: the forward step expires the 10-minute window and reissues the bot-info request)The new test seeds a successful probe through the real
probeFeishu(real client factory, request mocked), then stepsDate.now()forward 20 minutes — past the 10-minutePROBE_SUCCESS_TTL_MSwindow — and asserts the cached result is still returned without a second bot-info request. On base (wall-clock window) the step expires it; on candidate (monotonic window) it stays fresh.Real-transport proof (shipped Lark SDK over HTTPS proxy)
The discriminant also runs through the extension's real transport — the shipped
createFeishuClient(Lark SDK on the extension's own HTTP transport) making a real HTTPS request through an ambientHTTPS_PROXYto a local CONNECT stub that counts tunnel connections, then forwarding to a TLS origin stub (remote Node 24.22.1 container,proof.test.ts):extensions/feishu/src/proof.test.tsDate.now)performance.now)The wall step is again a process-local
Date.nowoffset (the #190894 preload method). No mocks on the transport:probeFeishu→ realcreateFeishuClient→ real TLS handshake through the proxy to the stub.Scope and risk
+4/−4(4 sites, 2 files)+22performance.now()) from fix: keep probe timings and cache windows stable across clock corrections #190894/fix(codex): keep plugin metadata cache on elapsed time #191533; no new helper or abstraction.reply-dispatcher.ts) has no remote-runnable suite here — its test pullsmdast-util-from-markdown(viamarkdown.ts) which the remote dependency closure lacks. The change is the same two-site clock-domain substitution as the provenprobe.tschange (same read/write symmetry), andstreamingStartBackoffUntilByAccountis a plain in-memoryMap<string, number>(grep-verified,reply-dispatcher-state.ts). The existingreply-dispatcher.test.tscovers the backoff path under fake timers.