Delivery Contract: PauseMesh

July 19, 2026 ยท View on GitHub

Date: 2026-07-15 Last updated: 2026-07-19 Mode: new-project Status: delivered through 0.3.0-alpha.1

Objective

Provide a protocol-neutral primitive that lets an agent workflow pause, survive process failure, hand control to another protocol surface, and resume exactly once without repeating a side effect.

Scope

Must:

  • Persist a versioned continuation envelope and append-only lifecycle events.
  • Enforce pending -> resumed | cancelled | expired with compare-and-swap fencing.
  • Issue opaque, one-shot resume tokens while persisting only their SHA-256 hashes.
  • Make retries idempotent and reject stale, wrong, expired, cancelled, or reused tokens.
  • Supply replaceable in-memory and SQLite/WAL event-store adapters.
  • Supply an optional PostgreSQL adapter with explicit migrations and multi-replica CAS semantics.
  • Map a minimal continuation contract across MCP, A2A, and AG-UI adapters.
  • Expose a small HTTP/CLI demo and machine-readable errors.
  • Keep liveness independent from a fail-closed, host-owned dependency readiness probe.

Should:

  • Reconstruct state by replay after reopening SQLite.
  • Emit structured, redacted operational logs.
  • Keep protocol mappings versioned and report semantic loss explicitly.

Could:

  • Publish the package to npm after the repository MVP proves stable.
  • Add OpenTelemetry instrumentation without coupling the core to a vendor.

Out of scope:

  • Agent orchestration, model routing, tool execution, memory, planning, workflow DAGs, or approval UI.
  • A production identity provider, multi-tenancy, hosted control plane, or generic protocol gateway.
  • Lossless translation of every MCP, A2A, or AG-UI field.

Assumptions

  • Node.js 24+ is available.
  • SQLite is a reference store; consumers may implement the event-store port elsewhere.
  • PostgreSQL consumers own their pool, credentials, TLS, timeouts, runtime role, and shutdown.
  • The MVP HTTP server is for local evaluation and must not be internet-exposed without authentication.
  • Protocol drafts can change, so adapter contracts are versioned independently from the core envelope.

Requirements

IDRequirementPriorityAcceptance criteriaVerification
R1Durable lifecycleMustA pending continuation replays after closing and reopening the SQLite storeRestart integration test
R2Exactly-once resumeMustOne valid token wins; subsequent or concurrent attempts cannot transition againUnit and concurrency tests
R3Retry idempotencyMustRepeating the same idempotency key returns the first result without another eventUnit test
R4Expiry/cancelMustExpired and cancelled continuations cannot resumeFake-clock tests
R5Protocol projectionMustCanonical requests project to MCP, A2A, and AG-UI with correlation preservedAdapter contract tests
R6ConfigurationMustInvalid limits, ports, or paths fail at startupConfig tests
R7Safe diagnosticsMustTokens and response payloads never appear in structured logsLog assertion test
R8Public deliveryMustCI, documentation, license, commit, and GitHub push succeedRepository evidence
R9MCP conformanceMustCapabilities, flat schemas, trusted URL policy, related-task metadata, and the exact issuance receipt fail closedExact adapter fixtures
R10A2A ownershipMustOnly an explicit server task/context binding is projected; credentials remain out-of-bandExact adapter fixtures
R11AG-UI resume contractMustA whole resume batch is bound to an immutable issued receipt/current cohort and invalid input becomes RUN_ERROROfficial schema, receipt, and replay fixtures
R12Adapter migrationMustHTTP/demo/docs use the explicit 0.2 bindings with no legacy ID fallbackBuild, demo, and HTTP tests
R13Consumable packageMustA clean source copy builds a tarball that installs in a real pnpm consumer with working ESM exports, declarations, docs, config, and CLIPackage smoke test
R14PostgreSQL multi-replica CASMustTwo independent pools share a stream, one conflicting append wins, the loser receives a typed version conflict, and exact service retry reconcilesReal PostgreSQL integration test
R15Explicit PostgreSQL migrationMustVersion/checksum mismatch, future schema, incomplete objects, or missing runtime access fail closed; constructors perform no DDLFake-pool and real PostgreSQL tests
R16Liveness/readiness splitMust/healthz is unchanged and independent; /readyz reports configured dependency readiness without leaking underlying errorsHTTP and storage tests
R17Optional package boundaryMustpausemesh/postgres works from the packed consumer while PostgreSQL symbols do not leak through the root exportClean package smoke test

