The renderer adapter keeps one single-process pool per WORKER_CONCURRENCY
slot. A render that exceeds RENDER_TIMEOUT_SECONDS is killed and its slot
is respawned, the render process has RLIMIT_AS = RENDER_MEMORY_MB on
Linux, so both limits end in ImageTooDemanding, a permanent
processing_failed. A render process killed from outside is a transient
error. A cancelled render (lost lease, shutdown) kills its process too.
The worker container limit grows to 1g: two 448 MiB render processes
plus the worker itself.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The worker decodes the original once (JPEG draft down to the optimized
box, EXIF orientation applied in place, alpha composed on white) and
encodes three variants: the 256 px thumbnail, a centred 128x128 JPEG crop
that may upscale and a WebP fitted into 1280x1280 without upscaling,
quality 80, method 4. No EXIF, ICC or XMP is written. The byte limit is
checked before decoding. ready is set by the transaction that stores all
three rows, so a partial set is never published.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Level 4 of the lab 5 rubric: crop and optimized variants, byte, pixel,
time and memory limits of the worker, crash points for the failure
windows 2-5 with automatic recovery, backoff with jitter and error
classification, a failed registry with an explicit replay, lease renewal
and failed staging retention. New capabilities lab5-image-variants and
lab5-job-recovery, deltas to lab5-attachment-pipeline and lab4-attachments.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Grade 3 of lab 5 is closed. Upload answers 202 queued only after the
original is staged in the private bucket and the attachment, its job
and the outbox row are committed together; a separate relay publishes
the outbox to a durable quorum queue with publisher confirms and
returns expired leases; a separate FastStream worker claims a job
under a lease, publishes the original and the 256 px JPEG thumbnail,
commits fenced by the lease token and acks only after the commit.
Transient errors retry up to JOB_MAX_ATTEMPTS and end in
retry_exhausted, undecodable images fail at once with invalid_image,
and a redelivered job changes nothing. The defence demonstration
(worker down, upload, message, API, relay and broker restarts, worker
up, ready) and the lab 4 minimum pass on a stand raised from empty
volumes.
The lab5-attachment-pipeline and lab5-job-delivery capabilities join
the main specs, and the upload, content, message and restart
requirements of lab 1, lab 3 and lab 4 are updated in place.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Every grade 3 item of lab 5 is proven on a stand raised from empty
volumes at fe26938: the public smoke passes with 202 queued and a real
256x160 JPEG thumbnail; the suite runs its six grade 3 scenarios and
eight invariants green, including worker down with both API replicas,
the relay and the broker restarted while the job stays in the queue,
a redelivered finished job that changes nothing, an S3 outage that
recovers on attempt 2 and five transient failures that end in
retry_exhausted; the stand evidence shows the queued job with
delivery mode 2, the job id as message id and exactly the contract
fields, 409 before ready and a clean SIGTERM of the relay and the
worker; persistence restarts all eight services with their volumes,
failover keeps 134 writes without errors, and the lab 4 scenarios,
S3 checks, upload faults and container policy still pass.
The report describes the clean clone start, the processes and the
source of truth, what is stored at the moment of 202, the outbox and
relay, the claim, fencing and ack order of the worker, the retry
policy, the failure windows, the broker topology and permissions, the
roles table and the mapping of .env.example.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Bring the stdlib suite and image generator of the lab 5 preparation:
make suite-preflight checks services, readiness, schema columns, broker
topology and the faults override, and make level3 runs the grade 3
scenarios (smoke through the pipeline, worker down with API, relay and
broker restarts, duplicate delivery after ready, poison image, S3
outage with recovery, retries up to JOB_MAX_ATTEMPTS) and checks the
invariants into evidence/level3.json. make pipeline-evidence shows the
queued job on the broker while the worker is stopped, its properties
and contract payload, the 409 before ready and SIGTERM of the relay and
the worker; make topology dumps queues, consumers with prefetch,
permissions and users.
The lab 4 failover and S3 outage scenarios and the upload fault suite
now expect 202 and wait for ready, the stack evidence lists the broker
and its client packages, and the CI acceptance job runs the pipeline
scenarios and the SIGTERM check of the new processes.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Embed the checked lab 5 preparation: RabbitMQ 4.1.8 pinned by digest
with a fixed node hostname, a volume, a read-only root and 512 MiB,
whose topology (vhost messenger, exchange attachments, quorum queue
attachments.process with a dead letter exchange, delivery limit 10 and
reject-publish overflow) and users come from definitions imported on
every boot. The relay may only write to the exchange, the worker may
only read the queue, configure belongs to the operator, there is no
guest, and the management UI is published on 127.0.0.1 only. The relay
and the worker run from the application image with a heartbeat health
check, init, a read-only root and their own limits; the worker gets its
own S3 user that reads staging and writes originals and variants, and
s3-init creates it idempotently. The API has no broker credentials.
make secrets also creates the broker passwords, URLs, hashed users and
the worker S3 keys; the restart hook now stops the balancer, the API,
the relay and the worker and restarts PostgreSQL, Valkey, S3 and the
broker with their volumes; worker.sh and broker.sh stop, start and
inspect the processes for the failure demonstrations; the limits
policy covers the new services and the loopback UI port.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The messaging zone asks a new AttachmentStates port whether any listed
attachment of the chat has failed and answers 409 conflict before the
message is stored; queued and processing attachments can still be
sent right after the upload. The check runs only on the first execution
of a key, so a replay returns the original 201 even if the attachment
failed later. main.py wires the port to the attachments directory, so
neither zone reads the other's tables.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Upload now stages the checked original under staging/, and one
transaction moves the intent to queued, inserts the job (pipeline
version 1, attempt 1), its outbox row and an audit event; the 202 is
the in-memory snapshot, never a reread. Content answers 409 until the
attachment is ready, the thumbnail variant is served from the
published version and absent variants are 404.
The relay publishes outbox rows through FastStream with publisher
confirms, mandatory routing and persistent delivery, marks a row only
after the broker acked it, returns jobs whose lease expired and deletes
the staging object of ready attachments. The worker consumes the
quorum queue through a FastStream subscriber that declares nothing,
takes prefetch from WORKER_CONCURRENCY and acks manually after the
result commit, rejects messages off jobs.schema.json to the dead letter
exchange and requeues after an infrastructure error. A job is claimed
under a lease token; the original is copied to originals/ and a
256 px JPEG thumbnail is written under a content-addressed key; the
commit is fenced by the token, inserts variants with ON CONFLICT DO
NOTHING and publishes only a newer pipeline version. A transient error
reschedules the same job with an exponential delay and a new outbox
row, the last attempt fails with retry_exhausted, an undecodable image
fails at once with invalid_image, and a redelivered finished job is a
recorded no-op.
The worker and the relay are assembled in worker.py and relay.py with
the dishka FastStream integration and the platform providers of the
API; the shared core imports neither FastStream nor aio-pika. Tests
cover the thumbnail geometry and rendering, the job message against
the contract, the pipeline against PostgreSQL (duplicates, parallel
copies, retries, the attempt bound, leases and fencing) and the broker
adapters against a throwaway RabbitMQ with the stand's topology and
permissions.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Migration 0004 widens the attachment states to queued, processing and
failed, adds the staging and original keys, the published pipeline
version and the error code, and moves the lab 4 object key into them
while leaving the old column nullable until a contract step. New tables
hold the variants under the effect key (attachment, pipeline version,
name), the jobs with attempt, claims and lease, the outbox rows the
relay publishes and the audit of job transitions. Partial indexes serve
the relay scan of unpublished rows, the search for expired leases and
the staging cleanup.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Plan grade 3 of lab 5: upload answers 202 queued after the original is
in a private staging prefix and the attachment, its job and an outbox
row are committed in one transaction; a separate relay publishes the
outbox to a RabbitMQ quorum queue with publisher confirms and returns
jobs with an expired lease; a separate worker on FastStream claims a
job under a lease, publishes the original and a 256 px JPEG thumbnail,
commits the result fenced by the lease token and acks only after the
commit, retries transient errors up to JOB_MAX_ATTEMPTS and fails
undecodable images at once. Content answers 409 until ready and a
failed attachment cannot be sent.
The change adds the lab5-attachment-pipeline and lab5-job-delivery
capabilities and deltas to lab4-attachments, lab4-upload-resilience,
lab1-messenger-history and lab3-load-balancing.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Bring the Claude Code settings, the lint hook, the opsx commands and
skills, the architecture notes, the lab 1 to lab 4 specs and the
archived lab 1 to lab 4 changes into the lab 5 skeleton, so lab 5
continues the same spec history instead of starting from scratch. The
files come from the lab 4 solution commit d2744bc.
Rewrite AGENTS.md and the openspec context and rules for lab 5: upload
answers 202 queued after the original is in a private staging prefix
and the attachment, the job and the outbox row are committed in one
transaction, a separate relay publishes the outbox to RabbitMQ with
publisher confirms, a separate worker built from the same image
consumes the queue through FastStream with a manual ack after the
result commit, PostgreSQL stays the source of truth for job states,
Out of scope moves to labs 6-7, track 1 and broker HA, and the rules
add the failure windows between PostgreSQL and the broker, the effect
key and the lease to specs and designs.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>