Skip to content

feat(D147): push-delivery seams — announce new work, replaceable conversion, no local state, per-bucket keys, pool options - #536

Merged
fazpu merged 3 commits into
mainfrom
feat/runtime-seams
Nov 6, 2026
Merged

fazpu merged 3 commits into
mainfrom
feat/runtime-seams

Conversation

@fazpu

@fazpu fazpu commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #531 (library seams, now D147). These are the generic seams the merged UMC relaunch designs need: UMC design/designs/task-dispatch-and-portability.md §5 and §7, and the shared-runtime design. They were requested by the orchestrator and by the UMC runtime agent. Nothing multi-tenant is added: no resolver, no Cloud Tasks adapter, no cache.

Public API added

# 1. Announce new work through the context's TaskQueuePort
SelfHostProfile(..., task_queue=queue)          # or from_settings(..., task_queue=queue)
run_task(context, pid)   # after the task: queue.announce(...) for every row the task created
ApiDeployment(..., task_queue=queue)            # profile.api_deployment() fills it from the profile
#   -> after a route returns, every row the request created (an upload's convert row) is announced
from rememberstack.spine.new_work import collect_new_work, announce_new_work, NewWork  # building blocks

# 2. Replaceable conversion
SelfHostProfile(..., conversion_routes={"application/pdf": my_converter, ...})
SelfHostProfile.from_settings(settings, conversion_routes=...)
#   used by the convert stage AND by upload admission (routable MIME types)

# 3. Forget manifests off local disk
SelfHostSettings(forget_manifest_bucket_name="fs-forget")   # REMEMBERSTACK_SELFHOST_FORGET_MANIFEST_BUCKET_NAME
#   -> ObjectStoreForgetManifestStore (adapters.selfhost), same contract as LocalFSForgetManifestStore
SelfHostProfile(..., forget_manifests=<any ForgetManifestPort>)

# 4. Per-bucket credentials
EngineSettings(..., object_store_by_bucket={"fs-raw": MinIOSettings(...), ...})  # falls back to object_store
EngineSettings.object_store_for(bucket=...) -> MinIOObjectStore

# 5. Pools
SelfHostProfile.from_settings(settings, engine_options={"poolclass": NullPool})  # main engine only
profile.close()   # disposes every engine

How it works and what to rely on:

  • Collection point. Every processing_state insert in the engine goes through spine.work_ledger.enqueue_on. That function now calls record_new_work(...) for an inserted row and for a backfill row promoted to steady, but only while a collector (a ContextVar) is active.
  • Self-host is unchanged. It sets no collector, so the insert trigger's pg_notify stays the only wake. With the default queue, run_task adds one harmless extra pg_notify per successor.
  • Best effort; the janitor is the backstop.
    • A row created on a thread that does not inherit context is missed. A rolled-back row may be announced, which the receiver ignores after re-reading the ledger.
    • An announce that raises is logged, not raised, because the work is already committed.
  • Convert: a host's converter receives the raw bytes, which the trusted worker reads, and the MIME type, through the existing Converter protocol. The claim, lease, artifacts and completion stay in the engine's convert stage.
  • Docs: the upgrades page now says the engine does not depend on pg_partman's background worker; CALL run_maintenance_proc(); per database works too.

Tests

  • test_two_deployment_contexts_pg.py (two DBs, one process), extended:
    • each upload's convert row is announced through its own deployment's queue;
    • each task's structure successor is announced after run_task;
    • B's replaced Markdown route is used and A's in-process route is not affected.
  • test_engine_settings.py: the per-bucket credential choice, NullPool via engine_options, and the bucket-backed forget store chosen by settings.
  • test_new_work.py: collector scope, de-duplication, and a failed announce being logged.
  • test_selfhost_forget.py: the bucket-backed manifest store contract (idempotent append, conflict, deployment filter, tampered key).

Checks

  • ruff, format, pyright (0), import-linter (5 kept), unit lane (3088 passed after the classification fix), the two-DB test on PG 19 Beta 3, docs checks

  • CI (green; one test fix: Alembic logging config disabled the logger under test in the full lane)

  • Codex review: round 1 APPROVE (two doc minors fixed)

  • I have read and agree to the RememberStack Contributor License Agreement v1.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm

fazpu and others added 2 commits November 6, 2026 18:30
…rsion, no local state

Follow-up seams the UMC relaunch designs need, all generic:
- New work is announced through the context's TaskQueuePort: enqueue_on
  records created rows while a collector is active (spine/new_work.py);
  run_task announces its successors after the task, and an ApiDeployment
  with a task_queue announces the rows a request created. Best effort; a
  host's janitor stays the backstop.
- Replaceable conversion: conversion_routes (MIME -> Converter) on the
  profile and from_settings, used by the convert stage and upload admission.
- Hard-forget manifests can live in a dedicated bucket
  (forget_manifest_bucket_name, ObjectStoreForgetManifestStore) instead of
  a local directory.
- EngineSettings.object_store_by_bucket: a credential per bucket.
- from_settings(engine_options=...) for the main engine's pool.
- Docs: partition maintenance can run per database without pg_partman's
  background worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm
…rd compatible

Codex round 1 minors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9cMsQBqiW2qU2ow4zeNCm
@fazpu

fazpu commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Codex review round 1 (gpt-6.1-sol, max effort)

VERDICT: APPROVE

No blocker or major findings. Two minor documentation inconsistencies:

  • Minor — requirements/page.mdx:103 still requires all listed preload settings, including pg_partman_bgw, contradicting the new upgrades guidance. Simplest fix: explicitly permit scheduled per-database maintenance instead of the background worker.
  • Minor — decisions.md:7385 says build_api’s keyword signature is unchanged, but http_api.py:604 adds task_queue. Simplest fix: say the signature remains backward compatible.

Every work-row insert goes through enqueue_on. Context isolation and post-commit announcements passed checks for run_task, threadpool routes, and 20 overlapping API requests. The manifest adapter preserves the local store’s D74 contract; credential selection, main-engine pool options, and default self-host behavior look correct.

Focused tests passed, including ledger and version-reuse tests, with the existing expected failure. PostgreSQL tests used a dedicated PG 19 Beta 3 container without pg_partman_bgw; it was removed afterward. No files changed.

Disposition (Claude)

Both minors are fixed in 70a150e. The requirements page now allows scheduled run_maintenance_proc() instead of the background worker. D147 now says build_api stays backward compatible and gains an optional task_queue.

@fazpu
fazpu marked this pull request as ready for review November 6, 2026 18:13
@fazpu
fazpu merged commit fd6049c into main Nov 6, 2026
22 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