Acceptance Threshold

Accepted only when all Must criteria pass, pnpm check is green, no known P0/P1 defect remains, the local API demo completes, and security/operational limitations are explicit.

Architecture Approach

A modular TypeScript library: pure domain state machine, application service, storage/clock/token ports, protocol adapters at the edge, SQLite/WAL reference adapter, optional PostgreSQL adapter, and a thin Hono HTTP adapter. Dependencies point inward; protocol and storage packages never leak into the domain. The PostgreSQL client is injected structurally and owned by the host.

Test Plan

Critical:

  • State transition, stale version, token mismatch/reuse, idempotency, cancel, and expiry tests.
  • SQLite close/reopen replay and concurrent-resume tests.
  • Scripted PostgreSQL migration, transaction, rollback, corruption, limit, and readiness tests.
  • Real PostgreSQL two-pool CAS, idempotency, append-only, and restart replay test.
  • MCP/A2A/AG-UI projection contract tests.
  • Strict MCP primitive/enum schemas, original-request receipt binding, trusted URL policy, URL consent vs completion, and invalid result fixtures.
  • A2A server-binding, JSON value, authorization boundary, and terminal-state fixtures.
  • AG-UI receipt/current-cohort equality, multi-interrupt coverage, replay, CAS cancellation, expiry, mandatory schema-policy, authorization isolation, and official wire-schema tests.

Recommended:

  • HTTP error-shape and payload-limit integration tests.
  • Log redaction and configuration validation tests.

Not covered by this library release:

  • PostgreSQL regional failover/HA, backup restore, tenant isolation, hostile internet traffic, or full upstream conformance suites. The bare CLI server remains non-production until a host adds identity, authorization, TLS, rate limits, and deployment controls.

Delivery Policy

Selected mode: create public GitHub repository and push main, as explicitly requested by Antonio.

  • Commit convention: Conventional Commits.
  • CI: lint, typecheck, unit/integration tests, and build on Node 24.
  • Rollback: revert the initial commit or archive the new repository; no external runtime is deployed.

Change Log

TimeChange requestImpactDecision
2026-07-15Exclude profile README, pins, descriptions, and topicsAvoid collision with another taskKept out of scope
2026-07-15Include LinkedIn context, GitHub follows, and starsParallel discovery/network workNon-blocking; LinkedIn awaits login
2026-07-15Avoid overlap with existing portfolio control planesNarrowed product boundaryProtocol primitive only
2026-07-17Correct upstream protocol drift before a first package releaseBreaking prerelease adapter surfaceExplicit host bindings and fail-closed conformance in 0.2 alpha
2026-07-17Make AG-UI cohort reconstruction independently verifiableAdded host-side issuance stateContent-addressed immutable receipt plus exact current-cohort validation
2026-07-17Prove the npm artifact from clean sourceRelease gate expandedPrepack build and import/bin/content smoke included in pnpm check
2026-07-17Bind MCP results/completion to the exact emitted requestAdded host-side issuance stateRequest SHA-256 receipt is mandatory on inbound helpers
2026-07-17Remove consumer native-build approvalStorage implementation swapSqliteEventStore now uses built-in node:sqlite behind the unchanged port
2026-07-19Support callbacks reaching another replicaAdded optional PostgreSQL adapterStream-head CAS on one checked-out READ COMMITTED transaction
2026-07-19Keep deployment credentials and lifecycle out of the libraryPool remains externally ownedOptional subpath and structural pool contract; CLI remains SQLite-only
2026-07-19Separate process liveness from dependency readinessAdded ReadinessProbe and /readyzOmission/error fails closed without changing /healthz

Incident Register

IncidentSeverityStatusRegression prevention
Windows checkout converted LF to CRLF, causing Biome's formatter gate to failP2ResolvedRepository .gitattributes, explicit Biome lineEnding: lf, and Windows CI

Final Evidence

  • Repository: https://github.com/aantenore/pausemesh
  • Delivered rewritten-history commits: 82b8964 (MVP), a515227 (cross-platform hardening), 4cad014 (delivery evidence), f3efe51 (authenticated retry hardening), 6b16790 (history evidence), and 2583003 (final CI link).
  • Local quality gate: pnpm check passed; 6 test files and 35 tests passed, then TypeScript package build completed.
  • Runtime smoke: create returned 201, AG-UI projection returned RUN_FINISHED, resume reached version 2, and an exact idempotent retry returned 200.
  • Packaging: pnpm pack --dry-run included only the compiled package, README, license, and package manifest. Production dependency audit reported no known vulnerabilities.
  • Remote CI: run 29403027193 passed from a clean checkout on Ubuntu, macOS, and Windows with Node.js 24.
  • Repository security: Dependabot alerts and security updates, private vulnerability reporting, secret scanning, push protection, and CodeQL default setup are enabled.
  • Acceptance result: every Must requirement is implemented and verified; no known P0/P1 defect remains inside the documented MVP boundary.

Adapter conformance release evidence

  • Target release: https://github.com/aantenore/pausemesh/releases/tag/v0.2.0-alpha.1.
  • Architecture decision: ADR 0002.
  • Local quality gate: pnpm check passed with 10 test files and 164 tests, 84.24% statement and 80.80% branch coverage, followed by the TypeScript build and clean-source package smoke.
  • Upstream validation: AG-UI interrupt events are accepted by the exact-pinned official RunFinishedEventSchema; MCP and A2A fixtures follow their tagged/current normative schemas.
  • Runtime smoke: the cross-protocol demo generated explicit MCP/A2A bindings, issued an AG-UI event plus receipt, validated a complete inbound batch, and completed a one-shot resume.
  • Packaging: the clean-copy smoke built pausemesh-0.2.0-alpha.1.tgz, installed it into a separate pnpm consumer, and verified compiled exports, declarations, embedded JS sources, docs/config, ESM import, and the installed CLI. The production dependency audit reported no known vulnerabilities.
  • Boundary result: the continuation core and persisted envelope did not change. Protocol drift is isolated to adapters, and legacy task/run ID fallbacks are absent.

PostgreSQL multi-replica release-candidate evidence

  • Release: 0.3.0-alpha.1, consolidated on the protected default branch after required CI.
  • Architecture decision: ADR 0003; operations: PostgreSQL adapter runbook.
  • PostgreSQL unit coverage uses a scripted pool/client boundary to verify statement ordering, pre-validation, compare-and-swap conflicts, rollback/release behavior, migration checksums, schema completeness, bounded replay, and corruption classification.
  • The opt-in real PostgreSQL suite compiles against pg.Pool and is mandatory in its Linux CI job. It runs concurrent migrations and replicas, exact retry, append-only guards, and restart replay.
  • Package smoke installs the tarball into a clean consumer and verifies pausemesh/postgres without leaking PostgreSQL symbols into the root export.
  • Local PostgreSQL 17 integration: one real test passed against an ephemeral container and the container was removed after verification.
  • Local quality gate: pnpm check passed with 193 tests passed and one opt-in PostgreSQL test skipped in the ordinary coverage run; statements 86.38%, branches 82.35%, functions 92.51%, and lines 87.20%. Build and clean-consumer package smoke produced and verified pausemesh-0.3.0-alpha.1.tgz.