fix(#12265): fallback-slop sweep (packages/agent) — media-store fast-fail + page-scoped-context reported degrades - #12766
Conversation
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Local verification from my side:
Not merging from this pass because GitHub checks are still queued/unstable and the new |
4d77cfb to
a9d5f9c
Compare
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
a9d5f9c to
4da82d3
Compare
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
4da82d3 to
63e7140
Compare
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
…, annotate justified handlers media-store: readStoredMediaBytes / writeStoredMediaFile no longer swallow a real fs error into a fabricated "media not found" / "restored fewer files". Absence still returns null/false; a genuine read/write failure (EACCES/EIO/ ENOSPC) throws a typed ElizaError (MEDIA_STORE_READ_FAILED / _WRITE_FAILED) so it surfaces at the export/import boundary instead of silently corrupting a backup. The file's remaining best-effort/parse/degrade handlers are annotated J3/J4/J6. page-scoped-context: the browser + automations live-state subsections and the provider boundary now report their failures via runtime.reportError (feeding RECENT_ERRORS / owner escalation) while still degrading gracefully; the fetchLocalJson port-failover empty catch is annotated J4 (exhaustion already renders an explicit "unavailable" line). Real-fs error-path tests induce the failures without mocking the thing under test; existing media-store + agent-export tests stay green. Refs #12265 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
63e7140 to
6896667
Compare
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
…/fabricated-default/promise-swallow to fail-fast Deep re-sweep of the remaining fallback-slop in packages/agent after the headline files were handled by #12766 / #12921. Empty-catch count in this slice is already 0; this pass targets the log-and-return-empty catches that make a broken pipeline read as a legitimately-empty result, plus fail-closed swallows. Converted (behavior-changing, fail-fast; each with a real error-path test): - providers/recent-conversations.ts + relevant-conversations.ts: on a recall failure both providers returned the IDENTICAL empty context as a legit-empty recall (the banned "not loaded reads as empty" conflation). Now runtime.reportError surfaces the broken pipeline via RECENT_ERRORS while the provider still degrades to empty (annotated error-policy:J4). Removed the now-unused logger imports (logger-only rule still holds; reportError logs). - security/access.ts hasPrivateAccess: a throw from the core private-access check was silently swallowed to `return false` — fail-closed is correct, but a broken role/world-resolution pipeline would deny forever with no signal. Now reports via runtime.reportError and stays fail-closed (error-policy:J4). Annotated (evaluated, kept — not slop): - api/views-registry.ts ×2 indexView `.catch(() => {})`: indexView self-degrades (its own catch logs and falls back to keyword search); the call-site catch only suppresses a stray pre-embed rejection so a background task cannot crash the loop (error-policy:J5). Deferred (ambiguous absence-vs-failure, per this wave's scope): bare `return null/[]/false` catches and `?? <lit>` defaults where legitimate-absence cannot be cleanly distinguished from masking-a-failure. Tests: 6 new fast-fail assertions across 3 files (recent-conversations, relevant-conversations.faildast, access) — all green; each asserts reportError fires on the real failure AND that a legit-absence path does NOT report. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Part of #12182 (fallback-slop sweep). Batch: packages/agent (#12265). Base:
develop@c0c2ddf374.This is a precision slice of the ~444-suspect-site batch, not a completeness pass: it converts the two highest-confidence data-loss slop sites the issue calls out by name (media-store I/O) and upgrades the page-scoped-context provider's silent degrades to reported degrades, then annotates every justified handler it keeps. The high-risk boot path (
runtime/eliza.ts) and the long?? <lit>tail are intentionally deferred (sitesLeft).Re-derived suspect counts (packages/agent, this tree)
.catch(()=>{}))?? <lit>|| <lit>Site table — verdicts (2 files touched)
api/media-store.tsreadStoredMediaBytestry/catch → return nullthrow ElizaError("MEDIA_STORE_READ_FAILED", {cause})(exemplar #2)api/media-store.tswriteStoredMediaFiletry/catch → return falsethrow ElizaError("MEDIA_STORE_WRITE_FAILED", {cause})api/media-store.tsmaybeEvict(×3)api/media-store.tsgcUnreferencedMedia(×2)api/media-store.tslistMediaFiles(×2)api/media-store.tstouchOnServeapi/media-store.tspersistDataUrlcatch → nullapi/media-store.tsreadBackgroundPinscatch → []api/media-store.tspinBackgroundMediaapi/media-store.tsresolveMediaFiledecodecatch → 400api/media-store.tsresolveMediaFilestatcatch → 404api/media-store.tspersistImageThumbnail/ensureThumbnailForStoredFilecatch → nullapi/media-store.tspersistAttachmentUrlIfInlineapi/media-store.tsdeleteMediaFilecatch → falsesitesLeftproviders/page-scoped-context.tsfetchLocalJsoncatch {}providers/page-scoped-context.tsrenderBrowserLiveStatecatch → nullruntime.reportError(J4 degrade, now agent-visible)providers/page-scoped-context.tsrenderAutomationsLiveStatecatch → nullruntime.reportError(J4 degrade, now agent-visible)providers/page-scoped-context.tsprovidergetreturn EMPTY_RESULTlogger.error→runtime.reportError(J1 boundary)Per-category tally
reportErrorupgrades.sitesLeft): the rest of the batch's ~444 suspect + 760?? <lit>sites, incl.deleteMediaFileand the entireruntime/eliza.tsboot path (high-risk — deferred, not touched).Exemplar before → after (
readStoredMediaBytes)Its test (
media-store.test.ts, real fs — no mocks): a directory placed where the bytes should be makesreadFileSyncthrowEISDIR; the test asserts anElizaErrorwith codeMEDIA_STORE_READ_FAILEDand a preservedcause, while absence still returnsnull. The write path is proven with a real read-only store dir (chmod 0o555, skipped as root) assertingMEDIA_STORE_WRITE_FAILED. The provider test drivespageScopedContextProvider.getwith a throwinggetTasks/getRoomand assertsruntime.reportErrorfires with the right scope while the provider still degrades (brief-only / empty context).Verification
bun run --cwd packages/agent test src/api/media-store.test.ts src/providers/page-scoped-context.test.ts src/services/agent-export.media.test.ts src/services/agent-export.roundtrip.test.ts→ 70 passed (63 pre-existing green + 7 new error-path).bun run audit:error-policy-ratchet→ passes:page-scoped-context.tsemptyCatch 1→0,media-store.ts5→5 (all annotated J6), zero server-console added.bun run --cwd packages/agent typecheck→ my four files clean. Two pre-existing, unrelated failures remain in untouched packages (plugins/plugin-discordmissing@elizaos/plugin-meetings;plugins/plugin-local-inferencelogger typing) — not introduced here.loggerimport dropped from page-scoped-context (top-level catch now usesruntime.reportError).Evidence
RECENT_ERRORSprovider (foundation Fallback slop foundation (#12182): AGENTS.md error policy, ElizaError, runtime.reportError + ERROR_REPORTED event, recent-errors provider, escalation wiring, lint guards #12263), which is unit-tested in core.Refs #12265
🤖 Generated with Claude Code