Skip to content

design: D165 transient object-store failures answer a retryable 503 - #693

Merged
fazpu merged 3 commits into
mainfrom
design/object-store-unavailable
Nov 29, 2026
Merged

fazpu merged 3 commits into
mainfrom
design/object-store-unavailable

Conversation

@fazpu

@fazpu fazpu commented Nov 29, 2026

Copy link
Copy Markdown
Member

Why

On 2026-11-28 08:30:30 UTC (release v0.22.6), one ingest of an unchanged document during a repository sync answered
HTTP 500 on remember.dev:

  • PostHog recorded api_unhandled_exception, type botocore ClientError, from E0 ingest_observed → selfhost
    MinIOObjectStore.write_bytes.
  • Re-running the identical ingest later succeeded as a no-op. The conditional create's 409/412 maps to
    ObjectAlreadyExistsError, so the failure was a different, transient provider error.
  • The S3 client deliberately makes one attempt per request (retries={"total_max_attempts": 1}, a8e0417), so that a
    write is never re-issued after losing the P3 lock. As a result, one throttle, 5xx or timeout becomes an unhandled 500
    that clients cannot tell from a bug.
  • The Python and TypeScript SDKs only read retryable from /query/* and /readiness errors.

What D165 decides (design only)

  1. A classification of object-store failures, covering every S3 call the adapter makes:
    • transient: HTTP 5xx, throttling, RequestTimeout, connect/read timeouts, closed connections and stream errors;
    • permanent: auth, missing bucket, bad requests;
    • unchanged handling: existing-key and NotImplemented.
  2. A port-level ObjectStoreUnavailableError that keeps the provider cause chained and never echoes provider text
    (D158 Rule 4).
  3. HTTP answers 503 {"detail": {"code": "object_store_unavailable", "message", "retryable": true}}, logged once per
    D158. Both SDKs decode it on every route, and MCP maps it to a retryable tool error. SDKs still never auto-replay writes.
  4. Workers treat it as a dependency outage, using the existing staggered dependency backoff instead of burning attempts.
  5. Automatic boto retries stay off, for reads too: one client, no new knobs.
  6. Retrying an ingest is safe and documented: an identical keyless ingest is a no-op under D55, and the raw original is
    created conditionally.

The client side, a bounded brain-sync retry, is writeitai/ultimate-memory-cloud#1238.

Process

  • Drafted by Antigravity (Gemini 4 Neon High).
  • Reviewed by an independent Claude reviewer, because GPT-6.2 sol is unavailable until 2026-12-02; a GPT re-review is planned
    then.
  • Implementation follows in a separate PR after approval.

Contributor agreement

Signing on behalf of a legal entity (leave blank if accepting individually):

🤖 Generated with Claude Code

https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq

…ilableError (D165)

Define the D165 binding design for transient object-store failures without
re-enabling automatic boto retries:

- Specify transient vs. permanent S3/botocore failure taxonomy across all
  14 network S3 calls and StreamingBody.read() in MinIOObjectStore,
  preserving existing 409/412, 404/absence, 501/NotImplemented, and
  permanent failure paths (including SSLError and before_write guards).
- Introduce port-level ObjectStoreUnavailableError with chained __cause__
  and Rule-4-safe closed-allowlist metadata (operation, cause_type,
  provider_code, status_code).
- Keep retries={total_max_attempts: 1} uniformly for writes and reads
  with zero new config knobs.
- Map ObjectStoreUnavailableError to HTTP 503 with a retryable structured
  error envelope logged once per D158 Rules 1 and 4, decode it in both
  Python and TypeScript SDKs without auto-retrying writes, and mirror it
  in in-process MCP.
- Add ObjectStoreUnavailableError to workers/base.py:_dependency_unavailable
  for staggered dependency-outage backoff, document ingest retry safety,
  and list same-PR D66 public doc updates and acceptance tests.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
@fazpu

fazpu commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Design review, round 1 (independent Claude reviewer; GPT-6.2 sol unavailable until 2026-12-02)

VERDICT: CHANGES_REQUESTED

What holds: the taxonomy per call (409/412, absence and NotImplemented untouched; the botocore class lists match 1.43.53);
no write after P3 lock loss; existing callers; the envelope shape and both SDKs, with no write replay; the worker
_dependency_unavailable change and backoff numbers; the app-wide handler covering the remember.dev runtime path.

Blocking

  1. The ingest retry-safety argument is false for ingest_stored (§6.3, :137). _release_unretained runs purge_objects
    after record_upload commits (e0.py:646-665; minio.py:539-590 is head, delete, versioning, list versions, list uploads).
    A transient error after the delete answers 503 for a completed registration, and the retry's iter_bytes raises
    FileNotFoundError.
    The same post-commit 503 can happen in ingest and ingest_observed (e0.py:339-343,611-615). Retrying still converges
    there, but answers created=False.
    Fix: state in §6, D165 (decisions.md:8888) and the §7 website text that a 503 can arrive after commit and a retry
    may answer created=False. Qualify or drop §6.3 (ingest_stored is not served over HTTP).
  2. Pin the base class: a direct subclass of Exception, like ObjectAlreadyExistsError, never
    OSError/ConnectionError/TimeoutError/ValueError/RuntimeError. The wrong base changes MCP mapping, existing
    except OSError handlers, _STORED_REFUSALS and test_error_contract.FAILURE_CLASSES.

Non-blocking
3. Rename the error's status_code to provider_status_code, in the attribute, the log extra and the error-reporting table.
Otherwise it reads as the response status and collides with map_error's duck typing.
4. SDK precedence: the /query/* and readiness branches run first (client.py:1746-1752, http.ts:214-224). Say
"non-query, non-readiness routes" or decode first. Accept the code only at 503, and take retryable from the wire value.
5. Drop the lease-expiry rationale in §3 (:70); leases renew on a background thread (workers/base.py:287-301).
6. Export from rememberstack.model only, not from ports (:46, decisions.md:8861).
7. Note that forget's public last_error (forget.py:338-345) will read ObjectStoreUnavailableError, and that forget
sweeps retry on their own.
8. Tests: a transient failure on put_object, upload_part and complete_multipart_upload results in exactly one client
call, and replace_stream still aborts. Add storage_class_of and remove_empty_folder_markers to the §8.1 matrix.
9. Nit: the stale http_api.py:1289 reference in the error-reporting table is now :1324.

fazpu and others added 2 commits November 29, 2026 04:25
Revise the D165 design, decision log, error-reporting table, and
TypeScript client contract to resolve all round-1 review findings:

- Document post-commit 503 convergence (created=False on retry) for
  POST /ingest and qualify in-process ingest_stored post-commit
  _release_unretained behavior.
- Pin ObjectStoreUnavailableError as a direct Exception subclass and
  export it from rememberstack.model only (not ports).
- Rename status_code to provider_status_code across attributes, log
  extra, and the D158 boundary table.
- Decode object_store_unavailable before /query/* and /readiness in both
  SDKs, gated on HTTP 503 with wire retryable.
- Drop the invalid worker lease-expiry rationale in §3, document
  forget.py last_error and self-retrying sweeps in §5, expand §8.1
  adapter tests (single-call writes, replace_stream abort,
  storage_class_of, remove_empty_folder_markers), and fix the stale
  http_api.py:1289 line reference to :1324.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
@fazpu

fazpu commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Design review, round 2 (independent Claude reviewer): APPROVE

All 9 round-1 findings are resolved:

  • Retry safety: the post-commit 503 caveat (retry answers created=False) is stated, and ingest_stored is qualified as
    a library API not served over HTTP.
  • Base class: pinned to Exception, with a test.
  • Naming: the attribute is provider_status_code.
  • SDKs: decode the code first, only at 503, taking retryable from the wire.
  • Smaller points: lease rationale removed; model-only export; forget's last_error noted; tests for exactly one call
    and multipart abort; matrix additions; line reference fixed.

The non-blocking nit (ForgetSweepHandler → ForgetHandler) is fixed in 8b14731. The implementation PR follows.

@fazpu
fazpu merged commit f46111e into main Nov 29, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant