Skip to content

test(backends): P1 reusable backend contract for TTL, clear, lifecycle and failures #111

Open

Description

@agustin18

Priority: P1 — contract before backend feature work

Define an installed-distribution conformance suite for InMemory, standalone Redis and experimental Memcached/DynamoDB. Do not claim backend parity based only on protocol types.

Contract matrix

  • get/get_with_ttl: missing, fresh, expiration, infinite TTL, clock skew, negative/zero TTL; no stale expired value returned when backend TTL cleanup is eventually consistent.
  • set: overwrite, bytes, empty payload, expiry rounding/units, cancellation and error semantics.
  • clear: exact key, namespace boundaries/glob escaping, count semantics, no unrelated deletion, unsupported operation must fail explicitly; Redis Cluster namespace clear remains unsupported.
  • close/ownership: idempotency, lifecycle, repeated app start/stop, borrower-owned clients not closed by the cache decorator.
  • corrupt bytes, timeout, disconnection, cancel and retry behavior; no raw keys, credentials, auth headers or payloads in errors/logs.
  • Per-backend capability matrix in docs; every supported operation must have installed wheel/sdist tests and where appropriate a real service or qualified emulator.
  • Reproduce DynamoDB expired get() vs get_with_ttl() and close() anomalies (fix(backends): test and correct experimental DynamoDB TTL/close semantics #45). Reproduce Memcached fixed 3600s TTL and unsupported clear(); fix only when clear semantics and tests are defensible.

Deliverables

One reusable contract harness + backend capability table, scoped regression issues/fixes and explicit status (supported/experimental/unsupported). Avoid blanket Memcached/DynamoDB graduation without real-world E2E evidence.

Related: #45, #102, #95, and separate corrupt-serialization policy issue. No change to 0.6.0 artifacts.

Activity

  1. agustin18 commented on Nov 22, 2026

    @agustin18
    OwnerAuthor

    Draft #114 adds a test-only shared InMemory/loopback Redis contract for get/set/TTL/scoped clear plus an explicit capability RFC. It does not change production backends or claim parity for experimental providers. CI uses Redis 7.x; Redis 7.4 and service-specific semantics remain separate evidence. A1/A2 app privacy and #112 failure policy must remain bounded. Keep this issue open for further TTL zero/negative, expiry, lifecycle, cancellation and Memcached/DynamoDB regressions.

  2. agustin18 commented on Nov 22, 2026

    @agustin18
    OwnerAuthor

    Reproducible 0.6.0 TTL boundary found while bringing up #100 / draft #120 (2026-11-22): A published-wheel-only InMemory smoke benchmark set an entry with expire=1, waited ~1.1 real seconds, and get() still returned the payload (RuntimeError: Expired item was returned; workflow run 45079688560). The tagged v0.6.0 implementation uses _now = int(time.time()), stores ttl_ts = _now + expire, and expires only when ttl_ts < _now rather than <=. At an integer clock boundary, get_with_ttl() can therefore return (0, value) and get() can return the same value until the next integer tick. Classification: observable TTL rounding/edge contract requiring focused tests and decision under #111/#112; not a demonstrated security disclosure. The benchmark harness is being adjusted to wait >2s for deterministic already-expired checks; that does not resolve the backend behavior. Recommend exact-boundary fake-clock tests for bounded and unbounded InMemory and explicit decision whether <= is the correct contract, preserving legacy behavior analysis.

  3. agustin18 commented on Nov 23, 2026

    @agustin18
    OwnerAuthor

    2026-11-23 scoped proposal: Open draft PR #123 for a deliberately small InMemory TTL boundary decision. Published 0.6.0's integer clock and strict ttl_ts < _now expose data at the exact expiry second with get_with_ttl() == (0, bytes). Proposed 0.7 behavior: expire at ttl_ts <= _now, for unbounded reads, bounded heap reclamation and LRU; use deterministic injected-clock tests for exact equality, TTL=0/negative, no resurrection after backward clock jump, and no eviction of a live LRU at a reclaimable expiry boundary. Seeded state-machine oracle and heap adversarial oracle updated in tandem. This is not yet an accepted general backend contract: Redis SET ex=0 rejects while InMemory immediate misses; separate backend sentinel and error semantics remain. Keep #111 OPEN for full installed-wheel backend matrix and #112 policy; no 0.6.0 changes or release.

  4. agustin18 commented on Nov 23, 2026

    @agustin18
    OwnerAuthor

    2026-11-23 #123 independent-review follow-up: Latest Draft PR #123 is rebased via a merge of post-#122 stable (cdc27e9), exact head a48da525, 77/77 CI checks green. The earlier review gap is addressed: test_backward_wall_clock_shift_on_still_live_entry now proves that a not-yet-expired InMemory value remains readable and can acquire a larger remaining TTL after a backward wall-clock jump, in both bounded and unbounded modes. A distinct assertion proves an already-removed value cannot revive. This characterizes—not resolves—clock-skew semantics. The PR restores historical changelog.d/111.misc.md and creates a separate 123.misc.md. Decision pending: approve inclusive ttl_ts <= now for future 0.7 and document Redis EX<=0 differences; do not close full #111 on this narrow slice.

  5. agustin18 commented on Nov 23, 2026

    @agustin18
    OwnerAuthor

    Proposed narrow acceptance decision for #123 — maintainer/security review required

    Recommended 0.7.x scoped contract, NOT yet approved: InMemory uses integer wall-clock int(time.time()); expiration occurs at the computed integer deadline (ttl_ts <= now). Reads, get_with_ttl and bounded-heap reclamation apply the identical rule. expire=0 and negative InMemory TTL become immediate misses. Existing Redis semantics stay separate: nonpositive EX raises; don't silently normalize across backends. A backward wall-clock jump on a still-live entry can increase remaining TTL; monotonic elapsed-time/clock-skew guarantees are explicitly out of scope. Once a value is discarded it cannot revive.

    Evidence: PR #123 exact post-#122 head a48da525, 77/77 checks, deterministic bounded/unbounded and still-live-clock tests, heap/LRU/fuzz oracle alignment, historical changelog fragment preserved.

    Decision needed: maintainer explicitly ACCEPT or REJECT this narrow future-release contract, and independently approve the observable boundary change. Only then mark #123 ready/merge. Even if accepted and merged, keep #111 OPEN for backend clear/close/ownership, Redis errors, clock-skew alternatives, Memcached/DynamoDB conformance and broader installed-artifact evidence.

  6. agustin18 commented on Nov 23, 2026

    @agustin18
    OwnerAuthor

    Decisión técnica acotada para el candidato 0.7.0 — ACCEPT (2026-11-23)

    Tras revisión de las diferencias y pruebas de #123, se acepta para la rama de desarrollo la semántica de vencimiento InMemory inclusivo (ttl_ts <= int(time.time())) aplicada tanto al modo ilimitado como a la lectura y recuperación del heap LRU acotado. Implicaciones aceptadas:

    • El instante exacto de vencimiento y expire=0 se consideran MISS; get_with_ttl() == (0, None). TTL negativos igualmente MISS.
    • Se preserva el reloj entero wall-clock existente: una entrada todavía viva puede recuperar TTL aparente cuando el reloj retrocede, y una ya eliminada no revive. No se promete expiración monotónica.
    • Redis mantiene su contrato independiente: EX 0 o negativo da error; no hay normalización silenciosa ni paridad Memcached/DynamoDB.
    • Es una modificación futura respecto del wheel inmutable 0.6.0, sin cambio de keys, clientes externos ni política de expiración de Redis.

    Límites de esta aceptación: solamente el diff y regresiones de #123; no equivale a aceptar todo #111 ni la versión 0.7.0. La compatibilidad final se verificará con CI sobre HEAD posterior a #127 y, después del merge, integración combinada con #124. El issue #111 sigue abierto para contratos completos de clear/close/cancellation/errores y proveedores experimentales. Esto documenta la decisión técnica de implementación bajo la solicitud de avanzar en el trabajo; no es una afirmación de firma personal del mantenedor sobre el release. No hay tag, TestPyPI ni PyPI autorizados.

  7. agustin18 commented on Nov 23, 2026

    @agustin18
    OwnerAuthor

    Post-merge checkpoint (2026-11-23): Narrow inclusive InMemory TTL change from #123 is MERGED into stable as 612e9d6, after 77/77 exact-head checks against then-current stable; deterministic bounded/unbounded, live clock rollback and heap/LRU regression tests included. #124 also subsequently merged (4dc66ad); joint stable CI is being verified. This does not close #111: backend clear/close/ownership, Redis errors, clock-skew alternatives, Memcached/DynamoDB experimental contracts and installed-artifact conformance remain. No 0.7.0 artifact or release authorization.

  8. agustin18 commented on Nov 23, 2026

    @agustin18
    OwnerAuthor

    Reabierto durante la preparación de la contraauditoría 0.7.0. El cierre previo como “completed” era inconsistente con la descripción y los comentarios post-merge: #123 cubre únicamente el TTL inclusivo InMemory y #114 el tuple Redis; no hay evidencia de cierre completo para clear/close/ownership, fallos de Redis, clock-skew comparado, ni matriz instalada Memcached/DynamoDB.

    Próximo criterio: pruebas instaladas independientes por backend, matriz explícita PASS/FAIL/NOT RUN y límites de soporte documentados. No equiparar merge o CI verde con aceptación de todo #111. #130 es solo higiene de identidad del candidato, no satisface este gate.

  9. agustin18 commented on Nov 23, 2026

    @agustin18
    OwnerAuthor

    0.7 risk disposition proposed, not final conformance certification

    See PR #135 risk register and prepromotion audit assignment. Merged #114/#123/#131/#133 characterize Redis tuple and sentinel/EX=0 differences, InMemory inclusive TTL/clock rollback, empty bytes, client ownership and Docker real Redis stop/restart with retries explicitly disabled. These do not qualify experimental Memcached/DynamoDB parity, default redis-py retry latency, cluster namespace clear or all clear/close/cancel races.

    Review selected 0.7 supported contract cases PASS/FAIL/NOT RUN; P0/P1 reproduced blockers cannot be waved away. Keep #111 OPEN for the broad matrix beyond this limited release. No final acceptance is claimed.

  10. agustin18 commented on Nov 23, 2026

    @agustin18
    OwnerAuthor

    0.7.0 final-candidate backend risk disposition — NARROW SCOPE ACCEPTED

    Under the maintainer's explicit authorization, the following documented limitations are accepted only for source df884644f11eb0e36ae5d74721009fc8e4470c4b and the exact 0.7.0 artifacts, pending final independent artifact/security review. This is not universal certification under issue #111.

    • InMemory: integer-second wall-clock TTL, inclusive expiry (now >= deadline), not monotonic. Backward clock shifts can extend a value that has not yet expired.
    • Standalone Redis: get_with_ttl() returns a tuple. Redis reports missing TTL as -2 versus InMemory's 0; Redis EX <= 0 raises rather than silently normalizing. Preserve these differences.
    • Clear/lifecycle: scoped key/namespace clearing for qualified standalone Redis, Redis connection owned by its caller. Redis Cluster clear(namespace) is unsupported.
    • Outage evidence: merged test(redis): exercise real disposable Redis 7.4 process outage and recovery #133 stops/restarts a disposable Redis 7.4 daemon with test-only Retry(NoBackoff(), 0). It does not qualify default redis-py retry latency, Sentinel, TLS, Cluster, managed failover or HA.
    • Memcached/DynamoDB: experimental; no general backend parity or critical-deployment certification is asserted.

    The final Phase B run passed all 12 Redis 7.4 migration/rollback jobs for wheel/sdist on Python 3.8–3.13, within the full 20-job first-attempt run. A new reproducible package-owned P0/P1 issue still blocks release. Keep #111 OPEN for broader backend support and untested cases. NOT RUN is not PASS.

    This is not approval to tag or publish. Final evidence: #126.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions