53 Commits
Author SHA1 Message Date
Artyom c835302f70 Merge completed lab 5 for Gitea submission
Application / Линт, типы и собственные тесты (pull_request) Canceled after 0s
Application / Стенд Compose с RabbitMQ, relay и worker за HAProxy, smoke, pipeline, отказ реплики, рестарт и отказы зависимостей (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
Preserve the exact lab 5 tree and original history from c7b8feb805.
Connect it to the instructor master for a cross-fork pull request.
2026-11-08 00:57:05 +03:00
Artyom c7b8feb805 Validate bounded PNG rendering and finalize lab 5 evidence 2026-11-07 02:25:23 +03:00
Artyom 74c33160ac Update lab 5 report after PNG memory review 2026-11-07 01:53:09 +03:00
Artyom 6096aa7948 Archive the bounded PNG memory change 2026-11-07 00:48:46 +03:00
Artyom 1a80205249 Bound PNG transparency buffers within worker memory limits 2026-11-07 00:47:22 +03:00
Artyom 429f12d0bc Propose bounded PNG rendering memory as an OpenSpec change 2026-11-07 00:41:52 +03:00
Artyom fb682bc384 Include raw PostgreSQL outage log in validation evidence 2026-11-07 00:31:13 +03:00
Artyom 8b84ebf6d6 Record final validation and boundary PNG memory failure 2026-11-07 00:30:38 +03:00
Artyom b30e2f6a84 Finalize lab 5 report and evidence provenance after review 2026-11-07 00:13:31 +03:00
Artyom 42575281b3 fix: preserve PNG transparency at original sample depth 2026-11-06 23:51:58 +03:00
Artyom 6e97bdbe96 Archive the critical lab5 review fixes change 2026-11-06 23:34:44 +03:00
Artyom 3fad49d6b9 Preserve infrastructure redeliveries and flatten PNG transparency 2026-11-06 23:33:51 +03:00
Artyom ef55f9ac0a Propose critical lab5 review fixes as an openspec change 2026-11-06 23:29:25 +03:00
Artyom 544b9c78d3 Verify late forward fixes and archive lab 5 regression evidence 2026-11-06 23:16:36 +03:00
Artyom 0e92111661 Port final lab 4 validation and session revocation fixes 2026-11-06 22:33:31 +03:00
Artyom f88e9ba43c Document verified lab 5 grades and archive the versioned pipeline 2026-11-06 12:11:44 +03:00
Artyom 9ba3076fa8 Preserve active staging and read published originals on reprocessing 2026-11-06 10:59:33 +03:00
Artyom 2e428cf8e6 Fix cold worker claim result mapping with Core updates 2026-11-06 10:35:08 +03:00
Artyom 1212c562d2 Identify the underlying job parameter conversion failure 2026-11-06 10:18:04 +03:00
Artyom 5f6169c06c Expose safe database error codes for failed job claims 2026-11-06 10:10:38 +03:00
Artyom 886d4b8bc2 Await terminal state of reordered pipeline versions 2026-11-06 09:50:51 +03:00
Artyom 389c159681 Handle structured missing-object responses in pipeline inventory 2026-11-06 09:49:20 +03:00
Artyom ac6c55809f Complete versioned attachment processing and fault invariants 2026-11-06 09:46:43 +03:00
Artyom e9e1ce576c Propose completing the versioned attachment pipeline 2026-11-06 09:39:58 +03:00
Artyom 6656280b2c Verify lab 5 grade 4 recovery and worker limits 2026-11-06 09:37:20 +03:00
Artyom e9ce6d0afa Scope retention fault injection to the synthetic attachment 2026-11-06 09:31:58 +03:00
Artyom b159899d73 Prepare lab 5 grade 4 recovery verification 2026-11-06 09:28:01 +03:00
Artyom 47ffb2d10b Verify lab 5 grade 3 on the SQLAlchemy stack 2026-11-06 09:27:12 +03:00
Artyom 24a51744f5 Record source revisions and stopped containers in pipeline evidence 2026-11-06 09:16:57 +03:00
Artyom f1ecb74dc4 Propose verifying lab 5 grade 3 on SQLAlchemy 2026-11-06 09:16:40 +03:00
Artyom 02228a2847 Archive the lab 4 foundation forward change 2026-11-06 09:13:42 +03:00
Artyom 1217da5f5e Forward the lab 4 foundation and migrate the lab 5 pipeline to SQLAlchemy 2026-11-06 09:12:25 +03:00
Artyom ae9f60fe1f Propose forwarding the lab 4 foundation as an openspec change 2026-11-06 08:58:00 +03:00
ArtyomandClaude Opus 5.5 64d5c6746e Archive the crop, optimized, worker limits and job recovery change
The change add-lab5-variants-and-recovery is archived as
2026-10-29-add-lab5-variants-and-recovery with archived and lab: 5 in
.openspec.yaml. Specs are synced: lab5-image-variants and
lab5-job-recovery are created, lab5-attachment-pipeline (four
requirements) and lab4-attachments (metadata and download) are updated.
Level 4 is closed by make level4 (evidence/level4.json) and the rows
4.1-4.4 of REPORT.md.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-29 03:39:39 +03:00
ArtyomandClaude Opus 5.5 573220e12a Record level 4 evidence and fill in the report
evidence/level4.json: all 17 scenarios of levels 3 and 4 and the eight
invariants pass on 0b85edf; evidence/operator.txt shows the failed
registry, a replay to ready, a noop replay, an expired replay and the
DLQ. Smoke, topology, level3, persistence, failover, lab 4 scenarios,
limits, student tests and contract checks are refreshed on the same
commit. REPORT.md describes the variants, worker limits, jitter, lease
renewal, crash points, replay and retention, adds rows 4.1-4.4, the
level 4 failure experiments and the updated limitations.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-29 03:39:20 +03:00
ArtyomandClaude Opus 5.5 0b85edfdea Build the application image before compose plans the stand
up --build decided which containers to recreate before the build
finished, so relay and worker, which reuse the API image without a build
section of their own, kept running the previous image after a code
change. make up now builds first and then starts the stand, and every
service runs the same fresh image.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-29 03:21:08 +03:00
ArtyomandClaude Opus 5.5 b9d28d190e Run the level 4 scenarios with one command
make level4 runs the level 3 and level 4 scenarios of the pipeline suite
and the invariants into evidence/level4.json. New scenarios: worker_limits
(a 40 Mpx render under a 0.5 s timeout and a 200 MiB address space fails
with processing_failed while the worker keeps running, then succeeds with
the default limits under the container limit), retry_backoff_jitter
(delays from the job journal stay within [d/2, d] and differ) and
failed_retention (failed staging is kept, removed after the retention,
then replay answers expired). The stalled holder must be fenced and the
republished copy must be a no-op. The faults override passes the stall,
render limits and retention through; the admin CLI is python -m
messenger.admin. make failed, make replay ID=... and make dlq are the
operator entry points; the lab 4 target becomes lab4-level4. CI runs
level4 instead of level3. The registry prints ISO timestamps.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-29 03:19:28 +03:00
ArtyomandClaude Opus 5.5 b568fcf9c9 Add the failed registry, an explicit replay and failed staging retention
python -m messenger.admin is a new process assembly over the attachments
zone with only a database: "failed" lists failed jobs (served by the new
partial index jobs_failed_idx), "replay --attachment-id" moves a failed
attachment back to queued with the same job_id, attempt 1 and a fresh
outbox row, writing a replayed event with the operator. A ready, queued
or processing attachment is a noop (replay_noop event), a failed one
whose staging is already gone is expired. Every request is audited.

The relay now also removes the staging object of a failed attachment
once STAGING_RETENTION_SECONDS have passed since it failed; replay and
the cleanup take the same row lock.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-29 03:12:19 +03:00
ArtyomandClaude Opus 5.5 ecb4827e75 Renew job leases, spread retries with jitter and add crash points
Leases: the worker renews its lease before the first side effect and
every JOB_TIMEOUT_SECONDS/3 while the variants are produced; a renewal
that finds the lease taken cancels the work (and its render process)
and settles the job as fenced without writing anything.

Retries: the delay before attempt n+1 is drawn from [d/2, d] with
d = min(cap, base * 2^(n-1)) (equal jitter), the next attempt time is
computed by PostgreSQL and the delay is kept in the job event.

Faults: the Faults port is async; relay reaches after_commit_before_publish
and after_publish_before_confirm, worker reaches after_claim_before_side_effect,
stall_after_claim (once, FAULT_STALL_SECONDS), after_s3_write_before_commit
and after_commit_before_ack. Crashes are os._exit(137).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-29 03:08:31 +03:00
ArtyomandClaude Opus 5.5 f2242eb39d Render variants in killable processes with time and memory limits
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>
2026-10-29 03:02:16 +03:00
ArtyomandClaude Opus 5.5 431b82fd43 Render crop and optimized variants next to the thumbnail
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>
2026-10-29 03:00:11 +03:00
ArtyomandClaude Opus 5.5 045d631c12 Propose crop, optimized, worker limits and job recovery as an openspec change
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>
2026-10-29 01:44:02 +03:00
ArtyomandClaude Opus 5.5 adb29a2afc Archive the asynchronous attachments change
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>
2026-10-29 01:31:34 +03:00
ArtyomandClaude Opus 5.5 a55bc716c4 Record level 3 evidence and fill in the report
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>
2026-10-29 01:31:07 +03:00
ArtyomandClaude Opus 5.5 fe2693870e Add the level 3 pipeline scenarios and the stand evidence
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>
2026-10-29 01:19:13 +03:00
ArtyomandClaude Opus 5.5 c55fb1b998 Run the broker, the relay and the worker in the stand
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>
2026-10-29 01:19:04 +03:00
ArtyomandClaude Opus 5.5 34741dc2d2 Refuse failed attachments in messages through a zone port
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>
2026-10-29 01:09:31 +03:00
ArtyomandClaude Opus 5.5 b152b6e07e Process attachment jobs through an outbox, a relay and a worker
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>
2026-10-29 01:08:06 +03:00
ArtyomandClaude Opus 5.5 64fdaa03f2 Add the jobs, outbox and variants schema as an additive migration
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>
2026-10-29 00:43:34 +03:00
ArtyomandClaude Opus 5.5 d9bcc7324b Propose asynchronous attachment processing as an openspec change
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>
2026-10-29 00:42:15 +03:00
ArtyomandClaude Opus 5.5 540fcb35ba Carry over the lab 4 solution
Bring the application, own tests, Dockerfile, toolchain, compose stack,
HAProxy, k6 and RustFS configuration, migrations, hooks, evidence and
scenario scripts and the CI job from the lab 4 solution commit d2744bc,
merge the lab 4 Makefile targets into the lab 5 skeleton Makefile
without touching its targets, and append the lab 4 solution variables
to the skeleton .env.example. The package and the application follow
the contract version 1.5.0, and the image and the throwaway test
containers are tagged lab5 so they do not collide with a lab 4 stand on
the same host.

This is the starting point of the lab 5 cycle: lint, own tests and the
offline skeleton check pass before any lab 5 change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-29 00:34:03 +03:00
ArtyomandClaude Opus 5.5 1210dd899c Carry over the agent context and openspec history from lab 4
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>
2026-10-29 00:32:37 +03:00
Mikhail Verkovykh 276dbdad8a Подготовить skeleton лабораторной 5 по мессенджеру 2026-09-10 18:01:35 +03:00
789 changed files with 78158 additions and 77 deletions
+181
View File
@@ -0,0 +1,181 @@
---
name: "OPSX: Apply"
description: "Implement tasks from an OpenSpec change (Experimental)"
allowed-tools: Bash(openspec:*)
category: "Workflow"
tags: ["workflow", "artifacts", "experimental"]
---
Implement tasks from an OpenSpec change.
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
**Input**: Optionally specify a change name (e.g., `/opsx:apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
**Steps**
1. **Select the change**
If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
2. **Check status to understand the schema**
```bash
openspec status --change "<name>" --json
```
Parse the JSON to understand:
- `schemaName`: The workflow being used (e.g., "spec-driven")
- `planningHome`, `changeRoot`, and `actionContext`: planning scope and edit constraints
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
3. **Get apply instructions**
```bash
openspec instructions apply --change "<name>" --json
```
This returns:
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
- Progress (total, complete, remaining)
- Task list with status
- Dynamic instruction based on current state
- Optional `context`: current required project instruction input from the selected root
- Optional `operationGuidance`: current advisory guidance for apply
**Handle states:**
- If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue` (if it is not installed, run `openspec status --change "<name>" --json` to see the next artifact and `openspec instructions <artifact-id> --change "<name>" --json` for how to create it)
- If `state: "all_done"`: congratulate, suggest archive
- Otherwise: proceed to implementation
Treat `context` as a required prompt-level input. Read and consider it, and
apply relevant project facts, conventions, and constraints while implementing.
Treat `operationGuidance` as optional additive advice. Read and consider every
entry, and follow entries that are applicable and compatible with the built-in
workflow.
Keep both fields separate from CLI-returned state, missing artifacts, tasks,
progress, `contextFiles`, and the built-in `instruction`. They are not
evidence of task completion, do not replace the built-in instruction, and do
not permit bypassing a blocked state. If context conflicts with the built-in
instruction, an explicit user choice, or a CLI-controlled value, report the
conflict and preserve the controlling value. If guidance is inapplicable or
conflicts with those controlling inputs, do not follow it and explain why.
These are prompt-level behavior contracts, not enforceable checks.
4. **Read context files**
Read every file path listed under `contextFiles` from the apply instructions output.
The files depend on the schema being used:
- **spec-driven**: proposal, specs, design, tasks
- Other schemas: follow the contextFiles from CLI output
Do not copy `context` or `operationGuidance` verbatim into implementation
files or planning artifacts unless the user separately asks for that content.
5. **Show current progress**
Display:
- Schema being used
- Progress: "N/M tasks complete"
- Remaining tasks overview
- Dynamic instruction from CLI
6. **Implement tasks (loop until done or blocked)**
For each pending task:
- Show which task is being worked on
- Make the code changes required
- Keep changes minimal and focused
- Mark task complete in the tasks file: `- [ ]` → `- [x]`
- Continue to next task
**Pause if:**
- Task is unclear → ask for clarification
- Implementation reveals a design issue → suggest updating artifacts
- Error or blocker encountered → report and wait for guidance
- User interrupts
7. **On completion or pause, show status**
Display:
- Tasks completed this session
- Overall progress: "N/M tasks complete"
- If all done: suggest archive
- If paused: explain why and wait for guidance
**Output During Implementation**
```
## Implementing: <change-name> (schema: <schema-name>)
Working on task 3/7: <task description>
[...implementation happening...]
✓ Task complete
Working on task 4/7: <task description>
[...implementation happening...]
✓ Task complete
```
**Output On Completion**
```
## Implementation Complete
**Change:** <change-name>
**Schema:** <schema-name>
**Progress:** 7/7 tasks complete ✓
### Completed This Session
- [x] Task 1
- [x] Task 2
...
All tasks complete! You can archive this change with `/opsx:archive`.
```
**Output On Pause (Issue Encountered)**
```
## Implementation Paused
**Change:** <change-name>
**Schema:** <schema-name>
**Progress:** 4/7 tasks complete
### Issue Encountered
<description of the issue>
**Options:**
1. <option 1>
2. <option 2>
3. Other approach
What would you like to do?
```
**Guardrails**
- Keep going through tasks until done or blocked
- Always read context files before starting (from the apply instructions output)
- If task is ambiguous, pause and ask before implementing
- If implementation reveals issues, pause and suggest artifact updates
- Keep code changes minimal and scoped to each task
- Update task checkbox immediately after completing each task
- Pause on errors, blockers, or unclear requirements - don't guess
- Use contextFiles from CLI output, don't assume specific file names
- Do not use context or operation guidance as proof that a task is complete
- Apply relevant project context; report conflicts with controlling workflow inputs
- Consider every guidance entry; explain any inapplicable or conflicting advice
- Do not copy runtime context or operation guidance into implementation files or planning artifacts
- Preserve CLI-controlled blocked/ready/all-done behavior and completion criteria
**Fluid Workflow Integration**
This skill supports the "actions on a change" model:
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
+225
View File
@@ -0,0 +1,225 @@
---
name: "OPSX: Archive"
description: "Archive a completed change in the experimental workflow"
allowed-tools: Bash(openspec:*)
category: "Workflow"
tags: ["workflow", "archive", "experimental"]
---
Archive a completed change in the experimental workflow.
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve the full path from each delta spec when resolving its main spec.
**Input**: Optionally specify a change name after `/opsx:archive` (e.g., `/opsx:archive add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
**Steps**
1. **Select the change**
If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
When prompting, show only active changes (not already archived).
Include the schema used for each change if available.
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:archive <other>`).
**Load current archive inputs before the existing archive checks:**
After resolving the selected change and planning root, run:
```bash
openspec instructions archive --change "<name>" --json
```
Keep the same selected-root flags on this command. This lookup is advisory and
optional: it only supplies extra prompt inputs, so it must never block archiving.
If it exits non-zero or returns invalid JSON — for example on an older CLI that
does not support this command yet — continue the archive workflow with no
context and no operation guidance. Do not report an error and do not stop.
A successful response may omit both optional fields. Treat `context` as a
required prompt-level input: read and consider it, and apply relevant project
facts, conventions, and constraints. Treat `operationGuidance` as optional
additive advice: read and consider every entry, and follow entries that are
applicable and compatible with the built-in archive workflow.
Keep both fields separate from built-in steps, explicit user choices, resolved
paths, CLI checks, and command contracts. If context conflicts with one of those
controlling inputs, report the conflict and preserve the controlling value. If
guidance is inapplicable or conflicts with a controlling input, do not follow it
and explain why. Do not infer replacement paths, skipped prompts, or flags from
either field, and do not copy their text verbatim into specs, change artifacts,
or archive summaries unless the user separately asks for it. These are
prompt-level behavior contracts, not enforceable checks.
2. **Check artifact completion status**
Run `openspec status --change "<name>" --json` to check artifact completion.
Parse the JSON to understand:
- `schemaName`: The workflow being used
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
- `artifacts`: List of artifacts with their status (`done`, `skipped`, or other)
**If any artifacts are neither `done` nor `skipped`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
- Display warning listing incomplete artifacts
- Prompt user for confirmation to continue
- Proceed if user confirms
3. **Check task completion status**
Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
**If incomplete tasks found:**
- Display warning showing count of incomplete tasks
- Prompt user for confirmation to continue
- Proceed if user confirms
**If no tasks file exists:** Proceed without task-related warning.
4. **Assess delta spec sync state**
Use `artifactPaths.specs.existingOutputPaths` from status JSON as the only
delta-spec source. If the `specs` entry is missing or
`existingOutputPaths` is empty, proceed without a sync prompt and do not infer
delta specs from other artifacts.
**If delta specs exist:**
- Compare each delta spec with its corresponding main spec at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (use the store-aware `planningHome.root` from step 2, not a hardcoded repo path)
- Determine what changes would be applied (adds, modifications, removals, renames)
- Show a combined summary before prompting
**Prompt options:**
- If changes needed: "Sync now (recommended)", "Archive without syncing"
- If already synced: "Archive now", "Sync anyway", "Cancel"
Route on the answer:
- "Cancel" — stop, do not archive
- "Archive without syncing" or "Archive now" — proceed to archive
- "Sync now" or "Sync anyway" — sync, then verify (below)
- Anything else — ask again rather than archiving
Before a selected sync writes any main spec, run
`openspec instructions specs --change "<name>" --json` once with the same
selected-root flags. Require a zero exit status and valid artifact-instruction
JSON. If the lookup fails or returns invalid JSON, report the error and stop
before writing any main spec or moving the change. A valid response with omitted
`rules` is the no-rules case. Apply returned `rules` only to the content and
form of main specs produced by this merge; do not use them as archive guidance,
change CLI behavior, or copy the rule text into any output file.
Then run the `/opsx:sync` workflow inline (agent-driven intelligent merge) for change '<name>', passing the delta spec analysis and the fetched specs-rule snapshot from above, and wait for it to finish. The inline sync must reuse that snapshot without fetching `specs` instructions again. Do not delegate it to a background task — step 5 would move `changeRoot` out from under a sync that is still reading it, leaving the change archived and the main specs never updated. If your agent can only run it by delegation, delegate synchronously and wait for the result.
Then re-run the comparison from the top of this step against every capability that has a delta spec in `artifactPaths.specs.existingOutputPaths` — not only the ones the sync reports it touched. A successful sync leaves nothing left to apply, so each capability must now read as already synced:
- ADDED requirements present
- MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
- REMOVED requirements gone — and where this sync retired a capability (removed its last requirement, leaving `## Requirements` empty), its main spec deleted rather than left empty; a spec the sync deliberately kept and reported is also a match
- RENAMED requirements present under the new name and absent under the old one
If the sync failed, or any capability does not match, report what differs and stop — do not archive. Nothing has moved and `changeRoot` is intact, so the user can fix the mismatch or re-run the sync and start the archive again.
5. **Perform the archive**
Create an `archive` directory under `planningHome.changesDir` if it doesn't exist:
```bash
mkdir -p "<planningHome.changesDir>/archive"
```
Generate the target name: use the change name as-is when it already starts with a `YYYY-MM-DD-` prefix; otherwise prepend the current date as `YYYY-MM-DD-<change-name>`. Never stack a second date (same rule as `openspec archive`).
**Check if target already exists:**
- If yes: Fail with error, suggest renaming existing archive or using different date
- If no: Move `changeRoot` to the archive directory
```bash
mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
```
6. **Display summary**
Show archive completion summary including:
- Change name
- Schema that was used
- Archive location
- Spec sync status (synced / sync skipped / no delta specs)
- Note about any warnings (incomplete artifacts/tasks)
**Output On Success**
```markdown
## Archive Complete
**Change:** <change-name>
**Schema:** <schema-name>
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
**Specs:** ✓ Synced to main specs
All artifacts complete. All tasks complete.
```
**Output On Success (No Delta Specs)**
```markdown
## Archive Complete
**Change:** <change-name>
**Schema:** <schema-name>
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
**Specs:** No delta specs
All artifacts complete. All tasks complete.
```
**Output On Success With Warnings**
```markdown
## Archive Complete (with warnings)
**Change:** <change-name>
**Schema:** <schema-name>
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
**Specs:** Sync skipped (user chose to skip)
**Warnings:**
- Archived with 2 incomplete artifacts
- Archived with 3 incomplete tasks
- Delta spec sync was skipped (user chose to skip)
Review the archive if this was not intentional.
```
**Output On Error (Archive Exists)**
```markdown
## Archive Failed
**Change:** <change-name>
**Target:** the archive path derived from `planningHome.changesDir`/<target-name>/
Target archive directory already exists.
**Options:**
1. Rename the existing archive
2. Delete the existing archive if it's a duplicate
3. Wait until a different date to archive
```
**Guardrails**
- Announce the selected change; prompt for selection when it is ambiguous
- Use artifact graph (openspec status --json) for completion checking
- Don't block archive on warnings - just inform and confirm
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
- Show clear summary of what happened
- If sync is requested, run the `/opsx:sync` workflow inline (agent-driven)
- Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving `changeRoot`
- If delta specs exist, always run the sync assessment and show the combined summary before prompting
- Apply relevant runtime context and report conflicts; operation guidance remains advisory
- Consider every guidance entry and explain any inapplicable or conflicting advice
- Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
- Artifact rules constrain only the specs being written and are never operation guidance
- Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files
+193
View File
@@ -0,0 +1,193 @@
---
name: "OPSX: Explore"
description: "Enter explore mode - think through ideas, investigate problems, clarify requirements"
allowed-tools: Bash(openspec:*)
category: "Workflow"
tags: ["workflow", "explore", "experimental", "thinking"]
---
Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first and create a change proposal. You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. For a new change, scaffold it first as described below.
**This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore.
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
**Input**: The argument after `/opsx:explore` is whatever the user wants to think about. Could be:
- A vague idea: "real-time collaboration"
- A specific problem: "the auth system is getting unwieldy"
- A change name: "add-dark-mode" (to explore in context of that change)
- A comparison: "postgres vs sqlite for this"
- Nothing (just enter explore mode)
---
## The Stance
- **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
- **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
- **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
- **Adaptive** - Follow interesting threads, pivot when new information emerges
- **Patient** - Don't rush to conclusions, let the shape of the problem emerge
- **Grounded** - Explore the actual codebase when relevant, don't just theorize
---
## What You Might Do
Depending on what the user brings, you might:
**Explore the problem space**
- Ask clarifying questions that emerge from what they said
- Challenge assumptions
- Reframe the problem
- Find analogies
**Investigate the codebase**
- Map existing architecture relevant to the discussion
- Find integration points
- Identify patterns already in use
- Surface hidden complexity
**Compare options**
- Brainstorm multiple approaches
- Build comparison tables
- Sketch tradeoffs
- Recommend a path (if asked)
**Visualize**
```
┌─────────────────────────────────────────┐
│ Use ASCII diagrams liberally │
├─────────────────────────────────────────┤
│ │
│ ┌────────┐ ┌────────┐ │
│ │ State │────────▶│ State │ │
│ │ A │ │ B │ │
│ └────────┘ └────────┘ │
│ │
│ System diagrams, state machines, │
│ data flows, architecture sketches, │
│ dependency graphs, comparison tables │
│ │
└─────────────────────────────────────────┘
```
**Surface risks and unknowns**
- Identify what could go wrong
- Find gaps in understanding
- Suggest spikes or investigations
---
## OpenSpec Awareness
You have full context of the OpenSpec system. Use it naturally, don't force it.
### Check for context
At the start, quickly check what exists:
```bash
openspec list --json
```
This tells you:
- If there are active changes
- Their names, schemas, and status
- What the user might be working on
Then read the project's own context from the resolved root - `<root.path>/openspec/config.yaml` (or `config.yml`). Use the `root.path` returned above, and skip this if neither file exists:
- `context`: project background - tech stack, conventions, constraints
- `rules`: keyed by artifact id - the entries for an artifact apply only when you write that artifact
Ground your thinking in these. They are constraints for you to follow, not content to reproduce: do NOT copy them into the conversation or into any artifact you create.
If the user mentioned a specific change name, read its artifacts for context.
### When no change exists
Think freely. When insights crystallize, you might offer:
- "This feels solid enough to start a change. Want me to create a proposal?"
- Or keep exploring - no pressure to formalize
If the user asks you to capture the exploration as a new change, transition seamlessly into the requested capture:
1. Run `openspec new change "<name>"` (with `--store <id>` when applicable) before creating any artifacts. Never create a new change directory under `openspec/changes/` by hand; the CLI scaffold creates required metadata such as `.openspec.yaml`. Keep the selected `--store <id>` on every applicable follow-up `status` and `instructions` command.
2. Run `openspec status --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store), then process the requested artifacts in dependency order. For each requested artifact that is `ready`, run `openspec instructions "<artifact-id>" --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store). Before creating a requested artifact, evaluate any condition in its own `instruction` against the explored change; record a deliberate skip instead when the condition does not apply. If a requested artifact is blocked by a direct prerequisite the user did not request, run `openspec instructions "<prerequisite-id>" --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store) for that prerequisite whether it is `ready` or `blocked`. If its own `instruction` states a condition, evaluate that condition against the explored change and record a deliberate skip only when the condition does not apply. If the condition applies, or the prerequisite is not conditional, treat it as a normal prerequisite and ask before expanding the capture. Do not create an unrequested prerequisite unless the user approves.
3. Follow the returned `template` and `instruction` fields. Read completed dependency files listed in `dependencies`, and apply `context` and `rules` as constraints without copying them into the artifact. If the instruction delegates creation to a specific skill or command, invoke it; otherwise write the artifact to `resolvedOutputPath`, using the instruction to choose a concrete path when it is a glob. Verify that the selected concrete output exists.
4. After creating each artifact, re-run `openspec status --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store) and continue until every requested artifact is `done`, `skipped`, or was deliberately skipped because its own `instruction` stated a condition that did not apply. Tell the user about a deliberate conditional skip, remember it, and do not reconsider it. Dependencies are enablers, not gates: if a requested artifact is still `blocked` only because you deliberately skipped a conditional prerequisite, run `openspec instructions "<artifact-id>" --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store) despite the blocked status, then create it using step 3 only when those recorded conditional skips are its sole missing dependencies. If a requested artifact is blocked by a prerequisite the user did not ask to capture and cannot be conditionally skipped, explain that dependency and ask before expanding the capture.
Capture the artifact(s) the user requested without asking them to invoke another workflow command. If they asked only to start a change, stop after scaffolding and show its status.
### When a change exists
If the user mentions a change or you detect one is relevant:
1. **Resolve and read existing artifacts for context**
- Run `openspec status --change "<name>" --json`.
- Use `changeRoot`, `artifactPaths`, and `actionContext` from the status JSON.
- Read existing files from `artifactPaths.<artifact>.existingOutputPaths`.
2. **Reference them naturally in conversation**
- "Your design mentions using Redis, but we just realized SQLite fits better..."
- "The proposal scopes this to premium users, but we're now thinking everyone..."
3. **Offer to capture when decisions are made**
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve an existing capability's full path and follow the project's established organization for new capabilities.
| Insight Type | Where to Capture |
|----------------------------|-------------------------------------|
| New requirement discovered | `specs/<capability-path>/spec.md` |
| Requirement changed | `specs/<capability-path>/spec.md` |
| Design decision made | `design.md` |
| Scope changed | `proposal.md` |
| New work identified | `tasks.md` |
| Assumption invalidated | Relevant artifact |
Example offers:
- "That's a design decision. Capture it in design.md?"
- "This is a new requirement. Add it to specs?"
- "This changes scope. Update the proposal?"
4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
---
## What You Don't Have To Do
- Follow a script
- Ask the same questions every time
- Produce a specific artifact
- Reach a conclusion
- Stay on topic if a tangent is valuable
- Be brief (this is thinking time)
---
## Ending Discovery
There's no required ending. Discovery might:
- **Flow into a proposal**: "Ready to start? I can create a change proposal."
- **Result in artifact updates**: "Updated design.md with these decisions"
- **Just provide clarity**: User has what they need, moves on
- **Continue later**: "We can pick this up anytime"
When things crystallize, you might offer a summary - but it's optional. Sometimes the thinking IS the value.
---
## Guardrails
- **Don't implement** - Never write code or implement features. Creating OpenSpec artifacts is fine, writing application code is not.
- **Don't fake understanding** - If something is unclear, dig deeper
- **Don't rush** - Discovery is thinking time, not task time
- **Don't force structure** - Let patterns emerge naturally
- **Don't auto-capture** - Offer to save insights, don't just do it
- **Don't manually scaffold changes** - Never create a new change directory under `openspec/changes/` by hand. Always use `openspec new change "<name>"` (with `--store <id>` when applicable) so required metadata such as `.openspec.yaml` is created before writing artifacts.
- **Do visualize** - A good diagram is worth many paragraphs
- **Do explore the codebase** - Ground discussions in reality
- **Do question assumptions** - Including the user's and your own
+145
View File
@@ -0,0 +1,145 @@
---
name: "OPSX: Propose"
description: "Propose a new change - create it and generate all artifacts in one step"
allowed-tools: Bash(openspec:*)
category: "Workflow"
tags: ["workflow", "artifacts", "experimental"]
---
Propose a new change - create the change and generate all artifacts in one step.
**Planning boundary**: This workflow creates planning artifacts only. The user request that selected or triggered this workflow authorizes planning only, even if it asks to build or fix something. Do not edit project code. After the planning artifacts are complete, stop. Do not start implementation in the same response, even if the initial request asks for it. Wait for a new user request after the artifacts are presented; then start the apply workflow.
I'll create a change with the artifacts your schema defines. With the default spec-driven schema that is:
- proposal.md (what & why)
- `specs/<capability-path>/spec.md` (what the system must do - a delta, not the main spec)
- design.md (how)
- tasks.md (implementation steps)
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve an existing capability's full path and follow the project's established organization for new capabilities.
When the user is ready to implement, they must start the apply workflow explicitly.
---
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
**Input**: The argument after `/opsx:propose` is the change name (kebab-case), OR a description of what the user wants to build.
**Steps**
1. **Understand the request and clarify material ambiguity**
If no input is provided, ask the user (open-ended, no preset options):
> "What change do you want to work on? Describe what you want to build or fix."
From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`).
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
If the request contains ambiguity that would materially affect scope, externally observable behavior, compatibility, or acceptance criteria, ask the user before creating the change. For minor details, make a reasonable assumption and record it in the planning artifacts.
2. **Determine the workflow schema**
Use the configured default schema unless the user explicitly requests a different workflow.
**Use a different schema only if the user:**
- Explicitly requests a specific schema by name → use `--schema <schema-name>`
- Asks to "show workflows" or asks "what workflows" exist → resolve the authoritative root by running `openspec context --json` from the current working directory. If the user explicitly selected a registered store, use `openspec context --json --store "<store-id>"`. Then run `openspec schemas --json` with its working directory set to the returned `root.path` and let them choose. This preserves roots selected by a local `store:` pointer or the global `defaultStore`; `schemas` does not accept `--store`. If context reports only `no_openspec_root`, run `openspec schemas --json` from the current working directory instead. Do not use this fallback for invalid or unavailable stores.
Otherwise, omit `--schema` to preserve the configured default.
3. **Create the change directory**
Choose one schema form below. If a registered store is selected, append `--store "<store-id>"` to that command and each later OpenSpec command shown below that accepts `--store`.
Using the configured default:
```bash
openspec new change "<name>"
```
Using an explicitly requested schema:
```bash
openspec new change "<name>" --schema "<schema-name>"
```
This creates a scaffolded change in the planning home resolved by the CLI with `.openspec.yaml`.
4. **Get the artifact build order**
```bash
openspec status --change "<name>" --json
```
Parse the JSON to get:
- `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
- `artifacts`: list of all artifacts, each with its `status` and its `requires` edges (the artifact IDs it directly depends on)
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
5. **Create every artifact in the required set**
Use a todo list to track progress through the artifacts.
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
a. **For each artifact that is `ready` (dependencies satisfied)**:
- Get instructions:
```bash
openspec instructions <artifact-id> --change "<name>" --json
```
- The instructions JSON includes:
- `context`: Project background (constraints for you - do NOT include in output)
- `rules`: Artifact-specific rules (constraints for you - do NOT include in output)
- `template`: The structure to use for your output file
- `instruction`: Schema-specific guidance for this artifact type
- `skipped`/`warning`: present when the change declares skip_specs and this artifact must NOT be created - stop and pick another artifact
- `resolvedOutputPath`: Resolved path or pattern to write the artifact
- `dependencies`: Completed artifacts to read for context
- Read any completed dependency files for context - always re-read them from disk, even if you saw them earlier in the conversation (the user may have edited them)
- If the `instruction` field delegates creation to a specific skill or command, invoke it to produce the artifact instead of writing the file yourself, then verify the artifact file exists at `resolvedOutputPath`
- Otherwise create the artifact file using `template` as the structure and write it to `resolvedOutputPath`. If `resolvedOutputPath` is a glob, follow `instruction` to choose the concrete file path
- Apply `context` and `rules` as constraints - but do NOT copy them into the file
- Show brief progress: "Created <artifact-id>"
b. **Continue until every artifact in the required set exists (not just `apply.requires`)**
- After creating each artifact, re-run `openspec status --change "<name>" --json`
- The required set is `applyRequires` plus every artifact reachable from those by following the `requires` edges in `status --json` - walk them transitively (spec-driven closes over proposal, specs, design, tasks). Leave artifacts outside that set alone
- `status` is file-existence only, so an `applyRequires` artifact reading `done` does NOT mean its dependencies exist - writing `tasks.md` early marks `tasks` done while `specs` was never written. Use each artifact's `requires` edges, not its `status`, to build the required set: a `done` artifact still lists what it depends on
- An artifact already reading `status: "skipped"` is satisfied: the change declares `skip_specs` in `.openspec.yaml`, so its files must NOT exist. Never try to create one
- Create every artifact in the required set that is missing, then re-check - creating one can unblock others
- Skip one only when `status` already reports it `skipped`, or when its own `instruction` says it is conditional: run `openspec instructions <artifact-id> --change "<name>" --json` and skip only if its `instruction` field marks it optional (e.g. "create only if..."). Spec-driven's `design.md` qualifies; `specs` qualifies only via the `skipped` status above, never by your own judgment. Tell the user, and do not reconsider it
- Dependencies are enablers, not gates: if a required artifact is still `blocked` only because you skipped a conditional dependency, write it anyway
- Stop when every artifact in the required set is `done`, `skipped`, or was deliberately skipped
c. **If an artifact requires user input** (unclear context):
- Ask the user to clarify
- Then continue with creation
6. **Show final status**
```bash
openspec status --change "<name>"
```
**Output**
After completing all artifacts, summarize:
- Change name and location
- List of artifacts created with brief descriptions, plus any conditional artifact you skipped and why
- What's ready: "All artifacts needed for implementation are ready."
- Prompt: "The artifacts are ready for review. When you are ready, run `/opsx:apply`."
**Artifact Creation Guidelines**
- Follow the `instruction` field from `openspec instructions` for each artifact type - it is the authoritative guidance, even for familiar artifact names
- If the `instruction` field directs you to use a specific skill or command to create the artifact, invoke it instead of writing the artifact directly
- The schema defines what each artifact should contain - follow it
- Read dependency artifacts for context before creating new ones
- Use `template` as the structure for your output file - fill in its sections
- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file
- Do NOT copy `<context>`, `<rules>`, `<project_context>` blocks into the artifact
- These guide what you write, but should never appear in the output
**Guardrails**
- The request that invoked this workflow authorizes planning only. Any implementation or apply instruction in that request does not carry forward. Do NOT implement the change, start the apply workflow, or edit project code during this workflow. After presenting the artifacts, stop and wait for a new user request to start the apply workflow
- Create every artifact the apply phase transitively depends on, not just the ids listed in `apply.requires`
- Always read dependency artifacts before creating a new one - re-read from disk, not from conversation memory (files may have changed since you last saw them)
- Ask about ambiguities that would materially change scope, externally observable behavior, compatibility, or acceptance criteria; for minor details, make reasonable assumptions and record them
- If a change with that name already exists, ask if user wants to continue it or create a new one
- Verify each artifact file exists after writing before proceeding to next
+258
View File
@@ -0,0 +1,258 @@
---
name: "OPSX: Sync"
description: "Sync delta specs from a change to main specs"
allowed-tools: Bash(openspec:*)
category: "Workflow"
tags: ["workflow", "specs", "experimental"]
---
Sync delta specs from a change to main specs.
This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve the full path from each delta spec when resolving its main spec.
**Input**: Optionally specify a change name after `/opsx:sync` (e.g., `/opsx:sync add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
**Steps**
1. **Select the change**
If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
When prompting, show changes that have delta specs (under `specs/` directory).
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:sync <other>`).
2. **Resolve change context**
Run:
```bash
openspec status --change "<name>" --json
```
The JSON includes `planningHome.root`. Main specs live under `<planningHome.root>/openspec/specs/` — use that (store-aware) root for every main-spec path below, not a hardcoded repo path. When a store is selected it points at the store, not the current repository.
3. **Find delta specs**
Use `artifactPaths.specs.existingOutputPaths` from the status JSON as the
only source of delta spec paths. If the `specs` entry is missing or
`existingOutputPaths` is empty, report that there are no delta specs to sync,
do not infer them from other artifacts, and stop without requesting artifact
instructions or writing a main spec.
Sync every path in `existingOutputPaths` unless the caller narrowed the set.
A caller narrows it by naming an explicit list of complete entries from
`existingOutputPaths` — copy those absolute values verbatim. Archive does
this inline, and a user can too (for example, by selecting the entry ending
in `/specs/billing/invoices/spec.md`).
Then sync only the named paths and leave the remaining delta specs untouched:
bulk archive excludes a delta whose implementation it could not find, and
syncing it anyway would write a main spec the caller deliberately withheld.
Carry that narrowed selection through step 4; never widen it back to the full
list. If a named path is not in `existingOutputPaths`, do not sync it —
report it and stop, rather than dropping it silently. If the named list is
empty, report that there is nothing to sync and stop without writing a main
spec.
Each delta spec file contains sections like:
- `## ADDED Requirements` - New requirements to add
- `## MODIFIED Requirements` - Changes to existing requirements
- `## REMOVED Requirements` - Requirements to remove
- `## RENAMED Requirements` - Requirements to rename (FROM:/TO: format)
If no delta specs found, inform user and stop.
4. **For each delta spec, apply changes to main specs**
Before the first main-spec write, obtain one current specs-rule snapshot:
- If archive invoked this workflow inline and supplied a valid snapshot from
`openspec instructions specs --change "<name>" --json`, reuse it and do not
fetch the same instructions again.
- Otherwise run that command once now with the same selected-root flags.
- If the direct lookup exits non-zero or returns invalid artifact-instruction
JSON, report the error and stop before writing any main spec. Do not treat the
failure as an absent rule set.
- A valid response with omitted `rules` means no artifact rules are configured
and the existing semantic merge continues.
Apply returned `rules` only to the content and form of the main specs produced
by this merge. Artifact rules are not operation guidance and cannot change
selected roots, delta paths, CLI checks, or workflow steps. Use their text as
constraints without copying it verbatim into a main spec or summary.
For each capability delta spec path selected in step 3 — the full `existingOutputPaths` list, or the narrowed subset when a caller supplied one (these may belong to a selected store, not the repo):
a. **Read the delta spec** to understand the intended changes
b. **Read the main spec** at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (may not exist yet)
c. **Apply changes intelligently**:
**ADDED Requirements:**
- If requirement doesn't exist in main spec → add it
- If requirement already exists → update it to match (treat as implicit MODIFIED)
**MODIFIED Requirements:**
- Find the requirement in main spec
- Apply the changes - this can be:
- Adding new scenarios the main spec does not have yet
- Modifying existing scenarios
- Changing the requirement description
- Preserve scenarios/content not mentioned in the delta
**REMOVED Requirements:**
- Remove the entire requirement block from main spec
- Retiring the capability. Delete the whole `spec.md` - and the directory once
nothing else is left in it - only when ALL of these hold:
1. removing the requirements *this run* left no requirement blocks;
2. the rest of the spec is well-formed (it still has a `## Purpose`);
3. the main spec was not already empty before this sync - if you removed
nothing, change nothing;
4. every other nonblank line in the whole file is accounted for as the
title, Purpose, Requirements header, or a canonical requirement's
statement, scenarios, or fenced examples;
5. the change's `.openspec.yaml` declares `retire_capabilities: true`;
6. the `spec.md` resolves inside the real specs root (do not follow a
capability-directory symlink to delete an external file).
If removing the selected requirements would leave no requirement blocks and
any retirement condition is not satisfied, do not modify the main spec. Stop
the sync for that capability, report the blocking condition, and tell the user
how to resolve it. Never write or leave an empty `## Requirements` section.
When only the marker is missing, say that too - it is the one thing the user
can add to make the retirement go through.
- Deleting the file also deletes its `## Purpose`; any other section blocks
retirement. Name Purpose when you report the retirement. Include a pasteable
`git checkout` only when the spec lived in the caller's checkout;
otherwise give checkout-scoped recovery guidance.
**RENAMED Requirements:**
- Find the FROM requirement, rename to TO
**`## Purpose` in the delta:**
- The main spec already has one and it is authoritative - leave it alone
(this is what `openspec archive` does; it warns and moves on)
d. **Create new main spec** if capability doesn't exist yet:
- Create `<planningHome.root>/openspec/specs/<capability-path>/spec.md`
- Add Purpose section: copy the delta's `## Purpose` body verbatim when it has one
(this is what `openspec archive` does); only write a brief TBD placeholder when it does not
- Add Requirements section with the ADDED requirements
- Follow the **Main Spec Format Reference** below
5. **Validate updated main specs**
Run `openspec validate --specs` with the same selected-root flags used earlier.
If validation fails, report the problems and do not claim the sync succeeded.
6. **Show summary**
After applying all changes, summarize:
- Which capabilities were updated
- What changes were made (requirements added/modified/removed/renamed)
- Any new main spec left with a TBD Purpose placeholder, so it gets written
now rather than lingering
- Any capability retired, naming the deleted `spec.md`, its Purpose, and
either a pasteable `git checkout` or checkout-scoped recovery guidance
**Delta Spec Format Reference**
```markdown
## Purpose
Only on a delta that introduces a brand-new capability. Seeds the new main spec.
## ADDED Requirements
### Requirement: New Feature
The system SHALL do something new.
#### Scenario: Basic case
- **WHEN** user does X
- **THEN** system does Y
## MODIFIED Requirements
### Requirement: Existing Feature
The system SHALL keep doing the existing thing, now also handling A.
#### Scenario: Scenario the main spec already has
- **WHEN** user does X
- **THEN** system does Y
#### Scenario: New scenario to add
- **WHEN** user does A
- **THEN** system does B
## REMOVED Requirements
### Requirement: Deprecated Feature
## RENAMED Requirements
- FROM: `### Requirement: Old Name`
- TO: `### Requirement: New Name`
```
**Main Spec Format Reference**
Main specs are what the delta merges INTO. They must never contain delta operation headers (`## ADDED/MODIFIED/REMOVED/RENAMED Requirements`) - after syncing, every requirement lives under a single `## Requirements` section:
```markdown
# <capability> Specification
## Purpose
Short description of what this capability does and why it exists.
## Requirements
### Requirement: New Feature
The system SHALL do something new.
#### Scenario: Basic case
- **WHEN** user does X
- **THEN** system does Y
```
**Key Principle: Intelligent Merging**
Unlike programmatic merging, you merge rather than overwrite:
- A MODIFIED block carries the whole requirement - body plus every scenario that survives the change. `openspec validate` and `openspec archive` both reject one that drops a scenario the main spec still has.
- Keep anything the delta does not mention, in the main spec's existing order
- Use your judgment to merge changes sensibly
**Output On Success**
```markdown
## Specs Synced: <change-name>
Updated main specs:
**<capability-1>**:
- Added requirement: "New Feature"
- Modified requirement: "Existing Feature" (added 1 scenario)
**<capability-2>**:
- Created new spec file
- Added requirement: "Another Feature"
Main specs are now updated. The change remains active - archive when implementation is complete.
```
**Guardrails**
- Read both delta and main specs before making changes
- Preserve existing content not mentioned in delta
- Never copy a delta file into a main spec as-is - merge its content so the main spec keeps the Main Spec Format Reference structure, with no delta operation headers
- If something is unclear, ask for clarification
- Show what you're changing as you go
- The operation should be idempotent - running twice should give same result
- Use only `artifactPaths.specs.existingOutputPaths`; never infer delta specs from unrelated artifacts
- Honor a caller-supplied subset of `existingOutputPaths`; never widen it back to the full list
- Fetch specs instructions once for direct sync, or reuse the archive-supplied snapshot inline
- Stop before every main-spec write on a non-zero or invalid JSON specs-instruction response
- Artifact rules constrain only the specs being written and are never copied into output files
+87
View File
@@ -0,0 +1,87 @@
---
name: "OPSX: Update"
description: "Update a change - revise existing planning artifacts and keep them coherent (Experimental)"
allowed-tools: Bash(openspec:*)
category: "Workflow"
tags: ["workflow", "artifacts", "experimental"]
---
Revise a change's existing planning artifacts and keep them coherent. Never edit code.
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
**Input**: Optionally specify a change name after `/opsx:update` (e.g., `/opsx:update add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
`/opsx:continue` is an expanded-profile workflow and may not be installed. Before suggesting it anywhere below, verify that it is available. If it is unavailable, `openspec status --change "<name>" --json` shows the next artifact and `openspec instructions "<artifact-id>" --change "<name>" --json` explains how to create it.
**Steps**
1. **Select the change**
If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run `openspec list --json` to get available changes sorted by most recently modified, and ask the user to select one
When prompting, present the top 3-4 most recently modified changes as options, showing:
- Change name
- Schema (from `schema` field if present, otherwise "spec-driven")
- Status (e.g., "0/5 tasks", "complete", "no tasks")
- How recently it was modified (from `lastModified` field)
Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to update.
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:update <other>`).
2. **Get the change's artifacts**
```bash
openspec status --change "<name>" --json
```
Parse the JSON to understand current state. The response includes:
- `schemaName`: The workflow schema being used (e.g., "spec-driven")
- `artifacts`: Array of artifacts with their status ("done", "skipped", "ready", "blocked")
- `isPlanningComplete`: Boolean indicating if all planning artifacts are complete. Older CLI versions expose the same value as `isComplete`.
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
The artifact ids and paths come from the active schema - do NOT assume them, and do NOT branch on hardcoded artifact names. Custom schemas must work unchanged.
The files to edit are `artifactPaths.<id>.existingOutputPaths` - the concrete files that exist on disk, already glob-expanded for glob artifacts (e.g. `specs/**/*.md`). Do NOT write to `resolvedOutputPath`: for a glob artifact it is still the glob pattern, not a real file.
3. **Understand the request**
- If the user asked for a specific revision ("the design now uses X"), that is the starting edit.
- If they only said "update" / "make this coherent", treat it as a coherence review: read the existing artifacts and check them against each other for contradictions, gaps, and duplication.
4. **Read and reconcile**
- Read the artifact(s) the request touches and the change's other existing artifacts.
- Apply the requested edit. Then check every other existing artifact against it - in ANY direction: an edit to a later artifact may require revising an earlier one, not only the other way around. Build order is a useful reading order, not a constraint on which artifacts may be revised.
- Note everything that is now inconsistent, missing, or contradictory.
- Revise only files that already exist (`existingOutputPaths`). Do NOT create artifacts that don't exist yet, and do NOT invent new files under a glob artifact - note them and point the user to `/opsx:continue` to create them.
- If the change is already coherent, say so and make no edits.
5. **Confirm and apply, one artifact at a time**
- Show each proposed revision and why. Write only after the user confirms.
- If the user rejects a revision, do not write it - leave that artifact unchanged.
- When a substantial rewrite is needed, get that artifact's rules and template first:
```bash
openspec instructions "<artifact-id>" --change "<name>" --json
```
6. **Point to the next step (guidance only - NEVER act on it)**
- Artifacts still missing -> suggest `/opsx:continue` to create them.
- Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan; suggest `/opsx:apply` to carry the delta into code.
- Everything done and implemented -> suggest `/opsx:archive`.
**Output**
After each invocation, show:
- Which artifacts were revised (and which proposed revisions were rejected)
- Anything deferred to `/opsx:continue` (not-yet-created artifacts or files)
- Where the change stands and the recommended next command
**Guardrails**
- Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes, stop and point to `/opsx:apply`.
- Use the artifact ids and paths reported by `openspec status`; never branch on hardcoded artifact names.
- Edit only the concrete files in `existingOutputPaths`; never write to a glob `resolvedOutputPath`.
- Do not advance the build frontier: no new artifacts, no new files under glob artifacts - that is `/opsx:continue`'s job.
- Confirm every edit with the user before writing.
- If the request changes the change's *intent* rather than refining it, first verify whether the expanded-profile `/opsx:new` workflow is available. If it is, recommend starting fresh with `/opsx:new` (the "Update vs. Start Fresh" heuristic). If it is unavailable, ask for a distinct unused change name and recommend `openspec new change "<new-change-name>"` instead.
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -uo pipefail
ROOT="${CLAUDE_PROJECT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
PAYLOAD=$(cat)
FILE=$(printf '%s' "$PAYLOAD" | /usr/bin/python3 -c 'import json,sys
try:
d = json.load(sys.stdin)
except Exception:
sys.exit(0)
t = d.get("tool_input") or {}
r = d.get("tool_response") or {}
p = r.get("filePath") or t.get("file_path") or ""
print(p)
' 2>/dev/null)
case "$FILE" in
"") exit 0 ;;
*.py) ;;
*) exit 0 ;;
esac
case "$FILE" in
"$ROOT"/src/*) ;;
src/*) FILE="$ROOT/$FILE" ;;
*) exit 0 ;;
esac
[ -f "$FILE" ] || exit 0
[ -x "$ROOT/.venv/bin/ruff" ] || exit 0
OUT=$(
cd "$ROOT" || exit 0
"$ROOT/.venv/bin/ruff" check --fix --quiet "$FILE" 2>&1
"$ROOT/.venv/bin/ruff" format --quiet "$FILE" 2>&1
if [ -x "$ROOT/.venv/bin/ty" ]; then
"$ROOT/.venv/bin/ty" check --quiet "$FILE" 2>&1 | grep -v "^All checks passed" || true
fi
)
if [ -n "$OUT" ]; then
printf 'ruff/ty по %s:\n%s\n' "${FILE#"$ROOT"/}" "$OUT" >&2
exit 2
fi
exit 0
+17
View File
@@ -0,0 +1,17 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit|NotebookEdit",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/lint-python.sh",
"timeout": 60,
"statusMessage": "ruff + ty по src/"
}
]
}
]
}
}
@@ -0,0 +1,185 @@
---
name: openspec-apply-change
description: Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
allowed-tools: Bash(openspec:*)
license: MIT
compatibility: Requires openspec CLI.
metadata:
author: openspec
version: "1.0"
generatedBy: "1.8.0"
---
Implement tasks from an OpenSpec change.
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
**Input**: Optionally specify a change name (e.g., `/opsx:apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
**Steps**
1. **Select the change**
If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
2. **Check status to understand the schema**
```bash
openspec status --change "<name>" --json
```
Parse the JSON to understand:
- `schemaName`: The workflow being used (e.g., "spec-driven")
- `planningHome`, `changeRoot`, and `actionContext`: planning scope and edit constraints
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
3. **Get apply instructions**
```bash
openspec instructions apply --change "<name>" --json
```
This returns:
- `contextFiles`: artifact ID -> array of concrete file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
- Progress (total, complete, remaining)
- Task list with status
- Dynamic instruction based on current state
- Optional `context`: current required project instruction input from the selected root
- Optional `operationGuidance`: current advisory guidance for apply
**Handle states:**
- If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue` (if it is not installed, run `openspec status --change "<name>" --json` to see the next artifact and `openspec instructions <artifact-id> --change "<name>" --json` for how to create it)
- If `state: "all_done"`: congratulate, suggest archive
- Otherwise: proceed to implementation
Treat `context` as a required prompt-level input. Read and consider it, and
apply relevant project facts, conventions, and constraints while implementing.
Treat `operationGuidance` as optional additive advice. Read and consider every
entry, and follow entries that are applicable and compatible with the built-in
workflow.
Keep both fields separate from CLI-returned state, missing artifacts, tasks,
progress, `contextFiles`, and the built-in `instruction`. They are not
evidence of task completion, do not replace the built-in instruction, and do
not permit bypassing a blocked state. If context conflicts with the built-in
instruction, an explicit user choice, or a CLI-controlled value, report the
conflict and preserve the controlling value. If guidance is inapplicable or
conflicts with those controlling inputs, do not follow it and explain why.
These are prompt-level behavior contracts, not enforceable checks.
4. **Read context files**
Read every file path listed under `contextFiles` from the apply instructions output.
The files depend on the schema being used:
- **spec-driven**: proposal, specs, design, tasks
- Other schemas: follow the contextFiles from CLI output
Do not copy `context` or `operationGuidance` verbatim into implementation
files or planning artifacts unless the user separately asks for that content.
5. **Show current progress**
Display:
- Schema being used
- Progress: "N/M tasks complete"
- Remaining tasks overview
- Dynamic instruction from CLI
6. **Implement tasks (loop until done or blocked)**
For each pending task:
- Show which task is being worked on
- Make the code changes required
- Keep changes minimal and focused
- Mark task complete in the tasks file: `- [ ]` → `- [x]`
- Continue to next task
**Pause if:**
- Task is unclear → ask for clarification
- Implementation reveals a design issue → suggest updating artifacts
- Error or blocker encountered → report and wait for guidance
- User interrupts
7. **On completion or pause, show status**
Display:
- Tasks completed this session
- Overall progress: "N/M tasks complete"
- If all done: suggest archive
- If paused: explain why and wait for guidance
**Output During Implementation**
```
## Implementing: <change-name> (schema: <schema-name>)
Working on task 3/7: <task description>
[...implementation happening...]
✓ Task complete
Working on task 4/7: <task description>
[...implementation happening...]
✓ Task complete
```
**Output On Completion**
```
## Implementation Complete
**Change:** <change-name>
**Schema:** <schema-name>
**Progress:** 7/7 tasks complete ✓
### Completed This Session
- [x] Task 1
- [x] Task 2
...
All tasks complete! You can archive this change with `/opsx:archive`.
```
**Output On Pause (Issue Encountered)**
```
## Implementation Paused
**Change:** <change-name>
**Schema:** <schema-name>
**Progress:** 4/7 tasks complete
### Issue Encountered
<description of the issue>
**Options:**
1. <option 1>
2. <option 2>
3. Other approach
What would you like to do?
```
**Guardrails**
- Keep going through tasks until done or blocked
- Always read context files before starting (from the apply instructions output)
- If task is ambiguous, pause and ask before implementing
- If implementation reveals issues, pause and suggest artifact updates
- Keep code changes minimal and scoped to each task
- Update task checkbox immediately after completing each task
- Pause on errors, blockers, or unclear requirements - don't guess
- Use contextFiles from CLI output, don't assume specific file names
- Do not use context or operation guidance as proof that a task is complete
- Apply relevant project context; report conflicts with controlling workflow inputs
- Consider every guidance entry; explain any inapplicable or conflicting advice
- Do not copy runtime context or operation guidance into implementation files or planning artifacts
- Preserve CLI-controlled blocked/ready/all-done behavior and completion criteria
**Fluid Workflow Integration**
This skill supports the "actions on a change" model:
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
@@ -0,0 +1,182 @@
---
name: openspec-archive-change
description: Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
allowed-tools: Bash(openspec:*)
license: MIT
compatibility: Requires openspec CLI.
metadata:
author: openspec
version: "1.0"
generatedBy: "1.8.0"
---
Archive a completed change in the experimental workflow.
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve the full path from each delta spec when resolving its main spec.
**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
**Steps**
1. **Select the change**
If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
When prompting, show only active changes (not already archived).
Include the schema used for each change if available.
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:archive <other>`).
**Load current archive inputs before the existing archive checks:**
After resolving the selected change and planning root, run:
```bash
openspec instructions archive --change "<name>" --json
```
Keep the same selected-root flags on this command. This lookup is advisory and
optional: it only supplies extra prompt inputs, so it must never block archiving.
If it exits non-zero or returns invalid JSON — for example on an older CLI that
does not support this command yet — continue the archive workflow with no
context and no operation guidance. Do not report an error and do not stop.
A successful response may omit both optional fields. Treat `context` as a
required prompt-level input: read and consider it, and apply relevant project
facts, conventions, and constraints. Treat `operationGuidance` as optional
additive advice: read and consider every entry, and follow entries that are
applicable and compatible with the built-in archive workflow.
Keep both fields separate from built-in steps, explicit user choices, resolved
paths, CLI checks, and command contracts. If context conflicts with one of those
controlling inputs, report the conflict and preserve the controlling value. If
guidance is inapplicable or conflicts with a controlling input, do not follow it
and explain why. Do not infer replacement paths, skipped prompts, or flags from
either field, and do not copy their text verbatim into specs, change artifacts,
or archive summaries unless the user separately asks for it. These are
prompt-level behavior contracts, not enforceable checks.
2. **Check artifact completion status**
Run `openspec status --change "<name>" --json` to check artifact completion.
Parse the JSON to understand:
- `schemaName`: The workflow being used
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context
- `artifacts`: List of artifacts with their status (`done`, `skipped`, or other)
**If any artifacts are neither `done` nor `skipped`** (skipped artifacts satisfy the requirement - the change declares skip_specs):
- Display warning listing incomplete artifacts
- Ask the user to confirm they want to proceed
- Proceed if user confirms
3. **Check task completion status**
Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
**If incomplete tasks found:**
- Display warning showing count of incomplete tasks
- Ask the user to confirm they want to proceed
- Proceed if user confirms
**If no tasks file exists:** Proceed without task-related warning.
4. **Assess delta spec sync state**
Use `artifactPaths.specs.existingOutputPaths` from status JSON as the only
delta-spec source. If the `specs` entry is missing or
`existingOutputPaths` is empty, proceed without a sync prompt and do not infer
delta specs from other artifacts.
**If delta specs exist:**
- Compare each delta spec with its corresponding main spec at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (use the store-aware `planningHome.root` from step 2, not a hardcoded repo path)
- Determine what changes would be applied (adds, modifications, removals, renames)
- Show a combined summary before prompting
**Prompt options:**
- If changes needed: "Sync now (recommended)", "Archive without syncing"
- If already synced: "Archive now", "Sync anyway", "Cancel"
Route on the answer:
- "Cancel" — stop, do not archive
- "Archive without syncing" or "Archive now" — proceed to archive
- "Sync now" or "Sync anyway" — sync, then verify (below)
- Anything else — ask again rather than archiving
Before a selected sync writes any main spec, run
`openspec instructions specs --change "<name>" --json` once with the same
selected-root flags. Require a zero exit status and valid artifact-instruction
JSON. If the lookup fails or returns invalid JSON, report the error and stop
before writing any main spec or moving the change. A valid response with omitted
`rules` is the no-rules case. Apply returned `rules` only to the content and
form of main specs produced by this merge; do not use them as archive guidance,
change CLI behavior, or copy the rule text into any output file.
Then run the `openspec-sync-specs` workflow inline (agent-driven intelligent merge) for change '<name>', passing the delta spec analysis and the fetched specs-rule snapshot from above, and wait for it to finish. The inline sync must reuse that snapshot without fetching `specs` instructions again. Do not delegate it to a background task — step 5 would move `changeRoot` out from under a sync that is still reading it, leaving the change archived and the main specs never updated. If your agent can only run it by delegation, delegate synchronously and wait for the result.
Then re-run the comparison from the top of this step against every capability that has a delta spec in `artifactPaths.specs.existingOutputPaths` — not only the ones the sync reports it touched. A successful sync leaves nothing left to apply, so each capability must now read as already synced:
- ADDED requirements present
- MODIFIED requirements carrying the scenario and description changes named in the delta, with their other scenarios intact
- REMOVED requirements gone — and where this sync retired a capability (removed its last requirement, leaving `## Requirements` empty), its main spec deleted rather than left empty; a spec the sync deliberately kept and reported is also a match
- RENAMED requirements present under the new name and absent under the old one
If the sync failed, or any capability does not match, report what differs and stop — do not archive. Nothing has moved and `changeRoot` is intact, so the user can fix the mismatch or re-run the sync and start the archive again.
5. **Perform the archive**
Create an `archive` directory under `planningHome.changesDir` if it doesn't exist:
```bash
mkdir -p "<planningHome.changesDir>/archive"
```
Generate the target name: use the change name as-is when it already starts with a `YYYY-MM-DD-` prefix; otherwise prepend the current date as `YYYY-MM-DD-<change-name>`. Never stack a second date (same rule as `openspec archive`).
**Check if target already exists:**
- If yes: Fail with error, suggest renaming existing archive or using different date
- If no: Move `changeRoot` to the archive directory
```bash
mv "<changeRoot>" "<planningHome.changesDir>/archive/<target-name>"
```
6. **Display summary**
Show archive completion summary including:
- Change name
- Schema that was used
- Archive location
- Whether specs were synced (if applicable)
- Note about any warnings (incomplete artifacts/tasks)
**Output On Success**
```markdown
## Archive Complete
**Change:** <change-name>
**Schema:** <schema-name>
**Archived to:** the archive path derived from `planningHome.changesDir`/<target-name>/
**Specs:** <"✓ Synced to main specs" only if the step 4 verification passed; otherwise "No delta specs" or "Sync skipped">
<"All artifacts complete. All tasks complete." — or, if archived with warnings, list them instead (e.g. "Archived with 2 incomplete tasks")>
```
**Guardrails**
- Announce the selected change; prompt for selection when it is ambiguous
- Use artifact graph (openspec status --json) for completion checking
- Don't block archive on warnings - just inform and confirm
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
- Show clear summary of what happened
- If sync is requested, run the `openspec-sync-specs` workflow inline (agent-driven)
- Never archive while a spec sync is still in flight — run the sync inline and verify the main specs before moving `changeRoot`
- If delta specs exist, always run the sync assessment and show the combined summary before prompting
- Apply relevant runtime context and report conflicts; operation guidance remains advisory
- Consider every guidance entry and explain any inapplicable or conflicting advice
- Existing CLI checks, resolved paths, prompts, and command contracts are unchanged
- Artifact rules constrain only the specs being written and are never operation guidance
- Never copy runtime context, operation guidance, or artifact-rule text verbatim into output files
+308
View File
@@ -0,0 +1,308 @@
---
name: openspec-explore
description: Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.
allowed-tools: Bash(openspec:*)
license: MIT
compatibility: Requires openspec CLI.
metadata:
author: openspec
version: "1.0"
generatedBy: "1.8.0"
---
Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
**IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER write code or implement features. If the user asks you to implement something, remind them to exit explore mode first and create a change proposal. You MAY create OpenSpec artifacts (proposals, designs, specs) if the user asks—that's capturing thinking, not implementing. For a new change, scaffold it first as described below.
**This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore.
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
---
## The Stance
- **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
- **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
- **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
- **Adaptive** - Follow interesting threads, pivot when new information emerges
- **Patient** - Don't rush to conclusions, let the shape of the problem emerge
- **Grounded** - Explore the actual codebase when relevant, don't just theorize
---
## What You Might Do
Depending on what the user brings, you might:
**Explore the problem space**
- Ask clarifying questions that emerge from what they said
- Challenge assumptions
- Reframe the problem
- Find analogies
**Investigate the codebase**
- Map existing architecture relevant to the discussion
- Find integration points
- Identify patterns already in use
- Surface hidden complexity
**Compare options**
- Brainstorm multiple approaches
- Build comparison tables
- Sketch tradeoffs
- Recommend a path (if asked)
**Visualize**
```
┌─────────────────────────────────────────┐
│ Use ASCII diagrams liberally │
├─────────────────────────────────────────┤
│ │
│ ┌────────┐ ┌────────┐ │
│ │ State │────────▶│ State │ │
│ │ A │ │ B │ │
│ └────────┘ └────────┘ │
│ │
│ System diagrams, state machines, │
│ data flows, architecture sketches, │
│ dependency graphs, comparison tables │
│ │
└─────────────────────────────────────────┘
```
**Surface risks and unknowns**
- Identify what could go wrong
- Find gaps in understanding
- Suggest spikes or investigations
---
## OpenSpec Awareness
You have full context of the OpenSpec system. Use it naturally, don't force it.
### Check for context
At the start, quickly check what exists:
```bash
openspec list --json
```
This tells you:
- If there are active changes
- Their names, schemas, and status
- What the user might be working on
Then read the project's own context from the resolved root - `<root.path>/openspec/config.yaml` (or `config.yml`). Use the `root.path` returned above, and skip this if neither file exists:
- `context`: project background - tech stack, conventions, constraints
- `rules`: keyed by artifact id - the entries for an artifact apply only when you write that artifact
Ground your thinking in these. They are constraints for you to follow, not content to reproduce: do NOT copy them into the conversation or into any artifact you create.
### When no change exists
Think freely. When insights crystallize, you might offer:
- "This feels solid enough to start a change. Want me to create a proposal?"
- Or keep exploring - no pressure to formalize
If the user asks you to capture the exploration as a new change, transition seamlessly into the requested capture:
1. Run `openspec new change "<name>"` (with `--store <id>` when applicable) before creating any artifacts. Never create a new change directory under `openspec/changes/` by hand; the CLI scaffold creates required metadata such as `.openspec.yaml`. Keep the selected `--store <id>` on every applicable follow-up `status` and `instructions` command.
2. Run `openspec status --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store), then process the requested artifacts in dependency order. For each requested artifact that is `ready`, run `openspec instructions "<artifact-id>" --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store). Before creating a requested artifact, evaluate any condition in its own `instruction` against the explored change; record a deliberate skip instead when the condition does not apply. If a requested artifact is blocked by a direct prerequisite the user did not request, run `openspec instructions "<prerequisite-id>" --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store) for that prerequisite whether it is `ready` or `blocked`. If its own `instruction` states a condition, evaluate that condition against the explored change and record a deliberate skip only when the condition does not apply. If the condition applies, or the prerequisite is not conditional, treat it as a normal prerequisite and ask before expanding the capture. Do not create an unrequested prerequisite unless the user approves.
3. Follow the returned `template` and `instruction` fields. Read completed dependency files listed in `dependencies`, and apply `context` and `rules` as constraints without copying them into the artifact. If the instruction delegates creation to a specific skill or command, invoke it; otherwise write the artifact to `resolvedOutputPath`, using the instruction to choose a concrete path when it is a glob. Verify that the selected concrete output exists.
4. After creating each artifact, re-run `openspec status --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store) and continue until every requested artifact is `done`, `skipped`, or was deliberately skipped because its own `instruction` stated a condition that did not apply. Tell the user about a deliberate conditional skip, remember it, and do not reconsider it. Dependencies are enablers, not gates: if a requested artifact is still `blocked` only because you deliberately skipped a conditional prerequisite, run `openspec instructions "<artifact-id>" --change "<name>" --json` (append the confirmed `--store "<id>"` only for a registered standalone store) despite the blocked status, then create it using step 3 only when those recorded conditional skips are its sole missing dependencies. If a requested artifact is blocked by a prerequisite the user did not ask to capture and cannot be conditionally skipped, explain that dependency and ask before expanding the capture.
Capture the artifact(s) the user requested without asking them to invoke another workflow command. If they asked only to start a change, stop after scaffolding and show its status.
### When a change exists
If the user mentions a change or you detect one is relevant:
1. **Resolve and read existing artifacts for context**
- Run `openspec status --change "<name>" --json`.
- Use `changeRoot`, `artifactPaths`, and `actionContext` from the status JSON.
- Read existing files from `artifactPaths.<artifact>.existingOutputPaths`.
2. **Reference them naturally in conversation**
- "Your design mentions using Redis, but we just realized SQLite fits better..."
- "The proposal scopes this to premium users, but we're now thinking everyone..."
3. **Offer to capture when decisions are made**
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve an existing capability's full path and follow the project's established organization for new capabilities.
| Insight Type | Where to Capture |
|----------------------------|-------------------------------------|
| New requirement discovered | `specs/<capability-path>/spec.md` |
| Requirement changed | `specs/<capability-path>/spec.md` |
| Design decision made | `design.md` |
| Scope changed | `proposal.md` |
| New work identified | `tasks.md` |
| Assumption invalidated | Relevant artifact |
Example offers:
- "That's a design decision. Capture it in design.md?"
- "This is a new requirement. Add it to specs?"
- "This changes scope. Update the proposal?"
4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
---
## What You Don't Have To Do
- Follow a script
- Ask the same questions every time
- Produce a specific artifact
- Reach a conclusion
- Stay on topic if a tangent is valuable
- Be brief (this is thinking time)
---
## Handling Different Entry Points
**User brings a vague idea:**
```
User: I'm thinking about adding real-time collaboration
You: Real-time collab is a big space. Let me think about this...
COLLABORATION SPECTRUM
════════════════════════════════════════════
Awareness Coordination Sync
│ │ │
▼ ▼ ▼
┌────────┐ ┌────────┐ ┌────────┐
│Presence│ │Cursors │ │ CRDT │
│ "3 │ │ Multi │ │Conflict│
│online" │ │ select │ │ free │
└────────┘ └────────┘ └────────┘
│ │ │
trivial moderate complex
Where's your head at?
```
**User brings a specific problem:**
```
User: The auth system is a mess
You: [reads codebase]
┌─────────────────────────────────────────────┐
│ CURRENT AUTH FLOW │
└─────────────────────────────────────────────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ Google │ │ GitHub │ │ Email │
│ OAuth │ │ OAuth │ │ Magic │
└────┬────┘ └────┬────┘ └────┬────┘
│ │ │
└─────────────┼─────────────┘
▼
┌───────────┐
│ Session │
└─────┬─────┘
│
▼
┌───────────┐
│ Perms │
└───────────┘
I see three tangles. Which one's burning?
```
**User is stuck mid-implementation:**
```
User: /opsx:explore add-auth-system
The OAuth integration is more complex than expected
You: [reads change artifacts]
You're on task 4: "Implement OAuth flow"
Let me trace what's involved...
[draws diagram, explores options, suggests paths]
Want to update the design to reflect this?
Or add a spike task to investigate?
```
**User wants to compare options:**
```
User: Should we use Postgres or SQLite?
You: Generic answer is boring. What's the context?
User: A CLI tool that tracks local dev environments
You: That changes everything.
┌─────────────────────────────────────────────────┐
│ CLI TOOL DATA STORAGE │
└─────────────────────────────────────────────────┘
Key constraints:
• No daemon running
• Must work offline
• Single user
SQLite Postgres
Deployment embedded ✓ needs server ✗
Offline yes ✓ no ✗
Single file yes ✓ no ✗
SQLite. Not even close.
Unless... is there a sync component?
```
---
## Ending Discovery
There's no required ending. Discovery might:
- **Flow into a proposal**: "Ready to start? I can create a change proposal."
- **Result in artifact updates**: "Updated design.md with these decisions"
- **Just provide clarity**: User has what they need, moves on
- **Continue later**: "We can pick this up anytime"
When it feels like things are crystallizing, you might summarize:
```
## What We Figured Out
**The problem**: [crystallized understanding]
**The approach**: [if one emerged]
**Open questions**: [if any remain]
**Next steps** (if ready):
- Create a change proposal
- Keep exploring: just keep talking
```
But this summary is optional. Sometimes the thinking IS the value.
---
## Guardrails
- **Don't implement** - Never write code or implement features. Creating OpenSpec artifacts is fine, writing application code is not.
- **Don't fake understanding** - If something is unclear, dig deeper
- **Don't rush** - Discovery is thinking time, not task time
- **Don't force structure** - Let patterns emerge naturally
- **Don't auto-capture** - Offer to save insights, don't just do it
- **Don't manually scaffold changes** - Never create a new change directory under `openspec/changes/` by hand. Always use `openspec new change "<name>"` (with `--store <id>` when applicable) so required metadata such as `.openspec.yaml` is created before writing artifacts.
- **Do visualize** - A good diagram is worth many paragraphs
- **Do explore the codebase** - Ground discussions in reality
- **Do question assumptions** - Including the user's and your own
+149
View File
@@ -0,0 +1,149 @@
---
name: openspec-propose
description: Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation.
allowed-tools: Bash(openspec:*)
license: MIT
compatibility: Requires openspec CLI.
metadata:
author: openspec
version: "1.0"
generatedBy: "1.8.0"
---
Propose a new change - create the change and generate all artifacts in one step.
**Planning boundary**: This workflow creates planning artifacts only. The user request that selected or triggered this workflow authorizes planning only, even if it asks to build or fix something. Do not edit project code. After the planning artifacts are complete, stop. Do not start implementation in the same response, even if the initial request asks for it. Wait for a new user request after the artifacts are presented; then start the apply workflow.
I'll create a change with the artifacts your schema defines. With the default spec-driven schema that is:
- proposal.md (what & why)
- `specs/<capability-path>/spec.md` (what the system must do - a delta, not the main spec)
- design.md (how)
- tasks.md (implementation steps)
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve an existing capability's full path and follow the project's established organization for new capabilities.
When the user is ready to implement, they must start the apply workflow explicitly.
---
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
**Steps**
1. **Understand the request and clarify material ambiguity**
If no clear input is provided, ask the user (open-ended, no preset options):
> "What change do you want to work on? Describe what you want to build or fix."
From their description, derive a kebab-case name (e.g., "add user authentication" → `add-user-auth`).
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
If the request contains ambiguity that would materially affect scope, externally observable behavior, compatibility, or acceptance criteria, ask the user before creating the change. For minor details, make a reasonable assumption and record it in the planning artifacts.
2. **Determine the workflow schema**
Use the configured default schema unless the user explicitly requests a different workflow.
**Use a different schema only if the user:**
- Explicitly requests a specific schema by name → use `--schema <schema-name>`
- Asks to "show workflows" or asks "what workflows" exist → resolve the authoritative root by running `openspec context --json` from the current working directory. If the user explicitly selected a registered store, use `openspec context --json --store "<store-id>"`. Then run `openspec schemas --json` with its working directory set to the returned `root.path` and let them choose. This preserves roots selected by a local `store:` pointer or the global `defaultStore`; `schemas` does not accept `--store`. If context reports only `no_openspec_root`, run `openspec schemas --json` from the current working directory instead. Do not use this fallback for invalid or unavailable stores.
Otherwise, omit `--schema` to preserve the configured default.
3. **Create the change directory**
Choose one schema form below. If a registered store is selected, append `--store "<store-id>"` to that command and each later OpenSpec command shown below that accepts `--store`.
Using the configured default:
```bash
openspec new change "<name>"
```
Using an explicitly requested schema:
```bash
openspec new change "<name>" --schema "<schema-name>"
```
This creates a scaffolded change in the planning home resolved by the CLI with `.openspec.yaml`.
4. **Get the artifact build order**
```bash
openspec status --change "<name>" --json
```
Parse the JSON to get:
- `applyRequires`: array of artifact IDs needed before implementation (e.g., `["tasks"]`)
- `artifacts`: list of all artifacts, each with its `status` and its `requires` edges (the artifact IDs it directly depends on)
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
5. **Create every artifact in the required set**
Use a todo list to track progress through the artifacts.
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
a. **For each artifact that is `ready` (dependencies satisfied)**:
- Get instructions:
```bash
openspec instructions <artifact-id> --change "<name>" --json
```
- The instructions JSON includes:
- `context`: Project background (constraints for you - do NOT include in output)
- `rules`: Artifact-specific rules (constraints for you - do NOT include in output)
- `template`: The structure to use for your output file
- `instruction`: Schema-specific guidance for this artifact type
- `skipped`/`warning`: present when the change declares skip_specs and this artifact must NOT be created - stop and pick another artifact
- `resolvedOutputPath`: Resolved path or pattern to write the artifact
- `dependencies`: Completed artifacts to read for context
- Read any completed dependency files for context - always re-read them from disk, even if you saw them earlier in the conversation (the user may have edited them)
- If the `instruction` field delegates creation to a specific skill or command, invoke it to produce the artifact instead of writing the file yourself, then verify the artifact file exists at `resolvedOutputPath`
- Otherwise create the artifact file using `template` as the structure and write it to `resolvedOutputPath`. If `resolvedOutputPath` is a glob, follow `instruction` to choose the concrete file path
- Apply `context` and `rules` as constraints - but do NOT copy them into the file
- Show brief progress: "Created <artifact-id>"
b. **Continue until every artifact in the required set exists (not just `apply.requires`)**
- After creating each artifact, re-run `openspec status --change "<name>" --json`
- The required set is `applyRequires` plus every artifact reachable from those by following the `requires` edges in `status --json` - walk them transitively (spec-driven closes over proposal, specs, design, tasks). Leave artifacts outside that set alone
- `status` is file-existence only, so an `applyRequires` artifact reading `done` does NOT mean its dependencies exist - writing `tasks.md` early marks `tasks` done while `specs` was never written. Use each artifact's `requires` edges, not its `status`, to build the required set: a `done` artifact still lists what it depends on
- An artifact already reading `status: "skipped"` is satisfied: the change declares `skip_specs` in `.openspec.yaml`, so its files must NOT exist. Never try to create one
- Create every artifact in the required set that is missing, then re-check - creating one can unblock others
- Skip one only when `status` already reports it `skipped`, or when its own `instruction` says it is conditional: run `openspec instructions <artifact-id> --change "<name>" --json` and skip only if its `instruction` field marks it optional (e.g. "create only if..."). Spec-driven's `design.md` qualifies; `specs` qualifies only via the `skipped` status above, never by your own judgment. Tell the user, and do not reconsider it
- Dependencies are enablers, not gates: if a required artifact is still `blocked` only because you skipped a conditional dependency, write it anyway
- Stop when every artifact in the required set is `done`, `skipped`, or was deliberately skipped
c. **If an artifact requires user input** (unclear context):
- Ask the user to clarify
- Then continue with creation
6. **Show final status**
```bash
openspec status --change "<name>"
```
**Output**
After completing all artifacts, summarize:
- Change name and location
- List of artifacts created with brief descriptions, plus any conditional artifact you skipped and why
- What's ready: "All artifacts needed for implementation are ready."
- Prompt: "The artifacts are ready for review. When you are ready, run `/opsx:apply` or ask me to apply this change."
**Artifact Creation Guidelines**
- Follow the `instruction` field from `openspec instructions` for each artifact type - it is the authoritative guidance, even for familiar artifact names
- If the `instruction` field directs you to use a specific skill or command to create the artifact, invoke it instead of writing the artifact directly
- The schema defines what each artifact should contain - follow it
- Read dependency artifacts for context before creating new ones
- Use `template` as the structure for your output file - fill in its sections
- **IMPORTANT**: `context` and `rules` are constraints for YOU, not content for the file
- Do NOT copy `<context>`, `<rules>`, `<project_context>` blocks into the artifact
- These guide what you write, but should never appear in the output
**Guardrails**
- The request that invoked this workflow authorizes planning only. Any implementation or apply instruction in that request does not carry forward. Do NOT implement the change, start the apply workflow, or edit project code during this workflow. After presenting the artifacts, stop and wait for a new user request to start the apply workflow
- Create every artifact the apply phase transitively depends on, not just the ids listed in `apply.requires`
- Always read dependency artifacts before creating a new one - re-read from disk, not from conversation memory (files may have changed since you last saw them)
- Ask about ambiguities that would materially change scope, externally observable behavior, compatibility, or acceptance criteria; for minor details, make reasonable assumptions and record them
- If a change with that name already exists, ask if user wants to continue it or create a new one
- Verify each artifact file exists after writing before proceeding to next
+262
View File
@@ -0,0 +1,262 @@
---
name: openspec-sync-specs
description: Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.
allowed-tools: Bash(openspec:*)
license: MIT
compatibility: Requires openspec CLI.
metadata:
author: openspec
version: "1.0"
generatedBy: "1.8.0"
---
Sync delta specs from a change to main specs.
This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
`<capability-path>` is the spec directory relative to `specs/` (for example, `user-auth` or `identity/user-auth`). Preserve the full path from each delta spec when resolving its main spec.
**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
**Steps**
1. **Select the change**
If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run `openspec list --json` to get available changes and ask the user to select one
When prompting, show changes that have delta specs (under `specs/` directory).
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:sync <other>`).
2. **Resolve change context**
Run:
```bash
openspec status --change "<name>" --json
```
The JSON includes `planningHome.root`. Main specs live under `<planningHome.root>/openspec/specs/` — use that (store-aware) root for every main-spec path below, not a hardcoded repo path. When a store is selected it points at the store, not the current repository.
3. **Find delta specs**
Use `artifactPaths.specs.existingOutputPaths` from the status JSON as the
only source of delta spec paths. If the `specs` entry is missing or
`existingOutputPaths` is empty, report that there are no delta specs to sync,
do not infer them from other artifacts, and stop without requesting artifact
instructions or writing a main spec.
Sync every path in `existingOutputPaths` unless the caller narrowed the set.
A caller narrows it by naming an explicit list of complete entries from
`existingOutputPaths` — copy those absolute values verbatim. Archive does
this inline, and a user can too (for example, by selecting the entry ending
in `/specs/billing/invoices/spec.md`).
Then sync only the named paths and leave the remaining delta specs untouched:
bulk archive excludes a delta whose implementation it could not find, and
syncing it anyway would write a main spec the caller deliberately withheld.
Carry that narrowed selection through step 4; never widen it back to the full
list. If a named path is not in `existingOutputPaths`, do not sync it —
report it and stop, rather than dropping it silently. If the named list is
empty, report that there is nothing to sync and stop without writing a main
spec.
Each delta spec file contains sections like:
- `## ADDED Requirements` - New requirements to add
- `## MODIFIED Requirements` - Changes to existing requirements
- `## REMOVED Requirements` - Requirements to remove
- `## RENAMED Requirements` - Requirements to rename (FROM:/TO: format)
If no delta specs found, inform user and stop.
4. **For each delta spec, apply changes to main specs**
Before the first main-spec write, obtain one current specs-rule snapshot:
- If archive invoked this workflow inline and supplied a valid snapshot from
`openspec instructions specs --change "<name>" --json`, reuse it and do not
fetch the same instructions again.
- Otherwise run that command once now with the same selected-root flags.
- If the direct lookup exits non-zero or returns invalid artifact-instruction
JSON, report the error and stop before writing any main spec. Do not treat the
failure as an absent rule set.
- A valid response with omitted `rules` means no artifact rules are configured
and the existing semantic merge continues.
Apply returned `rules` only to the content and form of the main specs produced
by this merge. Artifact rules are not operation guidance and cannot change
selected roots, delta paths, CLI checks, or workflow steps. Use their text as
constraints without copying it verbatim into a main spec or summary.
For each capability delta spec path selected in step 3 — the full `existingOutputPaths` list, or the narrowed subset when a caller supplied one (these may belong to a selected store, not the repo):
a. **Read the delta spec** to understand the intended changes
b. **Read the main spec** at `<planningHome.root>/openspec/specs/<capability-path>/spec.md` (may not exist yet)
c. **Apply changes intelligently**:
**ADDED Requirements:**
- If requirement doesn't exist in main spec → add it
- If requirement already exists → update it to match (treat as implicit MODIFIED)
**MODIFIED Requirements:**
- Find the requirement in main spec
- Apply the changes - this can be:
- Adding new scenarios the main spec does not have yet
- Modifying existing scenarios
- Changing the requirement description
- Preserve scenarios/content not mentioned in the delta
**REMOVED Requirements:**
- Remove the entire requirement block from main spec
- Retiring the capability. Delete the whole `spec.md` - and the directory once
nothing else is left in it - only when ALL of these hold:
1. removing the requirements *this run* left no requirement blocks;
2. the rest of the spec is well-formed (it still has a `## Purpose`);
3. the main spec was not already empty before this sync - if you removed
nothing, change nothing;
4. every other nonblank line in the whole file is accounted for as the
title, Purpose, Requirements header, or a canonical requirement's
statement, scenarios, or fenced examples;
5. the change's `.openspec.yaml` declares `retire_capabilities: true`;
6. the `spec.md` resolves inside the real specs root (do not follow a
capability-directory symlink to delete an external file).
If removing the selected requirements would leave no requirement blocks and
any retirement condition is not satisfied, do not modify the main spec. Stop
the sync for that capability, report the blocking condition, and tell the user
how to resolve it. Never write or leave an empty `## Requirements` section.
When only the marker is missing, say that too - it is the one thing the user
can add to make the retirement go through.
- Deleting the file also deletes its `## Purpose`; any other section blocks
retirement. Name Purpose when you report the retirement. Include a pasteable
`git checkout` only when the spec lived in the caller's checkout;
otherwise give checkout-scoped recovery guidance.
**RENAMED Requirements:**
- Find the FROM requirement, rename to TO
**`## Purpose` in the delta:**
- The main spec already has one and it is authoritative - leave it alone
(this is what `openspec archive` does; it warns and moves on)
d. **Create new main spec** if capability doesn't exist yet:
- Create `<planningHome.root>/openspec/specs/<capability-path>/spec.md`
- Add Purpose section: copy the delta's `## Purpose` body verbatim when it has one
(this is what `openspec archive` does); only write a brief TBD placeholder when it does not
- Add Requirements section with the ADDED requirements
- Follow the **Main Spec Format Reference** below
5. **Validate updated main specs**
Run `openspec validate --specs` with the same selected-root flags used earlier.
If validation fails, report the problems and do not claim the sync succeeded.
6. **Show summary**
After applying all changes, summarize:
- Which capabilities were updated
- What changes were made (requirements added/modified/removed/renamed)
- Any new main spec left with a TBD Purpose placeholder, so it gets written
now rather than lingering
- Any capability retired, naming the deleted `spec.md`, its Purpose, and
either a pasteable `git checkout` or checkout-scoped recovery guidance
**Delta Spec Format Reference**
```markdown
## Purpose
Only on a delta that introduces a brand-new capability. Seeds the new main spec.
## ADDED Requirements
### Requirement: New Feature
The system SHALL do something new.
#### Scenario: Basic case
- **WHEN** user does X
- **THEN** system does Y
## MODIFIED Requirements
### Requirement: Existing Feature
The system SHALL keep doing the existing thing, now also handling A.
#### Scenario: Scenario the main spec already has
- **WHEN** user does X
- **THEN** system does Y
#### Scenario: New scenario to add
- **WHEN** user does A
- **THEN** system does B
## REMOVED Requirements
### Requirement: Deprecated Feature
## RENAMED Requirements
- FROM: `### Requirement: Old Name`
- TO: `### Requirement: New Name`
```
**Main Spec Format Reference**
Main specs are what the delta merges INTO. They must never contain delta operation headers (`## ADDED/MODIFIED/REMOVED/RENAMED Requirements`) - after syncing, every requirement lives under a single `## Requirements` section:
```markdown
# <capability> Specification
## Purpose
Short description of what this capability does and why it exists.
## Requirements
### Requirement: New Feature
The system SHALL do something new.
#### Scenario: Basic case
- **WHEN** user does X
- **THEN** system does Y
```
**Key Principle: Intelligent Merging**
Unlike programmatic merging, you merge rather than overwrite:
- A MODIFIED block carries the whole requirement - body plus every scenario that survives the change. `openspec validate` and `openspec archive` both reject one that drops a scenario the main spec still has.
- Keep anything the delta does not mention, in the main spec's existing order
- Use your judgment to merge changes sensibly
**Output On Success**
```markdown
## Specs Synced: <change-name>
Updated main specs:
**<capability-1>**:
- Added requirement: "New Feature"
- Modified requirement: "Existing Feature" (added 1 scenario)
**<capability-2>**:
- Created new spec file
- Added requirement: "Another Feature"
Main specs are now updated. The change remains active - archive when implementation is complete.
```
**Guardrails**
- Read both delta and main specs before making changes
- Preserve existing content not mentioned in delta
- Never copy a delta file into a main spec as-is - merge its content so the main spec keeps the Main Spec Format Reference structure, with no delta operation headers
- If something is unclear, ask for clarification
- Show what you're changing as you go
- The operation should be idempotent - running twice should give same result
- Use only `artifactPaths.specs.existingOutputPaths`; never infer delta specs from unrelated artifacts
- Honor a caller-supplied subset of `existingOutputPaths`; never widen it back to the full list
- Fetch specs instructions once for direct sync, or reuse the archive-supplied snapshot inline
- Stop before every main-spec write on a non-zero or invalid JSON specs-instruction response
- Artifact rules constrain only the specs being written and are never copied into output files
@@ -0,0 +1,91 @@
---
name: openspec-update-change
description: Update an OpenSpec change by revising its existing planning artifacts and keeping them coherent with one another. Use when the user wants to revise a change's plan, fold new decisions into it, or reconcile its artifacts after an edit. Never edits code.
allowed-tools: Bash(openspec:*)
license: MIT
compatibility: Requires openspec CLI.
metadata:
author: openspec
version: "1.0"
generatedBy: "1.8.0"
---
Revise a change's existing planning artifacts and keep them coherent. Never edit code.
**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store <id>` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`, `view`). Once selected, treat `--store <id>` as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run `openspec status --change "<name>" --json --store "<id>"`, not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root.
**Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
`/opsx:continue` is an expanded-profile workflow and may not be installed. Before suggesting it anywhere below, verify that it is available. If it is unavailable, `openspec status --change "<name>" --json` shows the next artifact and `openspec instructions "<artifact-id>" --change "<name>" --json` explains how to create it.
**Steps**
1. **Select the change**
If a name is provided, use it. Otherwise:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run `openspec list --json` to get available changes sorted by most recently modified, and ask the user to select one
When prompting, present the top 3-4 most recently modified changes as options, showing:
- Change name
- Schema (from `schema` field if present, otherwise "spec-driven")
- Status (e.g., "0/5 tasks", "complete", "no tasks")
- How recently it was modified (from `lastModified` field)
Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to update.
Always announce: "Using change: <name>" and how to override (e.g., `/opsx:update <other>`).
2. **Get the change's artifacts**
```bash
openspec status --change "<name>" --json
```
Parse the JSON to understand current state. The response includes:
- `schemaName`: The workflow schema being used (e.g., "spec-driven")
- `artifacts`: Array of artifacts with their status ("done", "skipped", "ready", "blocked")
- `isPlanningComplete`: Boolean indicating if all planning artifacts are complete. Older CLI versions expose the same value as `isComplete`.
- `planningHome`, `changeRoot`, `artifactPaths`, and `actionContext`: path and scope context. Use these instead of assuming repo-local paths.
The artifact ids and paths come from the active schema - do NOT assume them, and do NOT branch on hardcoded artifact names. Custom schemas must work unchanged.
The files to edit are `artifactPaths.<id>.existingOutputPaths` - the concrete files that exist on disk, already glob-expanded for glob artifacts (e.g. `specs/**/*.md`). Do NOT write to `resolvedOutputPath`: for a glob artifact it is still the glob pattern, not a real file.
3. **Understand the request**
- If the user asked for a specific revision ("the design now uses X"), that is the starting edit.
- If they only said "update" / "make this coherent", treat it as a coherence review: read the existing artifacts and check them against each other for contradictions, gaps, and duplication.
4. **Read and reconcile**
- Read the artifact(s) the request touches and the change's other existing artifacts.
- Apply the requested edit. Then check every other existing artifact against it - in ANY direction: an edit to a later artifact may require revising an earlier one, not only the other way around. Build order is a useful reading order, not a constraint on which artifacts may be revised.
- Note everything that is now inconsistent, missing, or contradictory.
- Revise only files that already exist (`existingOutputPaths`). Do NOT create artifacts that don't exist yet, and do NOT invent new files under a glob artifact - note them and point the user to `/opsx:continue` to create them.
- If the change is already coherent, say so and make no edits.
5. **Confirm and apply, one artifact at a time**
- Show each proposed revision and why. Write only after the user confirms.
- If the user rejects a revision, do not write it - leave that artifact unchanged.
- When a substantial rewrite is needed, get that artifact's rules and template first:
```bash
openspec instructions "<artifact-id>" --change "<name>" --json
```
6. **Point to the next step (guidance only - NEVER act on it)**
- Artifacts still missing -> suggest `/opsx:continue` to create them.
- Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan; suggest `/opsx:apply` to carry the delta into code.
- Everything done and implemented -> suggest `/opsx:archive`.
**Output**
After each invocation, show:
- Which artifacts were revised (and which proposed revisions were rejected)
- Anything deferred to `/opsx:continue` (not-yet-created artifacts or files)
- Where the change stands and the recommended next command
**Guardrails**
- Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes, stop and point to `/opsx:apply`.
- Use the artifact ids and paths reported by `openspec status`; never branch on hardcoded artifact names.
- Edit only the concrete files in `existingOutputPaths`; never write to a glob `resolvedOutputPath`.
- Do not advance the build frontier: no new artifacts, no new files under glob artifacts - that is `/opsx:continue`'s job.
- Confirm every edit with the user before writing.
- If the request changes the change's *intent* rather than refining it, first verify whether the expanded-profile `/opsx:new` workflow is available. If it is, recommend starting fresh with `/opsx:new` (the "Update vs. Start Fresh" heuristic). If it is unavailable, ask for a distinct unused change name and recommend `openspec new change "<new-change-name>"` instead.
+26
View File
@@ -14,7 +14,33 @@ backups
*.pfx
*.jks
.venv
venv
__pycache__
*.pyc
*.pyo
.pytest_cache
.ruff_cache
.mypy_cache
.ty_cache
node_modules
evidence
openspec
student-tests
tests
scripts
examples
contracts
infra
*.md
!README.md
Makefile
Dockerfile*
compose*.yaml
.dockerignore
.gitignore
.DS_Store
lab.json
requirements-dev.txt
.claude
.verification/
+75
View File
@@ -9,3 +9,78 @@ DATABASE_URL_FILE=/run/secrets/database_url
# Optional on 3, required use on 4 in lab2; Redis OR Valkey:
SESSION_STORE=postgres
CACHE_URL_FILE=/run/secrets/cache_url
API_REPLICAS=2
IDEMPOTENCY_TTL_SECONDS=86400
S3_ENDPOINT=http://s3:9000
S3_REGION=us-east-1
S3_BUCKET=messenger-attachments
S3_ACCESS_KEY_ID_FILE=/run/secrets/s3_access_key_id
S3_SECRET_ACCESS_KEY_FILE=/run/secrets/s3_secret_access_key
MAX_UPLOAD_BYTES=10485760
MAX_IMAGE_PIXELS=40000000
BROKER_URL_FILE=/run/secrets/broker_url
WORKER_CONCURRENCY=2
JOB_MAX_ATTEMPTS=5
JOB_TIMEOUT_SECONDS=60
STAGING_RETENTION_SECONDS=86400
# Solution-specific: published LB ports, replica limits, workers and pool per replica,
# LB queue per replica, drain window before closing the listener on SIGTERM, PostgreSQL
# limits, load generator limits (profile bench), cursor key file. API_PORT/SHORTTTL_PORT of lab2 are gone:
# only the load balancer is published.
LB_HTTP_PORT=18085
LB_STATS_PORT=25085
API_CPUS=1
API_MEMORY=512m
WEB_CONCURRENCY=2
DB_POOL_MAX_SIZE=8
API_SERVER_MAXCONN=64
DRAIN_SECONDS=2
PG_MAX_CONNECTIONS=200
PG_CPUS=2
PG_MEMORY=1g
K6_CPUS=2
K6_MEMORY=512m
CURSOR_SECRET_FILE=/run/secrets/cursor_secret
# Solution-specific for lab4: S3 client timeouts (connect + read, two attempts stay below
# REQUEST_TIMEOUT_SECONDS=8), parallel image checks per worker, RustFS memory limit.
S3_CONNECT_TIMEOUT_SECONDS=1
S3_READ_TIMEOUT_SECONDS=2
IMAGE_CHECK_CONCURRENCY=2
S3_MEMORY=512m
# Solution-specific for lab4 grade 4: upload bodies buffered at once per worker, grace period
# before an abandoned pending upload is swept, sweep interval and rows per sweep pass.
UPLOAD_CONCURRENCY=3
UPLOAD_GRACE_SECONDS=900
UPLOAD_SWEEP_INTERVAL_SECONDS=30
UPLOAD_SWEEP_BATCH=100
# Fixed glibc mmap threshold for the API: buffers above 128 KiB are returned to the system on free.
MALLOC_MMAP_THRESHOLD_=131072
# Solution-specific for lab5: RabbitMQ management UI on 127.0.0.1, backoff base of a transient
# retry (doubles per attempt up to 60 s), relay poll and sweep intervals, worker limits and the
# PostgreSQL pool of relay and worker. FAULT_POINT is set only by infra/compose.faults.yaml.
BROKER_MANAGEMENT_PORT=25086
JOB_BACKOFF_BASE_SECONDS=2
OUTBOX_POLL_SECONDS=1
SWEEP_INTERVAL_SECONDS=5
WORKER_CPUS=2
WORKER_MEMORY=1g
PIPELINE_DB_POOL_MAX_SIZE=4
# Solution-specific for lab5 grade 4: render time per job (the render process is killed after it),
# address space of one render process (WORKER_MEMORY >= WORKER_CONCURRENCY * RENDER_MEMORY_MB plus
# ~120 MiB of the worker itself), jobs per render process before it is replaced.
RENDER_TIMEOUT_SECONDS=30
RENDER_MEMORY_MB=448
RENDER_TASKS_PER_CHILD=100
# Minimal client transfer rate, bytes/s: every body byte moved in either direction extends the
# request deadline by 1/rate, so slow but steady uploads and downloads outlive REQUEST_TIMEOUT_SECONDS.
MIN_TRANSFER_RATE_BYTES=131072
# Solution-specific for lab4 track 2: limits of the one-off reconciler (profile reconcile), its S3
# read timeout for listing pages, optional CPU pinning of the measured services (empty = no pinning)
# and the CPU limit of RustFS (make reconcile-cost raises it with its memory for the 100k point).
RECONCILE_CPUS=1
RECONCILE_MEMORY=256m
RECONCILE_S3_READ_TIMEOUT_SECONDS=10
RECONCILE_CPUSET=
S3_CPUSET=
PG_CPUSET=
S3_CPUS=1
+1 -1
View File
@@ -1,4 +1,4 @@
## Лабораторная 2
## Лабораторная 5
Автор / группа: TODO
Целевая оценка (3/4/5): TODO
+122
View File
@@ -0,0 +1,122 @@
name: Application
on: [push, pull_request]
permissions:
contents: read
jobs:
quality:
name: Линт, типы и собственные тесты
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- run: uv sync --locked --group dev
- run: make lint VENV=.venv
- run: make student-test VENV=.venv
acceptance:
name: Стенд Compose с RabbitMQ, relay и worker за HAProxy, smoke, pipeline, отказ реплики, рестарт и отказы зависимостей
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- run: uv sync --locked --group dev
- name: Поднять стенд из чистого clone
run: make up
- name: Публичный smoke через балансировщик
run: make test
- name: Топология брокера, consumer с prefetch и права клиентов
run: make topology
- name: Уровни «3» и «4» pipeline — worker остановлен, рестарт брокера, дубль, S3, попытки, варианты и пределы, падения в окнах 2–5, аренда, replay, DLQ, jitter, retention
run: |
make suite-preflight
make level4
- name: Сообщение задания в очереди, 409 до ready и SIGTERM relay и worker
run: make pipeline-evidence
- name: Вложение после остановки принявшей его реплики и при недоступном S3
run: |
make scenario SCENARIO=failover-upload
make scenario SCENARIO=s3-outage
- name: Приватный bucket, ограниченный ключ API и повторный bootstrap
run: make s3-check
- name: Негативный suite вложений, компенсация, уборка после grace, обрыв и зависание загрузки
run: make upload-faults
- name: Несколько реплик на одном токене и гонка одного ключа
run: make lb-check
- name: Повтор неподтверждённой записи после потерянного ответа и убитой реплики
run: make retry-check
- name: Остановка реплики под запросами, затем возврат
run: |
make test-failover ACTION_SCRIPT=scripts/stop-one.sh
docker compose ps -a api
make restore
- name: Рестарт LB, API и хранилищ с сохранением volumes
run: make test-persistence ACTION_SCRIPT=scripts/restart.sh
- name: Отказы Valkey и PostgreSQL, гонка и rollback
run: make test-faults
- name: Лимиты, порты, секреты, volumes и сети по политике
run: make limits
- name: Время обнаружения отказа балансировщиком (SIGTERM, kill, pause, PostgreSQL)
run: make detection
- name: Наружу опубликован только балансировщик
run: |
docker compose ps --format '{{.Service}} {{.Ports}}' | awk '$2 != "" && $1 != "lb" && $1 != "broker" {print; bad=1} END {exit bad}'
docker compose ps --format '{{.Service}} {{.Ports}}' | awk '$1 == "broker" && $2 !~ /^127\.0\.0\.1:/ {print; bad=1} END {exit bad}'
- name: Процессы работают не от root
run: |
for id in $(docker compose ps -q); do
docker top "$id" -eo pid,uid,comm | awk 'NR>1 && $2==0 {print; bad=1} END {exit bad}' || exit 1
done
- name: Одноразовые сервисы не от root
run: |
for service in migrate s3-init; do
user=$(docker inspect -f '{{.Config.User}}' "$(docker compose ps -aq "$service")")
echo "$service: $user"
case "${user%%:*}" in ""|0|root) exit 1 ;; esac
done
- name: Корректная остановка relay и worker по SIGTERM
run: |
start=$(date +%s)
docker compose stop -t 10 relay worker
elapsed=$(( $(date +%s) - start ))
codes=$(docker inspect -f '{{.State.ExitCode}}' $(docker compose ps -aq relay worker) | sort -u)
echo "остановка за ${elapsed} с, коды завершения ${codes}"
test "$elapsed" -le 10 && test "$codes" = "0"
- name: Корректная остановка реплик API по SIGTERM
run: |
start=$(date +%s)
docker compose kill --signal SIGTERM api
codes=$(docker wait $(docker compose ps -aq api) | sort -u)
elapsed=$(( $(date +%s) - start ))
echo "остановка за ${elapsed} с, коды завершения ${codes}"
test "$elapsed" -le 10 && test "$codes" = "0"
- name: Журналы стенда
if: always()
run: docker compose logs --tail 80
+10
View File
@@ -30,3 +30,13 @@ coverage/
.vscode/
# Keep small, sanitized evidence summaries in evidence/ under version control.
# Inspect git diff --cached: ignore rules are not a secret scanner.
# Тулчейн студенческой реализации
.pytest_cache/
.ruff_cache/
.ty_cache/
# Локальные настройки агента
.claude/settings.local.json
.verification/
+90
View File
@@ -0,0 +1,90 @@
## Что это за репозиторий
Skeleton лабораторной 5 курса «Мессенджер под нагрузкой» (МТУСИ, 7 независимых лаб) и решение в ветке `solution/bpi2303-kostylev`. Skeleton даёт задание (`README.md`), нормативный контракт (`contracts/`) и публичные black-box проверки (`tests/`). Реализация API, worker, relay, Dockerfile, compose-стенд, конфигурация балансировщика, S3 и брокера, миграции, хуки отказов и собственные тесты — студенческие; решение лабы 5 построено переносом решения лабы 4.
Лаба 5: приём вложения отделён от тяжёлой обработки. `POST /api/v1/chats/{chat_id}/attachments` проверяет файл как в лабе 4, кладёт оригинал в приватный префикс `staging/` bucket **RustFS** и одной транзакцией PostgreSQL фиксирует вложение `queued`, задание (`jobs`) и строку **transactional outbox**; только после этого отвечает `202` со снимком `queued`. Отдельный сервис `relay` публикует outbox в **RabbitMQ 4.1** (quorum queue, DLX, publisher confirms, `mandatory`, persistent), отдельный сервис `worker` (тот же образ, свой entrypoint) потребляет очередь через **FastStream** поверх aio-pika с ручным `ack` строго после `COMMIT` результата, захватывает задание арендой (`lease_token`), публикует оригинал в `originals/` и строит варианты Pillow. Источник истины состояний — PostgreSQL, брокер — транспорт и будильник. Остаётся всё из лаб 1–4: HAProxy перед ≥2 репликами, `X-Instance-Id`, `Idempotency-Key`, Basic → Bearer, хуки остановки реплики и рестарта стенда.
Текущий доступ к PostgreSQL — **SQLAlchemy 2.0.45 async**, `postgresql+asyncpg`, `async_sessionmaker`, ORM/Core и `DeclarativeBase`; миграции — **Alembic 1.16.5**, каталог `alembic/versions/`, async `alembic/env.py`. Compose-service `migrate` выполняет `alembic upgrade head` под advisory lock с проверкой legacy-схемы. Сырой asyncpg и прежние SQL-миграции не являются текущей архитектурой.
## Команды
```sh
make check # offline: структура skeleton, JSON, локальные $ref, синтаксис Python, версия 1.5.0
make validate PYTHON=.venv/bin/python # полная валидация OpenAPI 3.1 и jobs.schema.json (venv с requirements-dev.txt)
make install # uv sync --group dev
make lint # ruff check + ruff format --check + ty check; обязательно перед commit
make student-test # собственные тесты (одноразовые PostgreSQL, Valkey, RustFS и RabbitMQ в Docker)
make secrets # локальные secrets/* (PostgreSQL, Valkey, S3 root/API/worker, RabbitMQ) и .env
make up # docker compose build, затем up -d --wait (relay и worker пересоздаются на новом образе): хранилища и broker → migrate, s3-init → api ×2, relay, worker → lb
make test # публичный smoke через LB (BASE_URL=http://127.0.0.1:18085)
make test-persistence ACTION_SCRIPT=scripts/restart.sh # рестарт lb, api, relay, worker и postgres, valkey, s3, broker с volumes
make test-failover ACTION_SCRIPT=scripts/stop-one.sh # остановка реплики TARGET_INSTANCE_ID под запросами
make restore # вернуть остановленные реплики и дождаться их в ротации LB
make worker-stop / worker-start # демонстрация «worker недоступен»
make queues # очереди брокера: ready, unacked, consumers
make level3 # сценарии уровня «3» suite (scripts/pipeline_suite.py) → evidence/level3.json
make level4 # сценарии уровней «3» и «4» suite и инварианты → evidence/level4.json
make track2 TRACK2_OUTPUT=evidence/local-track2.json # 13 сценариев и 8 инвариантов трека 2
make reprocess ID=… PIPELINE_VERSION=2 # новая версия обработки доступного исходника
make failed / make replay ID=… / make dlq # реестр failed, явный replay, просмотр DLQ (python -m messenger.admin, rabbitmqadmin)
make down # остановка своего project без удаления постоянных volumes
```
`tests/*.py` и `scripts/*.py` — только stdlib, синтаксис Python 3.9 (`make check` разбирает их системным `python3`). Проверки сами не поднимают стенд. Хуки `scripts/stop-one.sh` и `scripts/restart.sh` запускаются тестом без shell, поэтому исполняемые и с shebang. Данные не удаляются автоматически: каждый прогон smoke создаёт новых синтетических пользователей и вложения.
## Архитектура skeleton
- `lab.json` — единственный источник номера лабы (5). От него зависят `scripts/check_contract.py` (`info.version == 1.5.0`) и `tests/client.py` (ветки `LAB>=5`: upload отвечает `202 queued`, сообщение с вложением сразу, ожидание `ready` до 60 с от второго участника, ровно один вариант `thumbnail` 256×160 настоящим JPEG).
- `tests/` байт в байт как в лабе 4; поведение переключает только `lab.json`. `tests/resilience.py` после хука рестарта запрашивает метаданные и оригинал один раз с таймаутом 2 с.
- `contracts/jobs.schema.json` — формат сообщения брокера (7 обязательных полей, без bytes, URL, ключей S3 и filename); `contracts/attachment-states.md` — машина состояний и окна отказа.
- `contracts/infrastructure.json` — роли `api`, `postgres`, `load_balancer`, `s3`, `broker` (persistent volume, at-least-once), `worker` (отдельный процесс). `compose.example.yaml` — только worksheet ролей.
## Ключевые правила контракта (lab5)
- Upload: те же лимиты и коды, что в лабе 4 (`413`, `415`, `400`, `404`), но успех — `202 Attachment` со снимком `status=queued`, `variants=[]`, `error_code=null`; снимок берётся из записанного объекта, а не перечитывается после публикации. `202` — только после записи оригинала в `staging/` и `COMMIT` вложения, задания и outbox.
- Состояния: `queued → processing → ready | failed`; `processing → queued` при временной ошибке или истёкшей аренде; `failed → queued` только явным replay. `ready` не откатывается. `ready` выставляется, только когда записаны оригинал и все обещанные уровнем варианты.
- `/content` для `queued`, `processing`, `failed` — `409 conflict` для любого `variant`, включая `original`; неизвестный `variant` — `400`; отсутствующий вариант `ready`-вложения — `404`; посторонний — `404`. Варианты: `thumbnail` JPEG вписан в 256×256 без увеличения, EXIF orientation применяется, alpha на белом, размеры вниз, минимум 1 px.
- Сообщение: вложение `queued`/`processing` прикрепляется (`201`), `failed` — `409`, вложение другого чата или неизвестное — `404`.
- Сообщение брокера — ровно поля `jobs.schema.json`; `job_id` не меняется при redelivery, `attempt` растёт только при управляемом повторе через outbox. Ключ эффекта — `(attachment_id, pipeline_version, variant)`.
- Сохраняются правила lab4 (сырые байты, тип по содержимому, скачивание только через API без redirect), lab3 (`X-Instance-Id`, `Idempotency-Key`, LB не повторяет upload), lab2 (`Basic` только на входе, `Bearer` дальше, `WWW-Authenticate` по пути) и lab1 (формат ошибки, посторонний → `404`, keyset `(created_at, id)`, время RFC 3339 с `Z`).
## Правила работы с репозиторием
- Не менять и не ослаблять `contracts/`, `tests/`, `README.md`, `COURSE.md`, рубрику. Расхождение оформляется вопросом преподавателю.
- Код — `src/messenger/`, миграции — `alembic/versions/`, конфигурация LB, нагрузки, S3 и брокера — `infra/`, хуки и обвязка стенда — `scripts/`, собственные тесты — `student-tests/`, обезличенные доказательства — `evidence/`.
- Без комментариев в коде; отступы — пробелы (`[tool.ruff.format]`); Python 3.14 без `from __future__ import annotations` и `TYPE_CHECKING`.
- Порты реплик API, S3, AMQP наружу не публикуются: только LB и UI брокера на `127.0.0.1`. API к брокеру не подключается. Клиенты брокера не объявляют очереди: топология — в `infra/rabbitmq/definitions.json`, права configure есть только у оператора.
- `REPORT.md`: команды из чистого clone, архитектура, таблица «критерий → команда → наблюдение → файл», таблица отказов. PASS без команды не доказательство; для отказов — какой контейнер реально остановлен (`docker ps -a`).
- Ветка `solution/bpi2303-kostylev`, коммиты на английском, перед каждым — `make lint`. Никогда не коммитить `.env`, `secrets/`, токены, ключи S3, пароли брокера, volumes, дампы.
- Проверять документацию используемых библиотек через Context7. Изменения реализации проходят OpenSpec propose/apply/archive. `openspec/config.yaml` уже описывает SQLAlchemy/Alembic и ЛР5; оставшееся в design правило `201` относится к прежней загрузке ЛР4, нормативный успех ЛР5 — `202`.
- Автор работы — Костылев Артём, БПИ2303. Не приписывать авторство Claude. Публикация только в private MTUCI-Labs и только назначенным агентом фазы PUBLICATION; вне неё не делать push и не отправлять Telegram.
## Порядок этапов и Docker
- Только runner управляет агентами: один переносит основу и последовательно реализует 3 → 4 → 5 с evidence, затем отдельные review → fix только major → re-review, отчёт, один агент нагрузки и публикации. Review/отчёт предыдущей лабы могут идти параллельно реализации следующей. Самостоятельно фоновых агентов не запускать, runner/state не менять.
- Major — доказанная угроза безопасности, потеря/повреждение данных, недоступность сервиса или провал обязательного сценария. Остальное — minor: сохранять в findings и ограничениях REPORT, не исправлять без назначения и не блокировать этапы. Обязательный FAIL нельзя объявлять PASS.
- Менять только назначенную лабу; другую читать лишь через предоставленный snapshot. Перед итоговым review переносить применимые поздние исправления. Сохранять WIP; `reset/clean` и удаление пользовательских данных запрещены.
- Разрешены основной project `mtusi2026lab5` в основном репозитории или `hlpipe-lab5-*` с working_dir под ним либо `/Users/artemkostylev/projects/learning/HL/labs/.pipeline/.runs/labs`. API — 18085, остальные порты — 25000–25999; текущие значения stats/UI — 25085/25086. Учитывать Compose env, не печатать секреты.
- Обычные Docker-этапы работают совместно на отдельных project/портах/volumes; финальная нагрузка получает эксклюзивный доступ через runner. Останавливать только свой стенд, в конце — без `-v`. Фон и условия замеров фиксировать; пригодные серии сохранять, повторять только отсутствующие, затронутые или непригодные.
- Отчётная фаза меняет только `REPORT.md`, `AGENTS.md`, `evidence/**/*.md`; не меняет код, конфиги, OpenSpec и сырые измерения. Docker, динамические/нагрузочные прогоны и полный `make student-test` в этой фазе запрещены; лёгкие check/validate/lint и OpenSpec validation допустимы.
## Состояние доказательств после ревью
Индекс — [evidence/README.md](evidence/README.md), отчёт — [REPORT.md](REPORT.md). Текущий код после исправления памяти и независимого re-review — `6096aa7948b8b666aa3892397a96d044a55f02c6` (M). Последняя полная динамическая квалификация — `0e921116610d289716af0a40ec823376eb8bbcbc` (D); предыдущее review — `42575281b352d35bda17ee7601bae5548a996e91` (R). От D к R менялись renderer PNG и policy RabbitMQ; от R к M из runtime изменён только renderer. Старые PASS не обозначать прогоном M.
Validation на `b30e2f6a84419d1ca64525ffb40df92183cccaef` (V, runtime = R) завершила реальный PostgreSQL outage: 12 requeue → ready без replay, policy `delivery-limit=-1` на сохранённом volume, DLQ не выросла. HTTP PNG: 8 fixtures / 48 сравнений вариантов v1/v2 PASS. Delivery subset: 12 сценариев / 8 инвариантов PASS. Student-test: 980 passed / 1 Linux-only skip. Исторический аудит — [evidence/load-validation.md](evidence/load-validation.md), результаты V — [evidence/final-validation-2026-11-07/RESULTS.md](evidence/final-validation-2026-11-07/RESULTS.md).
**Прежний major закрыт динамически на F `74c33160ac01618f70e9e1c6a121a5e45c3c7155` (runtime = M).** Четыре исходных PNG 8000×5000 и grayscale16 без tRNS прошли Linux с импортами worker при 448 MiB/30 с и HTTP 202 → ready в v1/v2. Два одновременных HTTP jobs: peak 844.41 MiB / 1 GiB, OOM=0. Boundary: 8 сценариев / 8 инвариантов, 11 ID / 59 объектов; малая HTTP-матрица: 8 fixtures / 48 сравнений / 8 инвариантов, 8 ID / 56 объектов. Принудительные лимиты, обычное задание после каждого отказа и cleanup после sweep — PASS. Student-test: 984 passed / 2 Linux-only skipped / 19 deselected; Linux-эквивалент выполнен отдельно. Исходные FAIL V сохранены, лимиты не увеличивались.
Актуальные команды и сырьё — [evidence/final-memory-validation-2026-11-07/RESULTS.md](evidence/final-memory-validation-2026-11-07/RESULTS.md), аудит применимости — [evidence/load-validation.md](evidence/load-validation.md). Полные track2, PostgreSQL outage и delivery subset приняты без повторения: соответствующий runtime не менялся. Стенд F остановлен, четыре volumes сохранены. Validation завершена; push/Telegram не выполнялись, публикация требует отдельного сообщения координатора с точным SHA. Документационные коммиты после F не меняют измеренный runtime.
Семь minor последнего review сохраняются в REPORT: crash_publish_confirm фактически после confirm до COMMIT outbox; limits.py имеет ложный FAIL порядка secrets; reconcile_track.py ожидает upload 201 ЛР4; failed upgrade v2 нельзя отдельно повторить при ready v1; UTC/elapsed run2/3 расходятся; design-правило config сохранило 201; JobMessage допускает преобразования типов и null вне jobs.schema.json. Последний minor воспроизведён reviewer в четырёх offline-пробах (bus/ack вместо reject); штатный relay формирует корректные сообщения, критичного последствия не установлено. Происхождение — [аудит обновления отчёта](evidence/report-memory-audit-2026-11-07.md). Корневые старые evidence до SQLAlchemy остаются историей.
## Уровни оценки
Цель — **«5»**, трек 2 «Доказанная идемпотентность pipeline». Критерии подтверждены совокупностью сохранённых серий D/V и адресной validation F; прежний major закрыт, семь minor сохранены. Таблица доказательств и границы применимости — в `REPORT.md`.
- **3** — `202 queued` после staging и `COMMIT` задания с outbox; отдельные `broker`, `relay`, `worker` в стенде; durable quorum queue, publisher confirm, ручной `ack` после `COMMIT`; состояния `queued/processing/ready/failed`, оригинал в `originals/` и thumbnail; ограниченный retry (`JOB_MAX_ATTEMPTS=5`) и `failed` с `error_code`; повтор job без второго набора вариантов; worker остановлен → upload → сообщение → рестарт API и broker → worker → `ready`; минимум lab4 сохранён.
- **4** — crop и optimized WebP, лимиты worker по байтам, пикселям, времени и памяти, crash между `COMMIT` и publish, backoff с jitter и классификация ошибок, DLQ и replay, crash после записи объекта до `ack`, lease и fencing для зависшего `processing`, prefetch, очистка staging.
- **5** — трек 2: `pipeline_version` 1 и 2, монотонная публикация, автоматический fault-injection (дубль, reorder, crash до и после side effect, устаревшая job) и проверка инвариантов одной командой.
+51
View File
@@ -0,0 +1,51 @@
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS builder
COPY --from=ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 /uv /usr/local/bin/uv
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=never \
UV_PROJECT_ENVIRONMENT=/opt/venv
WORKDIR /build
COPY pyproject.toml uv.lock README.md ./
RUN uv sync --locked --no-dev --no-install-project --no-editable
COPY src ./src
RUN uv sync --locked --no-dev --no-editable
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS runtime
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PATH="/opt/venv/bin:$PATH" \
HOST=0.0.0.0 \
PORT=8080 \
LOG_LEVEL=INFO \
WEB_CONCURRENCY=2 \
REQUEST_TIMEOUT_SECONDS=8 \
DRAIN_SECONDS=2 \
SHUTDOWN_TIMEOUT_SECONDS=6
RUN groupadd --system --gid 10001 messenger \
&& useradd --system --uid 10001 --gid messenger --no-create-home --shell /usr/sbin/nologin messenger
COPY --from=builder --chown=root:root /opt/venv /opt/venv
WORKDIR /app
COPY --chown=root:root alembic.ini ./
COPY --chown=root:root alembic ./alembic
USER 10001:10001
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
CMD ["python", "-c", "import urllib.request,sys;sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8080/health/live',timeout=2).status==200 else 1)"]
CMD ["python", "-m", "gunicorn", \
"--config", "python:messenger.gunicorn_conf", \
"messenger.main:create_app()"]
+1 -1
View File
@@ -1,4 +1,4 @@
# Памятка преподавателю — лабораторная 2
# Памятка преподавателю — лабораторная 5
## Что подготовлено
+263 -2
View File
@@ -1,17 +1,66 @@
PYTHON ?= python3
BASE_URL ?= http://localhost:8080
BASE_URL ?= http://$(shell docker compose port lb 8080 2>/dev/null || echo localhost:8080)
CA_FILE ?=
ACTION_SCRIPT ?=
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
.PHONY: help check validate test load test-persistence
VENV ?= .venv
UV ?= uv
COMPOSE ?= docker compose
RATE ?= 100
FROM_REV ?=
SHIFT ?= 0
SCRIPTS_PY = scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py \
scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py \
scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
SCENARIO ?= failover-upload
PSQL = $(COMPOSE) exec -T postgres psql -U messenger -d messenger -X -q
TRACK2_OUTPUT ?= evidence/track2.json
TRACK2_SCENARIOS = smoke_pipeline,duplicate_after_ready,crash_commit_publish,crash_publish_confirm,crash_after_s3_before_commit,crash_after_commit_before_ack,lease_expiry_fencing,crash_before_side_effect,worker_kill_mid_task,duplicate_in_flight,reorder_attempts,reorder_versions,stale_after_new_version
PIPELINE_VERSION ?= 2
PYTEST_ARGS ?=
.PHONY: help check validate test load test-persistence test-failover \
install lint format typecheck student-test \
secrets up down reset-data migrate ps logs restore lb-check failover-evidence stack-evidence \
persistence-evidence storage-evidence cache-evidence test-faults seed explain \
limits detection failover-each rolling-update lab4-level4 \
scenario s3-check attachments-evidence upload-faults upload-memory \
images queues topology worker-stop worker-start broker-restart suite-preflight level3 \
pipeline-evidence level4 replay failed dlq \
faults-evidence retry-check reconcile reconcile-demo reconcile-cost load-evidence \
clean-clone-evidence overload-leftovers
.NOTPARALLEL:
help:
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
@echo "install/lint/typecheck/student-test: студенческий тулчейн"
@echo "secrets/up/down/migrate/ps/logs: стенд Docker Compose; reset-data: намеренное удаление volumes"
@echo "restore: вернуть остановленные реплики; lb-check: реплики на одном токене и 20 гонок одного ключа"
@echo "lab4-level4 = limits, lb-check, detection, failover-each, rolling-update [FROM_REV=<коммит>]; RATE=$(RATE) rps"
@echo "scenario SCENARIO=failover-upload|s3-outage → evidence/<сценарий>.json; s3-check; attachments-evidence"
@echo "upload-faults: негативный suite, компенсация, уборка, обрыв и зависание загрузки против стенда"
@echo "upload-memory: пик памяти реплик при 10/20/40 одновременных загрузках 1 и 10 MiB → evidence/upload-memory/"
@echo "lab5: queues, topology, worker-stop/worker-start, broker-restart, images, suite-preflight, level3, level4"
@echo "lab5 оператор: failed (реестр), replay ID=<attachment_id>, dlq (просмотр DLQ без извлечения)"
@echo "retry-check: потерянный ответ на живой и на убитой реплике, повтор тем же ключом"
@echo "lab4-level4 = limits, lb-check, detection, failover-each, rolling-update [FROM_REV=<коммит>]; RATE=$(RATE) rps"
@echo "scenario SCENARIO=failover-upload|s3-outage → evidence/<сценарий>.json; s3-check; attachments-evidence"
@echo "upload-faults: негативный suite, компенсация, уборка, обрыв и зависание загрузки против стенда"
@echo "upload-memory ARGS='--out evidence/upload-memory/runN': пик памяти реплик при 10/20/40 загрузках 1 и 10 MiB"
@echo "load-evidence: tests/load.py ×3 клиентом-контейнером в сети edge стенда → evidence/load.txt, evidence/load/"
@echo "overload-leftovers: после upload-memory — намерения от 503, сверка и уборка после grace → evidence/overload-leftovers.txt"
@echo "clean-clone-evidence: блок «Запуск из чистого clone» в свежем клоне рядом → evidence/clean-clone.txt"
@echo "reconcile ARGS='--apply --deep': сверка PostgreSQL ↔ S3 (без ARGS — dry-run); трек 2:"
@echo "reconcile-demo: внедрение ошибок, dry-run/apply/повтор, безопасность, нагрузка → evidence/reconcile/"
@echo "reconcile-cost: стоимость обхода 1k/10k/30k/100k объектов × 3 прогона на чистом стенде → evidence/reconcile/cost/"
@echo "BASE_URL=$(BASE_URL) (порт lb из docker compose); failover-evidence SHIFT=1 — сдвиг round robin на вторую реплику"
check:
$(PYTHON) scripts/check_contract.py
validate: PYTHON := $(if $(wildcard $(VENV)/bin/python),$(VENV)/bin/python,$(PYTHON))
validate:
$(PYTHON) scripts/validate_openapi.py
@@ -24,3 +73,215 @@ load:
test-persistence:
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable restart hook"; exit 2)
$(PYTHON) tests/resilience.py --mode persistence --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
test-failover:
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable stop-one hook"; exit 2)
$(PYTHON) tests/resilience.py --mode failover --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
install:
$(UV) sync --group dev
lint:
$(VENV)/bin/ruff check src student-tests $(SCRIPTS_PY)
$(VENV)/bin/ruff format --check src student-tests $(SCRIPTS_PY)
$(VENV)/bin/ty check src student-tests alembic
format:
$(VENV)/bin/ruff check --fix src student-tests $(SCRIPTS_PY)
$(VENV)/bin/ruff format src student-tests $(SCRIPTS_PY)
typecheck:
$(VENV)/bin/ty check src student-tests alembic
student-test:
$(VENV)/bin/pytest $(PYTEST_ARGS)
secrets:
sh scripts/secrets.sh
sh scripts/broker-secrets.sh
up: secrets
$(COMPOSE) build
$(COMPOSE) up -d --wait
scripts/lb-wait.sh
down:
$(COMPOSE) --profile bench --profile tools --profile reconcile down
reset-data:
@echo "Удаляются volumes с учебными данными стенда"
$(COMPOSE) --profile bench --profile tools --profile reconcile down -v --remove-orphans
migrate:
$(COMPOSE) run --rm migrate
ps:
$(COMPOSE) ps
logs:
$(COMPOSE) logs --tail 200
restore:
scripts/restore.sh
lb-check:
$(PYTHON) scripts/probe.py check --rounds 20 --out evidence/lb-check.json
retry-check:
$(PYTHON) scripts/probe.py retry --out evidence/retry.json
limits:
$(PYTHON) scripts/limits.py --out evidence/limits.txt
detection:
rm -rf evidence/detection
for run in 1 2 3; do sh scripts/detection.sh evidence/detection/run$$run || exit 1; done
failover-each:
RATE=$(RATE) sh scripts/failover-each.sh evidence/failover-each
rolling-update:
ifneq ($(FROM_REV),)
git archive "$(FROM_REV)" | docker build -q -t "mtusi-messenger:$(FROM_REV)" -
API_IMAGE="mtusi-messenger:$(FROM_REV)" $(COMPOSE) up -d --no-deps --force-recreate --wait api
scripts/lb-wait.sh
endif
$(COMPOSE) build -q api
RATE=$(RATE) $(PYTHON) scripts/probe.py load --expect replace --duration 90 \
--out evidence/rolling$(if $(FROM_REV),-from-$(FROM_REV)) \
-- scripts/rolling-update.sh
lab4-level4: limits lb-check detection failover-each rolling-update
scenario:
$(PYTHON) scripts/lab4_scenarios.py $(SCENARIO) --base-url "$(BASE_URL)" --restore --output evidence/$(SCENARIO).json
scripts/lb-wait.sh
s3-check:
sh scripts/s3-check.sh > evidence/s3-security.txt; status=$$?; cat evidence/s3-security.txt; exit $$status
attachments-evidence:
sh scripts/evidence-attachments.sh
upload-faults:
{ echo "date: $$(date -u +%FT%TZ) commit: $$(git rev-parse --short HEAD) BASE_URL=$(BASE_URL)"; \
BASE_URL="$(BASE_URL)" $(VENV)/bin/pytest -m stack -v -s --no-header --tb=short \
-p no:cacheprovider student-tests/stack/test_attachment_faults.py; } > evidence/upload-faults.txt; \
status=$$?; cat evidence/upload-faults.txt; exit $$status
upload-memory:
$(PYTHON) scripts/upload_memory.py --base-url "$(BASE_URL)" $(ARGS)
load-evidence:
sh scripts/load-evidence.sh
overload-leftovers:
sh scripts/overload-leftovers.sh
clean-clone-evidence:
sh scripts/clean-clone.sh
reconcile:
$(COMPOSE) run --rm --no-deps reconciler $(ARGS)
reconcile-demo:
$(PYTHON) scripts/reconcile_track.py demo --base-url "$(BASE_URL)" $(ARGS)
reconcile-cost:
$(PYTHON) scripts/reconcile_track.py cost $(ARGS)
failover-evidence:
sh scripts/failover-evidence.sh "$(BASE_URL)" "$(SHIFT)"
stack-evidence:
sh scripts/evidence-stack.sh
persistence-evidence:
sh scripts/persistence-evidence.sh "$(BASE_URL)" > evidence/persistence.txt
cat evidence/persistence.txt
storage-evidence:
sh scripts/evidence-storage.sh
cache-evidence:
sh scripts/evidence-cache.sh > evidence/cache.txt
cat evidence/cache.txt
test-faults:
BASE_URL="$(BASE_URL)" $(VENV)/bin/pytest -m stack -v -s student-tests/stack
faults-evidence:
{ echo "date: $$(date -u +%FT%TZ) commit: $$(git rev-parse --short HEAD)"; echo "\$$ make test-faults"; \
$(MAKE) --no-print-directory test-faults 2>&1; } | sed 's#$(CURDIR)#<repo>#g' > evidence/faults.txt
cat evidence/faults.txt
grep -qE '^=+ [0-9]+ passed in' evidence/faults.txt
seed:
$(PSQL) -f - < scripts/sql/seed-history.sql
explain: seed
{ echo "date: $$(date -u +%FT%TZ) commit: $$(git rev-parse --short HEAD)"; \
echo "\$$ make explain # scripts/sql/explain-history.sql"; \
$(PSQL) -f - < scripts/sql/explain-history.sql; } > evidence/explain-history.txt
cat evidence/explain-history.txt
images:
$(PYTHON) scripts/make_images.py
queues:
sh scripts/broker.sh queues
topology:
{ echo "date: $$(date -u +%FT%TZ) commit: $$(git rev-parse --short HEAD)"; \
echo "$$ rabbitmqctl list_queues -p messenger name type durable policy messages"; \
$(COMPOSE) exec -T broker rabbitmqctl -q list_queues -p messenger name type durable policy messages; \
echo "$$ rabbitmqctl list_consumers -p messenger"; \
$(COMPOSE) exec -T broker rabbitmqctl -q list_consumers -p messenger queue_name ack_required prefetch_count; \
echo "$$ rabbitmqctl list_permissions -p messenger"; \
$(COMPOSE) exec -T broker rabbitmqctl -q list_permissions -p messenger; \
echo "$$ rabbitmqctl list_users"; \
$(COMPOSE) exec -T broker rabbitmqctl -q list_users; \
echo "$$ docker compose ps"; \
$(COMPOSE) ps --format '{{.Service}}\t{{.Status}}\t{{.Ports}}'; } > evidence/topology.txt
cat evidence/topology.txt
worker-stop:
sh scripts/worker.sh stop
worker-start:
sh scripts/worker.sh start
broker-restart:
sh scripts/broker.sh restart
suite-preflight:
BASE_URL="$(BASE_URL)" $(PYTHON) scripts/pipeline_suite.py --preflight
level3:
BASE_URL="$(BASE_URL)" $(PYTHON) scripts/pipeline_suite.py --level 3 --output evidence/level3.json
level4:
BASE_URL="$(BASE_URL)" $(PYTHON) scripts/pipeline_suite.py --level 4 --output evidence/level4.json
failed:
$(COMPOSE) run --rm --no-deps -T worker python -m messenger.admin failed
replay:
@test -n "$(ID)" || (echo "Set ID=<attachment_id>"; exit 2)
$(COMPOSE) run --rm --no-deps -T worker python -m messenger.admin replay --attachment-id "$(ID)"
dlq:
sh scripts/broker.sh dlq
pipeline-evidence:
$(PYTHON) scripts/pipeline_evidence.py --base-url "$(BASE_URL)" > evidence/pipeline-stand.txt; \
status=$$?; cat evidence/pipeline-stand.txt; exit $$status
.PHONY: track2 reprocess
track2:
BASE_URL="$(BASE_URL)" $(PYTHON) scripts/pipeline_suite.py --level 5 --only "$(TRACK2_SCENARIOS)" --output "$(TRACK2_OUTPUT)"
reprocess:
@test -n "$(ID)" || (echo "Set ID=<attachment_id>"; exit 2)
$(COMPOSE) run --rm --no-deps -T worker python -m messenger.admin reprocess --attachment-id "$(ID)" --pipeline-version "$(PIPELINE_VERSION)"
+33 -33
View File
@@ -1,6 +1,6 @@
# Лабораторная 2. PostgreSQL, сессии и Redis/Valkey
# Лабораторная 5. Очереди и асинхронная обработка изображений
Перенести состояние в постоянное хранилище и связать запросы с аутентифицированным пользователем. Подтверждённые сообщения и действующие сессии переживают перезапуск.
Отделить приём файла от тяжёлой обработки, корректно переживать повторную доставку и остановку worker.
Это **skeleton**, а не готовый сервер. Здесь есть задание, контракт и публичные проверки. Реализацию приложения, Dockerfile и требуемую инфраструктуру пишет студент. Язык и framework свободные; UI не обязателен.
@@ -8,41 +8,42 @@
## Откуда начинаем
Перенесите собственный минимум lab1. Изменения API: password при регистрации, Basic для создания сессии, Bearer вместо X-User-Id для бизнес-запросов.
Нужен минимум lab4. POST upload теперь возвращает 202 queued, а готовность выясняется через метаданные. В HTTP upload клиент по-прежнему передаёт все байты.
**Архитектура:** Клиент → API → PostgreSQL; на 4 появляется Redis ИЛИ Valkey для сессий/кэша.
**Архитектура:** API → устойчивый staging + запись задания → брокер → worker → конечный S3 + PostgreSQL. Клиент опрашивает статус.
## Что сделать
1. Опишите таблицы, ограничения, индексы и транзакционные границы до написания запросов. Добавьте версионируемые миграции.
2. Перенесите пользователей, чаты, членство и сообщения в PostgreSQL. Не используйте SQLite как замену PostgreSQL в принимаемом стенде.
3. Реализуйте регистрацию с password KDF, вход через Basic, opaque Bearer-сессию, expiry и logout. Действующие сессии тоже должны сохраняться.
4. Подготовьте единый локальный запуск API и БД (Compose рекомендуется уже здесь), подключите именованные volumes.
5. Пройдите smoke и тест полного перезапуска. На 4 добавьте Redis/Valkey с конкретной ролью и повторите эксперимент отказа.
1. Выберите RabbitMQ, Redis/Valkey Streams, NATS JetStream или другой брокер с persistence и подтверждениями. Обычный Pub/Sub без хранения не подходит.
2. Разделите приём, durable staging, публикацию задания, обработку и фиксацию результата. Прочитайте contracts/attachment-states.md.
3. Реализуйте worker отдельно от API: публикация оригинала в конечный S3-prefix и thumbnail 256×256 по правилам контракта.
4. Добавьте конечные состояния, ограниченные повторы и идемпотентную запись результатов. Не помещайте bytes или credentials в сообщения брокера.
5. Остановите worker, загрузите файл, перезапустите API/worker, убедитесь в завершении принятой задачи. Затем проверьте повторную доставку.
## Оценка «3»: работающий минимум
- Минимум lab1 сохранён с объявленным переходом на новую аутентификацию. Все обязательные данные и ещё действующие сессии переживают рестарт API и хранилищ без удаления volumes.
- PostgreSQL содержит пользователей, чаты, участников и сообщения. Есть первичные/внешние ключи, уникальность username и миграции с нуля. Составная операция создания чата выполняется атомарно.
- Basic применяется только на POST /auth/sessions, остальные endpoint требуют Bearer. Есть срок жизни сессии и отзыв; X-User-Id не даёт доступ. Пароли уже хешируются password KDF.
- make test и make test-persistence ACTION_SCRIPT=scripts/restart.sh проходят. Миграции повторно запускаются без дублирования данных. Secrets/volumes не попадают в Git.
- Весь минимум lab4 сохранён с переходом upload 201 → 202. API возвращает 202 только после устойчивого приёма оригинала и сохранения задания; остановка API после ответа не теряет работу.
- В общем Compose/Swarm есть отдельные broker и worker. Сообщения durable, доставка at least once, подтверждение только после устойчивого эффекта. Недоступность worker не заставляет API выполнять resize синхронно.
- Состояния queued/processing/ready/failed доступны в API. Worker сохраняет оригинал и один thumbnail; original неизменен, thumbnail соответствует контракту. Публичный smoke проходит.
- Есть ограниченный retry (конкретное число попыток в конфигурации, например 5), финальное failed с безопасным error_code. Повтор одной job не создаёт второго набора вариантов.
- Демонстрация: worker остановлен → upload 202 → сообщение с вложением создано → API перезапущен → worker запущен → ready и доступный thumbnail. Принятое задание не исчезает при рестарте broker с volume.
## Оценка «4»: уровень стажёра/джуна
Весь уровень 3 **и все** пункты ниже:
- Redis ИЛИ Valkey реально используется для сессий с TTL либо осмысленного кэша. Опишите источник истины, политику expiry и инвалидации. Если это единственное хранилище сессий, включите persistence, выдерживающее проверяемый рестарт; один TTL не сохраняет данные.
- Используются параметризованные запросы/безопасный ORM, ограниченный connection pool и таймауты. Проверены гонка регистрации одинакового username и rollback составной операции.
- Индекс истории обоснован запросом и EXPLAIN (ANALYZE, BUFFERS) на ≥10 000 сообщениях; пагинация не использует полный scan всей истории на каждую страницу.
- Есть автоматическая проверка expiry при коротком SESSION_TTL_SECONDS, logout, неверного пароля и недоступности Redis/БД. При потере сервиса приложение возвращает ограниченную ошибку/корректно обходит кэш, не принимает запрос от анонимного пользователя как доверенный.
- Добавлены crop 128×128 и optimized WebP по контракту, параметры качества/удаления метаданных описаны. Невалидные/огромные изображения ограничены по bytes, пикселям, времени и памяти worker.
- Разрыв между PostgreSQL и broker закрыт transactional outbox или другой доказанной схемой восстановления намерения. Внедрён crash между COMMIT и publish; после восстановления задача доходит до ready без ручного создания нового задания.
- Retry использует backoff с jitter, различает постоянные/временные ошибки; есть DLQ/реестр failed и безопасный явный replay. «Повторить» не означает безусловно исполнить дубль уже успешной job.
- Проверена остановка worker после записи объекта, но до ack; повтор завершает тот же результат. Есть timeout/lease для зависшего processing, ограниченная конкуренция/prefetch и очистка staging после безопасной фиксации.
## Оценка «5»: исследование и доказанный результат
Весь уровень 4 **и один законченный трек на выбор**. Приведите гипотезу, повторяемую методику, результаты и ограничения.
**Трек 1. Согласованность кэша.** Покажите на конкурентном сценарии stale read или cache stampede, реализуйте защиту и измерьте число SQL-запросов/latency до и после. Докажите read-after-write из контракта и восстановление после рестарта кэша; одной установки Redis недостаточно.
**Трек 1. Очередь под перегрузкой.** Сравните ≥3 настройки concurrency/prefetch на разных размерах изображений. Измерьте throughput, queue lag, p95 времени до ready и RSS; покажите backpressure и ограничение количества принятой работы. Докажите восстановление после перегрузки, объясните компромисс latency/ресурсы.
**Трек 2. План запроса и восстановление.** Исследуйте ≥100 000 сообщений с неравномерными размерами чатов, сравните ≥2 индекса/запроса и стоимость записи. Сделайте backup → восстановление в новое хранилище → сверку количества и выбранных сообщений. Обсудите время восстановления и границы потери данных.
**Трек 2. Доказанная идемпотентность pipeline.** Постройте versioned pipeline и автоматический fault-injection для дубля, reorder, crash до/после side effect и устаревшей job после новой версии. Зафиксируйте инварианты, покажите отсутствие потери подтверждённых задач и перезаписи нового результата старым. Обсудите почему это не exactly-once доставка.
## Как начать и проверить
@@ -78,28 +79,27 @@ Smoke не выставляет оценку автоматически. Про
## Сценарий защиты
1. Применить миграции к пустому volume, создать пользователей, войти, отправить сообщение.
2. Запустить persistence-сценарий: он держит токен только в памяти тестового процесса; action script перезапускает API и все используемые хранилища, сохраняя volumes.
3. После готовности тот же токен читает те же данные; после logout — 401. Повторить с отдельным коротким TTL для проверки expiry.
4. Для 4: показать роль Redis/Valkey, план SQL и ошибку зависимости. Для 5: выполнить выбранный эксперимент.
1. Запустить make test: API возвращает 202, GET доходит до ready, оригинал и настоящий JPEG thumbnail проверяются.
2. Остановить worker своим скриптом, загрузить файл, убедиться, что content отвечает 409, а другие сообщения продолжают работать.
3. Перезапустить API/broker с сохранением volumes, запустить worker; та же запись должна стать ready. Зафиксировать порядок действий и ID без токенов.
4. Для 4: воспроизвести crash после side effect до ack, разрыв COMMIT/publish и replay failed; для 5 — выбранный эксперимент.
## Что должно быть в PR
Исходники, Dockerfile, миграции, compose.yaml либо эквивалентный воспроизводимый запуск, scripts/restart.sh, собственные тесты и отчёт.
Worker, брокер в общем стенде, схема jobs, migrations/outbox по уровню, конфигурация retry, тесты сбоев и отчёт.
Заполните `REPORT.md` и [шаблон PR](.github/pull_request_template.md), укажите целевую оценку/трек. Не меняйте обязательный контракт и публичные tests ради зелёного результата. Сохраняйте возможности предыдущих лабораторных в пределах [объявленных переходов](COURSE.md).
## Вопросы на защите
- Что подтверждает COMMIT и какие гарантии зависят от настройки durability?
- Где хранятся сессии и что будет после flush/restart Redis?
- Чем аутентификация отличается от доступа к конкретному чату?
- Почему hash пароля и быстрый checksum имеют разные задачи?
- Чем publisher confirm отличается от consumer ack?
- Что именно уже сохранено в момент 202?
- Почему повторная доставка нормальна и где находится ключ идемпотентности job?
- Как отличить зависший worker от долго работающего и не запустить два неконтролируемых дубля?
## Первичные материалы
- [PostgreSQL transactions](https://www.postgresql.org/docs/current/tutorial-transactions.html)
- [PostgreSQL EXPLAIN](https://www.postgresql.org/docs/current/using-explain.html)
- [Valkey persistence](https://valkey.io/topics/persistence/)
- [Redis persistence](https://redis.io/docs/latest/operate/oss_and_stack/management/persistence/)
- [Basic authentication](https://www.rfc-editor.org/info/rfc7617/)
- [RabbitMQ reliability](https://www.rabbitmq.com/docs/reliability)
- [Publisher confirms and acknowledgements](https://www.rabbitmq.com/docs/confirms)
- [Redis Streams](https://redis.io/docs/latest/develop/data-types/streams/)
- [NATS JetStream](https://docs.nats.io/nats-concepts/jetstream)
+227 -22
View File
@@ -1,37 +1,242 @@
# Отчёт — лабораторная 2
# Отчёт — лабораторная работа 5
- Автор, группа: TODO
- Целевая оценка; выбранный трек 5, если нужен: TODO
- Commit/PR: TODO после публикации
- Использованные источники, библиотеки и помощь ИИ: TODO
Автор: **Костылев Артём, БПИ2303**. Тема: «Очереди и асинхронная обработка изображений».
Цель — **«5», трек 2 «Доказанная идемпотентность pipeline»**. Критичный дефект памяти PNG закрыт после отдельного fix/re-review и адресной Linux/HTTP validation. Совокупность сохранённых серий D/V и новых проверок M подтверждает критерии выбранного трека в описанных условиях. Семь minor сохранены; исходные четыре FAIL остаются историей. Validation завершена, публикация требует отдельного разрешения координатора.
## Запуск из чистого clone
Ветка: `solution/bpi2303-kostylev`. Предыдущее ревью: `42575281b352d35bda17ee7601bae5548a996e91` (далее **R**). Последняя полная динамическая квалификация: `0e921116610d289716af0a40ec823376eb8bbcbc` (далее **D**). Между D и R из runtime изменены только `infra/rabbitmq/definitions.json` и `src/messenger/attachments/infrastructure/images.py`; SQLAlchemy, Alembic, outbox, lease/fencing и публикация версий не изменились. Финальные проверки выполнены на `b30e2f6a84419d1ca64525ffb40df92183cccaef` (V), runtime которого побайтно совпадает с R. Текущий код после исправления памяти и повторного ревью — **`6096aa7948b8b666aa3892397a96d044a55f02c6` (M)**; реализация исправления — `1a8020524909ebc5e2e43303436c9d1ce3c1a87b`. От V из runtime изменён только `images.py`, настройки 448 MiB/30 с/concurrency=2 сохранены. Новая validation выполнена на **`74c33160ac01618f70e9e1c6a121a5e45c3c7155` (F, runtime = M)**: 984 passed / 2 Linux-only skipped, Linux-пробник с импортами worker, граничные HTTP и 8 PNG / 48 сравнений PASS. Результаты V не являются прогоном M; новые результаты F сохранены отдельно. Документационные коммиты отчёта и evidence не меняют runtime. Публикация — отдельная фаза, только в private MTUCI-Labs; этот этап ничего не публикует.
TODO: версии runtime/образов, prerequisites, команды создания локальных secrets/.env, build, миграций, запуска, ожидания готовности, тестов и остановки. Указать необходимые действия оператора. Не вставлять секреты. Отдельно указать безопасную остановку и команду намеренного удаления учебных данных.
Индекс происхождения всех доказательств — [evidence/README.md](evidence/README.md). Источники решения: skeleton и контракт курса, собственная ЛР4 с поздними исправлениями до `4ed889c1e4008e3f6040ae2534bef99262d3b8ce`, документация библиотек; при подготовке использован Codex. Перенос 253 файлов разобран в [forward-port.md](evidence/forward-port.md). Нормативные `contracts/`, `tests/`, `README.md`, `COURSE.md` не изменены.
## Воспроизведение из чистого clone
Нужны доступ к приватному репозиторию, Git, Docker с Compose v2, make, системный Python 3.9+, uv и OpenSpec CLI для проверки спецификаций. Приложение использует Python 3.14. Команды ниже — инструкция, а не заявление о новом прогоне из clone: отчётные этапы Docker не запускали; validation V и F использовали существующие volumes, а не чистый clone. Для воспроизведения выбран M.
Вместо `<PRIVATE_REPOSITORY_URL>` подставляется URL репозитория ЛР5 в MTUCI-Labs, доступный после публикации. На общей машине запуск разрешён только в выделенной фазе и своём project; занятые порты не освобождают остановкой чужих контейнеров.
```sh
git clone <PRIVATE_REPOSITORY_URL> mtusi2026lab5
cd mtusi2026lab5
git checkout 6096aa7948b8b666aa3892397a96d044a55f02c6
export COMPOSE_PROJECT_NAME=mtusi2026lab5
export COMPOSE_FILE=compose.yaml
export API_IMAGE=mtusi-messenger:lab5-reviewed
export LB_HTTP_PORT=18085
export LB_STATS_PORT=25085
export BROKER_MANAGEMENT_PORT=25086
export BASE_URL=http://127.0.0.1:18085
export NO_PROXY=localhost,127.0.0.1,::1
uv sync --frozen --group dev
make check validate lint
openspec validate --all --strict
make secrets
docker compose --env-file .env config --quiet
make up
make test
make test-persistence ACTION_SCRIPT=scripts/restart.sh
make test-failover ACTION_SCRIPT=scripts/stop-one.sh
make restore
make student-test
make images
make suite-preflight
python3 scripts/pipeline_suite.py --level 4 --output evidence/local-level4.json
make track2 TRACK2_OUTPUT=evidence/local-track2-run1.json
make track2 TRACK2_OUTPUT=evidence/local-track2-run2.json
make track2 TRACK2_OUTPUT=evidence/local-track2-run3.json
make down
```
`make up` собирает образ и ждёт готовности хранилищ, успешных одноразовых `migrate` и `s3-init`, затем API ×2, relay, worker и LB. `migrate` выполняет **`alembic upgrade head`**. `make secrets` создаёт локальные секреты и `.env`, не предназначенные для Git; их содержимое не входит в evidence. Порты реплик, PostgreSQL, S3 и AMQP наружу не опубликованы. HTTP, статистика LB и UI RabbitMQ слушают только `127.0.0.1`. Экспорты выше имеют приоритет над Compose `.env` и предотвращают случайный выбор старых портов.
`make student-test` поднимает одноразовые Docker-зависимости; его нельзя считать offline-проверкой. Suite сам использует `infra/compose.faults.yaml`, временно меняет параметры своих relay/worker и восстанавливает их. Level 4 включает все шесть сценариев уровня 3. Новые JSON сохраняются отдельно от квалификационных файлов. Стенд останавливают `make down` без удаления постоянных volumes; `reset-data`, `down -v`, `reset/clean` в процедуру не входят.
Для защиты и оператора: `make worker-stop`, `make worker-start`, `make queues`, `make topology`, `make failed`, `make dlq`; `make replay ID=<attachment_id>` возвращает failed в queued с audit, повтор для ready — noop. `make reprocess ID=<attachment_id> PIPELINE_VERSION=2` создаёт новую версию при доступном исходнике. Результаты завершённой адресной validation приведены ниже; полный повтор пригодных серий не требуется.
## Архитектура и решения
TODO: схема процессов/хранилищ, источник истины, транзакционные границы, ограничения. Что перенесено из lab1, что изменено в этой работе. Соответствие переменных из .env.example реальной конфигурации.
```text
Клиент → HAProxy :18085 → API ×2 → проверка → PUT staging в RustFS
→ COMMIT queued + jobs + outbox → 202
PostgreSQL outbox → relay → RabbitMQ quorum queue → отдельный worker
confirm manual ack ↑ после COMMIT
worker → lease → рендер → originals/ и variants/ в S3 → fenced COMMIT
```
## Доказательства критериев
Python 3.14, FastAPI, gunicorn/uvicorn-worker, dishka и dishka-faststream, pydantic, structlog; **SQLAlchemy 2.0.45 async**, драйвер asyncpg 0.32.0, **Alembic 1.16.5**; FastStream 0.7.8 поверх aio-pika 10.2.1, Pillow 13.0.0, aiobotocore, redis-py, argon2-cffi. Версии закреплены в [uv.lock](uv.lock); сохранённая проверка runtime — [runtime.txt](evidence/sqlalchemy-2026-11-06/track2/qualified/runtime.txt). Образы PostgreSQL 17.11, Valkey 8.1.11, RustFS 1.0.4, RabbitMQ 4.1.8, HAProxy 3.2.26 закреплены digest в [compose.yaml](compose.yaml).
| Критерий README | Команда/сценарий | Наблюдаемый результат | Файл доказательства |
Три зоны `identity`, `messaging`, `attachments` имеют домен, application-порты, инфраструктурные адаптеры и entrypoints. `shared` содержит платформу, а сборка — `main.py`, `relay.py`, `worker.py`, `admin.py`. PostgreSQL хранит состояния, версии, сессии и идемпотентность; S3 — байты; Valkey — ускорение проверки сессий; брокер — транспорт. API не подключается к RabbitMQ. Порты зон связаны через DI, а зависимости проверяет `test_bounded_contexts.py`.
**SQLAlchemy и миграции.** [Database/UoW](src/messenger/shared/infrastructure/postgres.py) используют `create_async_engine`, `postgresql+asyncpg`, `async_sessionmaker`, `AsyncSession` и явный `commit()`; ORM-модели основаны на `DeclarativeBase`. Репозитории строят параметризованные ORM/Core-запросы, граница API остаётся pydantic. [alembic/env.py](alembic/env.py) запускает миграции через async engine и `run_sync`, сериализует их advisory lock и проверяет legacy-схему перед принятием. Последовательность [alembic/versions](alembic/versions): `0001_init` → `0002_idempotency_keys` → `0003_attachments` → `0004_jobs` → `0005_failed_registry` → `0006_attachment_quarantine`. Старый каталог SQL-миграций и самописный мигратор не являются текущим способом развёртывания.
**Граница 202.** Сначала фиксируется внутреннее намерение pending, затем проверенные bytes записываются в приватный `staging/`. Одной транзакцией вложение переводится в queued, создаются job, outbox и audit. Только после COMMIT отдаётся сохранённый снимок `queued`, `variants=[]`, `error_code=null`. Отказ до COMMIT не подтверждён клиенту; оставшееся намерение убирается по grace period. API не ждёт resize. Очередь или worker могут быть недоступны при успешном upload.
**Outbox.** Relay выбирает доступные строки по частичному `outbox_pending_idx (available_at, id) WHERE published_at IS NULL` с `FOR UPDATE SKIP LOCKED`. Публикация persistent/mandatory с publisher confirms предшествует отметке `published_at` в той же транзакции. Ошибка публикации оставляет намерение для повтора; сбой после confirm до COMMIT может создать дубль. Цена решения — транзакция остаётся открытой на время сетевой публикации пачки и outbox растёт при недоступном брокере. Нет общей транзакции PostgreSQL/RabbitMQ.
**Worker и эффект.** FastStream использует `AckPolicy.MANUAL`, `RabbitMessage`, prefetch=2 при `WORKER_CONCURRENCY=2`. Worker берёт доверенные ключи S3 из БД, захватывает job арендой `lease_token`, продлевает её при работе и рендерит в отдельном процессе. После записи оригинала и всех трёх вариантов условный COMMIT проверяет актуальность аренды. Ключ эффекта — `(attachment_id, pipeline_version, name)`; уникальные ограничения, versioned S3-ключи с хешем и условие `published_version < new_version` предотвращают второй набор и откат новой публикации. `ack()` вызывается после завершения обработчика с COMMIT, включая фиксацию результата/noop. Ошибка БД приводит к задержке 1 с и `nack(requeue=True)`.
**Повторы.** После claim временная ошибка назначает новую outbox-попытку с equal jitter: половина экспоненциальной задержки плюс случайная половина; штатная база 2 с, максимум 5 попыток. Постоянные ошибки дают `invalid_image`/`processing_failed`, исчерпание — `retry_exhausted`. Просроченный processing возвращает relay через `jobs_lease_idx`; старый держатель не проходит fencing. Ready не откатывается при upgrade, ошибка v2 оставляет v1 доступной. Сообщение, отвергнутое моделью `JobMessage`, отправляется в DLQ; модель не полностью эквивалентна `jobs.schema.json` из-за преобразования типов и nullable-поля (minor ниже). Реестр failed и replay доступны через CLI.
В R policy `delivery-limit=-1` сохраняет инфраструктурные redelivery при длительном отказе БД; прикладной предел `JOB_MAX_ATTEMPTS=5` остаётся. Это исправляет прежний путь queued → DLQ после 10 nack без автоматического восстановления. На V policy подтверждена на существующем volume: 12 requeue после реальной остановки PostgreSQL, затем ready без replay и без роста DLQ — [evidence](evidence/final-validation-2026-11-07/postgres-outage-retry.json); уже лежащие в DLQ сообщения смена policy не возвращает. Произвольное удаление сообщения при уже опубликованном outbox также не исправляется автоматически: outbox/lease не равны универсальной сверке очереди.
**Изображения и ресурсы.** Оригинал неизменен. EXIF orientation применяется, прозрачность накладывается на белый фон, EXIF/ICC/XMP не копируются в варианты. Thumbnail — JPEG в 256×256 без увеличения, округление вниз, минимум 1 px; crop — центральный JPEG 128×128; optimized — WebP в 1280×1280 без увеличения. JPEG quality v1/v2 = 85/90, optimize=True; WebP = 80/85, method=4; Lanczos, reducing_gap=3.0. R исправляет tRNS, включая grayscale 2/4/16 и сравнение полных RGB16 samples до потери младших битов.
Предел входа — 10 485 760 байт и 40 млн пикселей; renderer — 30 с, Linux `RLIMIT_AS=448 MiB` на процесс, до 100 задач на дочерний процесс. Контейнер worker ограничен 2 CPU / 1 GiB, API — 1 CPU / 512 MiB на реплику, relay — 0.5 CPU / 192 MiB, broker — 1 CPU / 512 MiB, PostgreSQL — 2 CPU / 1 GiB, S3 — 1 CPU / 512 MiB. Старое измерение 423 MiB относится к обычному PNG. На V четыре 40 Мп PNG tRNS дали `processing_failed` на первой попытке; Linux-пробник подтверждает `MemoryError` внутри RLIMIT_AS, несмотря на peak контейнера 640 196 608 байт < 1 GiB. Это исходное доказательство major на V; исправление M ещё не подтверждено на той же Linux/HTTP-границе.
**Исправление памяти M.** Преобразования цвета и RGB-маски вычисляются плитками 256×256; глобальные resize/fit остаются после сборки изображения, чтобы не создавать границы плиток. Low-byte core закрывается перед high-byte decode, маски — до EXIF/resize, grayscale-исходник — после сборки RGB. `Image.close()` уничтожает pixel core; обычный выход из контекста изображения закрывает файл, но сохраняет core — [Pillow 13.0.0](https://github.com/python-pillow/Pillow/blob/13.0.0/docs/reference/open_files.rst). Сохранённое сравнение 132 вариантов побайтно совпало с V, но новые затраты Linux-процесса этим не измерены.
**Очистка.** Staging удаляется после безопасной публикации и завершения активных версий; у failed хранится 86400 с, затем replay возвращает expired. Проверка активных jobs и сериализация cleanup/reprocess защищают используемый исходник. Удаление выполняет relay; worker не получает право DeleteObject. Quarantine-миграция поддерживает унаследованную сверку S3, но демонстратор `reconcile_track.py` для квалификации ЛР5 непригоден.
## Проверки и таблица критериев
Исторические динамические PASS относятся к **D**, 2026-11-06 UTC; более ранняя топология и новые проверки V помечены явно. Это аудит сохранённых прогонов, не новый запуск на M. Новые tRNS и policy дополнительно проверены динамически на V в отдельном блоке ниже; эти результаты не смешиваются с D. Полные команды, environment, exit codes и SHA находятся в связанных файлах.
| Критерий | Команда / сценарий | Наблюдение | Файл |
| --- | --- | --- | --- |
| Публичный smoke | make test | TODO | TODO |
| Остальные пункты уровня 3 | TODO | TODO | TODO |
| Все пункты уровня 4, если заявлен | TODO | TODO | TODO |
| Выбранный трек 5, если заявлен | TODO | TODO | TODO |
| Контракт, синтаксис, типы | `make check validate lint` | PASS на F; приложение этим не проверяется | [checks](evidence/final-memory-validation-2026-11-07/checks.txt) |
| Собственные интеграционные тесты | `make student-test PYTEST_ARGS='-q --tb=short'` | F: 984 passed, 2 Linux-only skips, 19 stack deselected; real-broker, Linux-эквивалент пропусков выполнен отдельно | [student-test.txt](evidence/final-memory-validation-2026-11-07/student-test.txt), [Linux](evidence/final-memory-validation-2026-11-07/linux.json) |
| Предыдущее исправление tRNS | Offline-команда с `--confcutdir`, шесть unit-модулей; отдельно `--noconftest` для границ | R: сохранённые 430 + 20 passed; 114 прежних вариантов побайтно совпали; Docker не участвовал | [Команды и результаты](evidence/review-trns-depth-2026-11-06/RESULTS.md) |
| Исправление памяти M | `make student-test` с `--confcutdir` и восемью unit-модулями; отдельно `--noconftest` для границ | Сохранённые 440 passed / 2 Linux-only skipped + 20 passed; 22 изображения / 132 идентичных варианта. Это offline-результат исправления; новые Linux/HTTP на F приведены ниже | [Команды](evidence/review-png-memory-2026-11-07/RESULTS.md), [offline](evidence/review-png-memory-2026-11-07/offline-tests.txt), [границы](evidence/review-png-memory-2026-11-07/boundaries.txt) |
| OpenSpec | `openspec validate --all --strict`; `openspec list --json` | F: 22 спецификации PASS, активных changes нет; цикл исправления памяти архивирован | [OpenSpec](evidence/final-memory-validation-2026-11-07/openspec.txt) |
| 3: минимум lab1–4, 202 и thumbnail | `make test` | Публичный smoke PASS через LB на F | [smoke.txt](evidence/final-memory-validation-2026-11-07/smoke.txt) |
| 3: сессия, исходник и данные после рестарта | `make test-persistence ACTION_SCRIPT=scripts/restart.sh` | PASS; рестарты своих хранилищ и процессов подтверждены событиями | [persistence.txt](evidence/forward-final-2026-11-06/persistence.txt), [контейнеры](evidence/forward-final-2026-11-06/persistence-containers.txt) |
| 3: отказ реплики | `make test-failover ACTION_SCRIPT=scripts/stop-one.sh`; `make restore` | 131 успешная запись, 0 ошибок, первая после отказа через 2.791 с; api-2 остановлен и восстановлен | [failover.txt](evidence/forward-final-2026-11-06/failover.txt), [контейнеры](evidence/forward-final-2026-11-06/failover-containers.txt), [restore.txt](evidence/forward-final-2026-11-06/restore.txt) |
| 3: отдельный broker/worker, quorum, confirm, manual ack, prefetch | `rabbitmqctl list_queues/list_consumers/list_permissions`; проверки падений suite | Топология и prefetch=2 зафиксированы до forward; COMMIT/ack повторно проверен на D. Старый delivery-limit не доказывает policy R | [queues.txt](evidence/sqlalchemy-2026-11-06/grade3/queues.txt), [consumers.txt](evidence/sqlalchemy-2026-11-06/grade3/consumers.txt), [permissions.txt](evidence/sqlalchemy-2026-11-06/grade3/permissions.txt), [level4.json](evidence/forward-final-2026-11-06/level4.json) |
| 3: worker down, рестарт API/broker, затем ready | `pipeline_suite.py --level 4`, `worker_down_broker_restart` | 202 queued, content 409, сообщение 201; очередь [1,0] переживает рестарт; тот же ID становится ready | [level4.json](evidence/forward-final-2026-11-06/level4.json) |
| 3: конечные состояния и повторы | `s3_outage_recovers`, `retry_exhausted`, `duplicate_after_ready` в suite | S3 восстановлен → done на попытке 2; failed на попытке 5; дубль ready → duplicate_noop | [level4.json](evidence/forward-final-2026-11-06/level4.json) |
| 4: варианты и Linux-лимиты | `image_matrix`, `worker_limits` в suite | 26 fixtures: 17 ready и 9 отклонённых; 40 Мп, 0.5 с / 200 MiB → контролируемый failed, worker жив; штатно ready, peak 423/1024 MiB. Новые tRNS на V не прошли границу; после исправления M адресная validation F проходит, см. ниже | [level4.json](evidence/forward-final-2026-11-06/level4.json) |
| 4: outbox, crash COMMIT→publish | `crash_commit_publish` | Relay exit 137; outbox не опубликован; после восстановления ready без новой job | [level4.json](evidence/forward-final-2026-11-06/level4.json) |
| 4: backoff, DLQ, replay | `retry_backoff_jitter`, `malformed_message_dead_lettered`, `replay_failed`, `failed_retention` | Задержки 0.722422/1.010937/2.240832/4.845013 с; DLQ +1; replay failed→ready, ready→noop, после retention→expired | [level4.json](evidence/forward-final-2026-11-06/level4.json) |
| 4: S3→COMMIT→ack, lease/fencing, cleanup | `crash_after_s3_before_commit`, `crash_after_commit_before_ack`, `lease_expiry_fencing` | Exit 137 в заданных окнах; один набор вариантов; старая аренда fenced; staging ready очищен | [level4.json](evidence/forward-final-2026-11-06/level4.json) |
| Все уровни 3/4 в suite | `python3 scripts/pipeline_suite.py --level 4 --output evidence/forward-final-2026-11-06/level4.json` | 17 сценариев / 8 инвариантов PASS; 33 ID, 28 ready, 5 ожидаемых failed, 116 объектов | [Команда](evidence/forward-final-2026-11-06/level4-command.txt), [JSON](evidence/forward-final-2026-11-06/level4.json) |
| 5: трек 2 | `make track2 TRACK2_OUTPUT=evidence/forward-final-2026-11-06/track-runN.json`, N=1,2,3 | 39 сценариев / 24 инварианта PASS; 39 ID / 174 объекта, см. методику | [run1](evidence/forward-final-2026-11-06/track-run1.json), [run2](evidence/forward-final-2026-11-06/track-run2.json), [run3](evidence/forward-final-2026-11-06/track-run3.json) |
| Поздние исправления ЛР4 | `forward_network.py`, целевые stack-тесты и fixture HAProxy | Basic/NUL/logout; битые PNG до storage; обход Valkey с безопасным logout; 12 корректных JSON для 502/503/504 | [network](evidence/forward-final-2026-11-06/network-regressions.txt), [upload](evidence/forward-final-2026-11-06/upload-negative.txt), [cache](evidence/forward-final-2026-11-06/cache-outage.txt), [HAProxy](evidence/forward-final-2026-11-06/haproxy-errors.txt) |
TODO: добавить отдельную строку для каждого заявленного критерия. PASS без команды и наблюдения не является доказательством. Проверка инфраструктурного hook требует подтверждения, какие реальные процессы/хранилища перезапущены.
## Отказы: время и сохранность
## Эксперименты и отказы
Источник — D: [level4.json](evidence/forward-final-2026-11-06/level4.json) и публичные логи выше. Времена suite — **длительности всего сценария**, включая управление контейнерами и assertions; это не время недоступности API и не p95. «Потерь 0» означает отсутствие потерь принятых ID в выборке, а не доказательство для любых отказов диска/сети.
TODO: гипотеза, hardware/лимиты, версии, объём данных, профиль нагрузки, concurrency/arrival rate, длительность/прогрев, повторы, успешные RPS, ошибки, p50/p95/p99, CPU/RAM. Сохранить raw summary без tokens и объяснить ограничения измерения.
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
| Воздействие / команда suite | Фактически остановленный контейнер | Наблюдение | Время / потери |
| --- | --- | --- | --- |
| TODO | TODO | TODO | TODO |
| `worker_down_broker_restart` | `mtusi2026lab5-worker-1`, `3924574b030d`, exited 0 | 19:36:04.231533Z upload; рестарт API/relay, broker с volume; worker started 19:36:20.143149Z, ready 19:36:20.313903Z | 0.171 с от отметки старта до ready; сценарий 16.6 с; потерь 0 |
| Persistence, `scripts/restart.sh` | `mtusi2026lab5-{postgres,valkey,s3,broker,lb,api-1,api-2,relay,worker}`; точные ID в events | Данные, сессия и оригинал сохранены | Команда 12.835 с; потерь подтверждённых данных не обнаружено |
| Failover, `scripts/stop-one.sh` | `mtusi2026lab5-api-2`, exited 0 | 131 запись, 0 ошибок | Первая запись 2.791 с; потерь 0 |
| `crash_commit_publish` | `mtusi2026lab5-relay-1`, `57ef736182d7`, exited 137 | Неопубликованный outbox → ready с прежней job | Сценарий 9.5 с; потерь 0 |
| `crash_publish_confirm` | `mtusi2026lab5-relay-1`, `9f63b40078d5`, exited 137 | **После confirm**, до COMMIT отметки outbox; повтор публикации без второго эффекта | Сценарий 9.6 с; потерь 0; потеря confirm не проверялась |
| `crash_after_s3_before_commit` | `mtusi2026lab5-worker-1`, `c74820bbdab3`, exited 137 | Processing, 0 строк вариантов; повтор → ready | Сценарий 12.6 с; потерь 0 |
| `crash_after_commit_before_ack` | `mtusi2026lab5-worker-1`, `5accc3314905`, exited 137 | Ready до падения; redelivery без нового набора | Сценарий 10.3 с; потерь 0 |
| `lease_expiry_fencing` | Worker задержан, не остановлен | claimed(1) → lease_expired(2) → done(2) → fenced(1) | Сценарий 33.2 с при аренде 5 с и stall 15 с; перезаписи нет |
| `s3_outage_recovers` | S3 остановлен сценарием; отдельного ps с ID в этом JSON нет | После восстановления done на попытке 2 | Сценарий 12.0 с; потерь 0; полнота свидетельства остановки ограничена |
| `retry_exhausted` / `replay_failed` | Fault-injection, контейнеры не требуется останавливать | 5 попыток → failed; явный replay → ready, повтор → noop | Сценарии 17.6 / 28.4 с; failed — ожидаемый исход, не потерянная job |
| `worker_limits` | Worker остаётся running | 40 Мп: принудительные время/память → failed; штатный режим → ready | 15.4 с на сценарий; ошибок процесса worker не зафиксировано |
## Ограничения и следующие шаги
Историческая остановка стенда D: `make down` без `-v`, затем пустой список контейнеров project и четыре сохранённых volume — [down.txt](evidence/forward-final-2026-11-06/down.txt), [stopped-containers.txt](evidence/forward-final-2026-11-06/stopped-containers.txt), [retained-volumes.txt](evidence/forward-final-2026-11-06/retained-volumes.txt). В финальной validation стенд снова остановлен без `-v`; контейнеров project нет, четыре volume сохранены — [down](evidence/final-validation-2026-11-07/down.txt), [проверка](evidence/final-validation-2026-11-07/stopped-containers.txt), [volumes](evidence/final-validation-2026-11-07/retained-volumes.txt).
TODO: какие отказы выдерживаются и какие нет; что не реализовано; где учебное упрощение; какое улучшение подтверждено, а какое пока гипотеза.
## Трек 2: гипотеза, методика и числа
**Гипотеза.** At-least-once доставка вместе с lease/fencing, уникальностью эффекта и монотонной публикацией сохраняет принятые задания при проверенных сбоях; старая job не заменяет результат новой версии.
**Методика.** На D выполнены три последовательных `make track2`. Каждый повтор создаёт 13 новых вложений и включает контроль `smoke_pipeline`, дубль готовой job, две копии в работе, перестановку attempts и версий, crash до side effect, после S3 и после COMMIT до ack, SIGKILL worker, истечение аренды и позднюю v1 после v2. В `reorder_attempts` меняется порядок транспортных копий, а управляемый номер попытки остаётся фактом БД. Отдельно проверяется outbox до publish и после confirm до COMMIT. Потеря самого confirm не моделируется, несмотря на историческое название сценария.
После сценариев suite сверяет SQL и фактический S3 inventory для принятых ID, опрашивает API, скачивает bytes и сравнивает SHA-256, длину и геометрию. Восемь инвариантов: `terminal`, `single_effect`, `no_ready_rollback`, `monotonic_publication`, `bytes_match_metadata`, `bounded_attempts`, `no_orphans`, `no_lost_202`. Наблюдение состояний дискретное, дополнено журналом переходов и SQL-ограничениями. `no_orphans` относится к выборке: исторические failed/DLQ сохранены, глобальная DLQ не обязана быть пустой.
| Повтор на D | Сценарии PASS | Инварианты PASS | Уникальные 202 | Объекты S3 | Команда и первичные данные |
| --- | --- | --- | --- | --- | --- |
| 1 | 13 | 8 | 13 | 58 | [txt](evidence/forward-final-2026-11-06/track-run1.txt), [json](evidence/forward-final-2026-11-06/track-run1.json) |
| 2 | 13 | 8 | 13 | 58 | [txt](evidence/forward-final-2026-11-06/track-run2.txt), [json](evidence/forward-final-2026-11-06/track-run2.json) |
| 3 | 13 | 8 | 13 | 58 | [txt](evidence/forward-final-2026-11-06/track-run3.txt), [json](evidence/forward-final-2026-11-06/track-run3.json) |
| Всего | 39 | 24 | 39 | 174 | [summary.json](evidence/forward-final-2026-11-06/summary.json) |
Во всех трёх повторах `stale_after_new_version` сохраняет одинаковый публичный снимок v2 до/после поздней v1. В `reorder_versions` v2 достигает done первой, v1 получает superseded. Для fixture 320×200 версии различимы; размеры и первые 16 hex SHA-256 ниже повторяются во всех трёх JSON:
| Вариант | Геометрия | v1, байт | v2, байт | SHA v1 / v2 |
| --- | --- | --- | --- | --- |
| crop | 128×128 | 1820 | 2142 | `97bf1400b30a28c1` / `5b6fb2a66216f8ca` |
| optimized | 320×200 | 2462 | 2790 | `1090d84ed8411226` / `fe520c978bd45fc8` |
| thumbnail | 256×160 | 4679 | 5628 | `7bc40bf315c8e18e` / `fa0db661078d4da9` |
Разница вызвана quality JPEG/WebP, не изменением геометрии; больший файл не является измерением визуального качества. На D в этой матрице не обнаружены потеря 202, второй эффект, откат ready или замена v2 старой job. Это ограниченное подтверждение гипотезы, не exactly-once доставка: commit и подтверждение брокеру не атомарны, поэтому повторная доставка остаётся нормальным исходом сбоя.
**Условия.** Darwin arm64, 16 CPU; Docker 28.3.2, VM 16 CPU / 8 217 190 400 байт RAM. Project `mtusi2026lab5`, образ `mtusi-messenger:lab5-forward`, ports 18085/25085/25086; volumes между повторами сохранены. Fault override: lease 5 с, backoff 1 с, outbox poll 0.5 с, sweep 1 с, stall 15 с. [conditions-before.json](evidence/forward-final-2026-11-06/conditions-before.json) и [conditions-track-start.json](evidence/forward-final-2026-11-06/conditions-track-start.json) не показывают других Docker projects в моменты снимков; непрерывного мониторинга CPU хоста нет. Фоновая нагрузка этого этапа не запускалась, ресурсная изоляция производительности не доказана.
У run2/3 UTC-интервалы и монотонные elapsed расходятся: 1161.195/186.458 с и 571.513/180.259 с; у run1 — 181.175/181.089 с. Причина не установлена. Эти длительности исключены из SLO, RPS, сравнений производительности и оценок разброса — [clock-observation.json](evidence/forward-final-2026-11-06/clock-observation.json). Трек 2 проверяет идемпотентность, а не throughput; пригодные функциональные серии не требуется повторять из-за спорного времени.
Предыдущие 39/174 на `9ba3076fa8ba707de932e053fc22f455d83b3210` — историческое сравнение сохранности инвариантов до позднего forward, не ускорения: [старые результаты](evidence/sqlalchemy-2026-11-06/track2/qualified/RESULTS.md). Прерванный старый run3 исключён и заменён только третьим повтором; 10 принятых до прерывания ID восстановились. Корневые `evidence/level3.json`, `level4.json` и старые логи относятся к коду до SQLAlchemy и не подтверждают R.
## Ограничения
Семь minor последнего независимого ревью M сохранены без исправления; они не блокируют отчёт или передачу следующей фазе. Новый minor JobMessage передан координатором в результате `lab5-release-load0-round1`; в отчётном этапе его offline-пробы не повторялись:
| Файл | Ограничение / доказательство |
| --- | --- |
| `src/messenger/attachments/application/pipeline.py:230` | `after_publish_before_confirm` вызывается после `publish()`, уже получившего Basic.Ack. `crash_publish_confirm` проверяет окно после confirm до COMMIT outbox, а не потерю confirm. См. [findings.json](evidence/review-trns-depth-2026-11-06/findings.json). |
| `scripts/limits.py:10` | Несортированный список secrets сравнивается с отсортированным и даёт два ложных FAIL. [Сохранённый запуск](evidence/sqlalchemy-2026-11-06/grade3/limits.txt) имеет exit_code=1; PASS ему не присваивается. |
| `scripts/reconcile_track.py:396` | Демонстратор ждёт upload 201 и `attachments/` из ЛР4; для ЛР5 с 202 непригоден и в квалификации не используется. См. [findings.json](evidence/forward-final-2026-11-06/findings.json). |
| `src/messenger/attachments/application/pipeline.py:304` | Failed upgrade v2 при ready v1 нельзя отдельно повторить replay/reprocess; v1 остаётся доступной. Проверка `test_failed_new_version_keeps_ready_original` — [student-test.txt](evidence/forward-final-2026-11-06/student-test.txt). |
| `evidence/forward-final-2026-11-06/clock-observation.json` | Расхождение часов в run2/3; время не используется для performance-выводов. |
| `openspec/config.yaml:130` | Унаследованное design-правило указывает upload 201 вместо нормативного 202. Конфиг вне scope отчётной фазы. |
| `src/messenger/attachments/entrypoints/schemas.py:67` | Модель допускает `attempt="1"`, `pipeline_version=true`, числовой `created_at` и `traceparent=null` вне `jobs.schema.json`. В четырёх offline-пробах ревью вызваны bus/ack, reject=0. Штатный relay формирует корректные сообщения; критичного последствия не установлено. [Источник и границы проверки](evidence/report-memory-audit-2026-11-07.md). |
Один host, один PostgreSQL, S3 и узел quorum RabbitMQ не обеспечивают HA. Инфраструктурные redelivery теперь не ограничены числом доставок и при долгом отказе создают повторные обращения/логи; прикладные ошибки после claim ограничены. SIGTERM во время обработки может задержать повтор до истечения аренды. Replay сбрасывает attempt с audit и не ограничивает число ручных запусков. Три повтора не покрывают все чередования событий. Уже опубликованные ready-объекты автоматически новым renderer не переписываются; RGB16+tRNS зависит от tile rawmode Pillow и требует регрессий при обновлении.
`openspec/config.yaml` проверен, но не изменён: разрешённый scope отчётной фазы исключает конфиги и OpenSpec. Он уже содержит SQLAlchemy/Alembic и контекст ЛР5; в унаследованном правиле design осталось `201` для PostgreSQL+S3. Для upload ЛР5 нормативен `202` после staging и COMMIT, как в `contracts/`. Эта документационная неточность не меняет HTTP-реализацию.
## Историческая validation V: завершённые проверки и исходный major
Аудит по README, измеренному SHA, diff, конфигурации, ресурсам, dataset, повторам и сырью — [load-validation.md](evidence/load-validation.md). Три пригодных функциональных track2-повтора приняты, вся матрица повторно не запускалась. Изменение только документации не аннулирует эти свидетельства. Новых SLO/throughput-обещаний нет: выбран трек 2.
| Проверка на V | Реальный результат | Доказательство |
| --- | --- | --- |
| `make check validate lint`, OpenSpec | PASS; 22 спецификации, changes=[] | [checks](evidence/final-validation-2026-11-07/checks.txt), [OpenSpec](evidence/final-validation-2026-11-07/openspec.txt) |
| Сборка и публичный `make test` | PASS; образ содержит reviewed images.py, версии закреплены | [build](evidence/final-validation-2026-11-07/build.txt), [runtime](evidence/final-validation-2026-11-07/image-runtime.txt), [smoke](evidence/final-validation-2026-11-07/smoke.txt) |
| Policy на существующем volume и реальная остановка PostgreSQL | PostgreSQL `9f62ea9d176b` exited; 12 `job.requeued`; без replay ready с той же job и attempt=1; DLQ осталась 15; 8 инвариантов PASS. Сценарий 21.815 с, вся команда 27.330 с; принятое вложение сохранено | [команда](evidence/final-validation-2026-11-07/postgres-outage-retry.txt), [JSON](evidence/final-validation-2026-11-07/postgres-outage-retry.json) |
| tRNS HTTP v1/v2, exact neighbor, Adam7/filter/EXIF | 8 изображений, 48 побайтных сравнений вариантов с независимым белым эталоном; исходник, metadata/hash/размеры, stale/duplicate noop; 8 инвариантов PASS | [команда](evidence/final-validation-2026-11-07/png-http.txt), [JSON](evidence/final-validation-2026-11-07/png-http.json) |
| Адресные duplicate/reorder/fencing, COMMIT/ack, malformed/DLQ, exhaustion/replay | 12 сценариев, 8 инвариантов PASS, 11 ID / 47 объектов; одна ожидаемая новая DLQ от malformed | [команда](evidence/final-validation-2026-11-07/delivery-targeted.txt), [JSON](evidence/final-validation-2026-11-07/delivery-targeted.json) |
| PNG tRNS 8000×5000 при 448 MiB / 30 с | **4 FAIL**: grayscale 2/4/16 и RGB16 получили 202 → failed/processing_failed, attempt=1. Штатный ready-сценарий не пройден | [команда](evidence/final-validation-2026-11-07/png-limits.txt), [JSON](evidence/final-validation-2026-11-07/png-limits.json), [fixtures](evidence/final-validation-2026-11-07/fixtures) |
| Принудительные timeout/memory и последующее обычное задание | PASS; worker остаётся жив, обычное задание ready. Это не отменяет четыре FAIL выше | [png-limits.json](evidence/final-validation-2026-11-07/png-limits.json) |
| Повторная read-only сверка после staging sweep | PASS; нет pending outbox/staging/nonterminal/дублей, 10 объектов совпали с БД для 7 ID. Исходный ранний no_orphans FAIL сохранён | [cleanup-recheck](evidence/final-validation-2026-11-07/cleanup-recheck.json) |
**Исходный major на V:** объявленный [OpenSpec-сценарий PNG на пределе пикселей](openspec/specs/lab5-image-variants/spec.md) требует ready при штатных пределах. Новые 40 Мп tRNS fixtures размером 35 759–385 445 байт его не проходят. [Linux-пробник с импортами worker](evidence/final-validation-2026-11-07/resource-probe-worker.txt) воспроизводит MemoryError в `images.py`: grayscale 2/4 — белый RGB-фон, grayscale16 — `I → L`, RGB16 — маски/повторное декодирование. Без tRNS gray2/gray4/RGB16 проходят; gray16 превышает память и без tRNS. Это провал конкретного граничного сценария; потери данных или падение сервиса не обнаружены.
Этот вывод относится к V. Причина исправлена отдельным агентом в M через OpenSpec, выполнено независимое re-review. Старый [findings.json](evidence/final-validation-2026-11-07/findings.json) сохраняет исходный major и шесть minor как историю; он не перезаписывается. Динамическое закрытие major подтверждено новым прогоном F ниже; исходные FAIL V сохранены.
Первый outage-прогон невалиден: `docker compose start worker` автоматически запустил БД; повторён только этот сценарий с точным container ID. Первая передача пробника через docker cp отклонена read-only rootfs, затем использован stdin/tmpfs. Эти ошибки обвязки и ранний cleanup FAIL сохранены отдельно и не объявлены успехом. Все команды, условия, ограничения и остановка — [RESULTS](evidence/final-validation-2026-11-07/RESULTS.md).
Запуск из чистого clone и отдельная throughput-матрица на V не выполнялись. Полный student-test, HTTP и реальный брокер выполнены именно на V. Runtime M дополнительно проверен динамически на F ниже; публикация остаётся отдельной фазой. Push и Telegram не выполнялись.
## Исправление M и завершённая адресная validation F
[Результаты исправления](evidence/review-png-memory-2026-11-07/RESULTS.md) сохраняют четыре ожидаемых FAIL регрессии на исходном renderer и PASS после изменения. Счётчик одновременно живущих pixel buffers на 1025×769 дал:
| PNG tRNS | До, байт | После, байт |
| --- | ---: | ---: |
| grayscale 2 | 7 882 250 | 4 596 485 |
| grayscale 4 | 7 882 250 | 4 596 485 |
| grayscale 16 | 7 882 250 | 5 384 710 |
| RGB16 | 9 458 700 | 5 517 575 |
Это модель pixel buffers, не RSS, виртуальная память процесса или проверка 40 Мп под Linux. До — [regression-before.txt](evidence/review-png-memory-2026-11-07/regression-before.txt), после — [offline-tests.txt](evidence/review-png-memory-2026-11-07/offline-tests.txt). Сохранённые 440 + 20 passed и 132 идентичных варианта подтверждают offline-часть. Независимое ревью M по данным координатора повторило 460 проверок с двумя Linux-only skips и не обнаружило major в доступной области. Его семь minor перечислены выше.
Адресная validation F выполнена после независимого review M. Runtime совпадает с M; от V изменён только renderer, поэтому PostgreSQL outage, delivery subset и три полных track2-повтора приняты без повторения. Аудит применимости — [load-validation](evidence/load-validation.md), команды и методика — [RESULTS](evidence/final-memory-validation-2026-11-07/RESULTS.md).
| Критерий / команда | Результат F | Доказательство |
| --- | --- | --- |
| `linux-runner.py`: импорты worker, RLIMIT_AS=448 MiB, 30 с | Четыре прежних 40 Мп tRNS и grayscale16 без tRNS, v1/v2, обычный render после каждого — PASS; два параллельных RGB16 render — PASS | [команда](evidence/final-memory-validation-2026-11-07/linux.txt), [JSON](evidence/final-memory-validation-2026-11-07/linux.json) |
| `targeted.py png-boundary`: LB/API/relay/broker/worker | 8 сценариев / 8 инвариантов PASS; 202 → ready, original/bytes/hash/геометрия/tRNS, v2, stale/duplicate noop; 11 ID / 59 объектов | [команда](evidence/final-memory-validation-2026-11-07/png-boundary.txt), [JSON](evidence/final-memory-validation-2026-11-07/png-boundary.json) |
| Два одновременных HTTP jobs, v1/v2 | Перекрытие claimed→done; peak worker 885 428 224 байт (844.41 MiB) / 1 GiB; OOM=0 | [concurrent-rgb16](evidence/final-memory-validation-2026-11-07/png-boundary.json) |
| Принудительные 0.01 с / 200 MiB и следующие обычные задания | Два ожидаемых failed/processing_failed, worker жив; после каждого обычная загрузка ready; штатные 448 MiB/30 с/concurrency=2 восстановлены | [JSON](evidence/final-memory-validation-2026-11-07/png-boundary.json), [условия после](evidence/final-memory-validation-2026-11-07/conditions-after.json) |
| `targeted.py png-http`: точный tRNS, Adam7/filter=4/EXIF=6 | 8 fixtures / 48 сравнений v1/v2 с независимым эталоном, 8 инвариантов PASS; 8 ID / 56 объектов | [команда](evidence/final-memory-validation-2026-11-07/png-http.txt), [JSON](evidence/final-memory-validation-2026-11-07/png-http.json) |
| Sweep и SQL/S3 inventory обеих серий | Нет pending outbox/staging/дублей для новых ID; 19 ID / 115 объектов согласованы. Историческая DLQ=16 не выросла | Инварианты в двух JSON выше |
Все 30 SHA пяти файлов × двух версий × трёх вариантов совпали между Linux и HTTP. Peak RSS Linux-процесса — 342 956–406 312 KiB; это не cgroup memory и не виртуальный адресный предел. Диагностический параллельный пробник с дополнительным управляющим процессом дал cgroup peak 1 026 285 568 байт; он отделён от штатных HTTP jobs. Все memory.events=0. Исходные четыре FAIL V закрыты новым динамическим PASS F при неизменных лимитах.
Условия F: тот же project и сохранённые volumes, Docker VM 16 CPU / 8 217 190 400 байт, worker 2 CPU / 1 GiB. В снимках нет чужих контейнеров; специальный фон не запускался, непрерывного контроля хоста нет. Throughput/SLO не заявляются. [Начальные условия](evidence/final-memory-validation-2026-11-07/conditions.json), [итоговые](evidence/final-memory-validation-2026-11-07/conditions-after.json). Стенд F остановлен через `make down` без `-v`: [команда](evidence/final-memory-validation-2026-11-07/down.txt), [пустой project](evidence/final-memory-validation-2026-11-07/stopped-containers.txt), [четыре volumes](evidence/final-memory-validation-2026-11-07/retained-volumes.txt). Push и Telegram не выполнялись.
## Вопросы защиты
- **Что сохранено к 202?** Проверенный оригинал staging, вложение queued, job и outbox после COMMIT. Быстрота worker не меняет снимок ответа.
- **Confirm и ack — в чём разница?** Confirm подтверждает приём брокером; ack подтверждает устойчивый результат обработки. Между ними возможны дубли.
- **Почему дубль безопасен?** Job/версия идентифицируются в БД, lease сериализует работу, fencing отвергает старого держателя, уникальный ключ эффекта защищает варианты.
- **Как отличить долгую работу от смерти?** Живая работа продлевает lease; истёкшую восстанавливает relay. Поздняя фиксация не проходит lease_token.
- **Почему v1 не затирает v2?** Versioned ключи и условие монотонного published_version; ready v1 остаётся доступной до успешной публикации v2.
- **Что ещё не доказано?** Потеря confirm, все сбои диска/сети, производительность под изолированной нагрузкой. Граничные 40 Мп tRNS не прошли на V; исправление M подтверждено Linux/HTTP на F. Validation завершена; публикация требует отдельной фазы.
Документация сверена через Context7: [SQLAlchemy 2.0.45 async](https://github.com/sqlalchemy/sqlalchemy/blob/rel_2_0_45/doc/build/orm/extensions/asyncio.rst), [Alembic 1.16.5 async migrations](https://github.com/sqlalchemy/alembic/blob/rel_1_16_5/docs/build/cookbook.rst), [FastStream 0.7.2 manual ack](https://github.com/ag2ai/faststream/blob/0.7.2/docs/docs/en/getting-started/acknowledgement.md). API 0.7.2 сопоставлен с используемым FastStream 0.7.8; прикладной порядок COMMIT/ack проверяется кодом и evidence, а не одной документацией.
+4
View File
@@ -0,0 +1,4 @@
[alembic]
script_location = %(here)s/alembic
prepend_sys_path = %(here)s/src %(here)s/alembic
path_separator = space
+102
View File
@@ -0,0 +1,102 @@
import asyncio
from alembic import context
from alembic.script import ScriptDirectory
from legacy import adopt_legacy
from sqlalchemy import Connection, func, make_url, pool, select
from sqlalchemy.ext.asyncio import create_async_engine
from messenger.attachments.infrastructure.postgres import (
AttachmentRow,
JobEventRow,
JobRow,
OutboxRow,
VariantRow,
)
from messenger.identity.infrastructure.postgres import SessionRow, UserRow
from messenger.messaging.infrastructure.postgres import (
ChatMemberRow,
ChatRow,
IdempotencyKeyRow,
MessageAttachmentRow,
MessageRow,
)
from messenger.shared.config import PlatformSettings
LOCK_KEY = 20_260_002
MODELS = (
UserRow,
SessionRow,
ChatRow,
ChatMemberRow,
MessageRow,
IdempotencyKeyRow,
AttachmentRow,
JobRow,
OutboxRow,
JobEventRow,
VariantRow,
MessageAttachmentRow,
)
target_metadata = UserRow.metadata
config = context.config
def include_object(_obj, name, _type, _reflected, _compare_to):
return name != "schema_migrations"
def run_migrations(connection: Connection) -> None:
with connection.engine.connect() as lock:
lock.execute(select(func.pg_advisory_lock(LOCK_KEY)))
lock.commit()
try:
with connection.begin():
adopt_legacy(connection, ScriptDirectory.from_config(config))
context.configure(
connection=connection,
target_metadata=target_metadata,
transaction_per_migration=True,
compare_type=True,
include_object=include_object,
)
with context.begin_transaction():
context.run_migrations()
finally:
lock.execute(select(func.pg_advisory_unlock(LOCK_KEY)))
lock.commit()
async def run_async_migrations() -> None:
dsn = config.attributes.get("database_url")
if dsn is None:
dsn = PlatformSettings().database_url.get_secret_value()
engine = create_async_engine(
make_url(dsn).set(drivername="postgresql+asyncpg"),
poolclass=pool.NullPool,
hide_parameters=True,
connect_args={
"timeout": 10,
"server_settings": {"lock_timeout": "10000", "statement_timeout": "60000"},
},
)
try:
async with engine.connect() as connection:
await connection.run_sync(run_migrations)
finally:
await engine.dispose()
if context.is_offline_mode():
context.configure(
dialect_name="postgresql",
target_metadata=target_metadata,
literal_binds=True,
transaction_per_migration=True,
)
with context.begin_transaction():
context.run_migrations()
elif config.attributes.get("connection") is not None:
run_migrations(config.attributes["connection"])
else:
asyncio.run(run_async_migrations())
+94
View File
@@ -0,0 +1,94 @@
from uuid import uuid4
from alembic.migration import MigrationContext
from alembic.operations import Operations
from alembic.script import ScriptDirectory
from sqlalchemy import Connection, MetaData, Table, func, inspect, select, text
from sqlalchemy.schema import CreateSchema
LEGACY = {
"0001_init": "9a13618f078ae9056431391e2e5197a31b981ae1fff047a9b3421ac750d3fd0d",
"0002_idempotency_keys": "d9159a35553249a1e51af5f2e4e7c39b014e97593c49748e13f3799839063dd0",
"0003_attachments": "c4417f560538a083efba1c67f660147dc94532fcbb2fa91f3f3e8258a0f01f2e",
"0004_jobs": "c3887fa7a886ae8153a216aa43fd4c3c6190a2074e8ce20c3e77f29bfb01550e",
"0005_failed_registry": "02b80061a08a6929feb092148c453ad970e3d001901c651b5a73b90b1e40f145",
"0006_attachment_quarantine": (
"541f5399d87fac3584c4102b4e0bf92c23cd372cc20a7d56dad03e771773202c"
),
}
SNAPSHOT = text("""
WITH relations AS (
SELECT c.* FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = :schema AND c.relkind IN ('r', 'p')
AND c.relname NOT IN ('schema_migrations', 'alembic_version')
)
SELECT 'table' AS kind, c.relname AS name,
concat_ws('|', c.relkind, c.relpersistence,
c.relrowsecurity, c.relforcerowsecurity) AS definition
FROM relations c
UNION ALL
SELECT 'column', c.relname || '.' || a.attname,
concat_ws('|', a.attnum, format_type(a.atttypid, a.atttypmod), a.attnotnull,
a.attidentity, a.attgenerated, a.attcollation::regcollation,
pg_get_expr(d.adbin, d.adrelid))
FROM relations c JOIN pg_attribute a ON a.attrelid = c.oid
LEFT JOIN pg_attrdef d ON d.adrelid = c.oid AND d.adnum = a.attnum
WHERE a.attnum > 0 AND NOT a.attisdropped
UNION ALL
SELECT 'constraint', c.relname || '.' || k.conname,
concat_ws('|', pg_get_constraintdef(k.oid), k.convalidated)
FROM relations c JOIN pg_constraint k ON k.conrelid = c.oid
UNION ALL
SELECT 'index', c.relname || '.' || x.relname,
concat_ws('|', pg_get_indexdef(i.indexrelid), i.indisvalid, i.indisready)
FROM relations c JOIN pg_index i ON i.indrelid = c.oid
JOIN pg_class x ON x.oid = i.indexrelid
UNION ALL
SELECT 'trigger', c.relname || '.' || t.tgname,
concat_ws('|', pg_get_triggerdef(t.oid), t.tgenabled)
FROM relations c JOIN pg_trigger t ON t.tgrelid = c.oid WHERE NOT t.tgisinternal
ORDER BY kind, name
""")
def snapshot(connection: Connection, schema: str) -> list[tuple[str, str, str]]:
return [
(kind, name, definition.replace(f"{schema}.", ""))
for kind, name, definition in connection.execute(SNAPSHOT, {"schema": schema})
]
def adopt_legacy(connection: Connection, scripts: ScriptDirectory) -> None:
migration = MigrationContext.configure(connection)
if migration.get_current_heads():
return
tables = set(inspect(connection).get_table_names(schema="public"))
if tables <= {"alembic_version"}:
return
if "schema_migrations" not in tables:
raise RuntimeError("Existing schema has no legacy migration journal")
journal = Table("schema_migrations", MetaData(), schema="public", autoload_with=connection)
applied = dict(connection.execute(select(journal.c.version, journal.c.checksum)).tuples().all())
expected = dict(list(LEGACY.items())[: len(applied)])
if applied != expected:
raise RuntimeError("Unknown or changed legacy migrations")
if not applied:
if tables - {"schema_migrations", "alembic_version"}:
raise RuntimeError("Existing schema has an empty migration journal")
return
revision = list(expected)[-1]
actual = snapshot(connection, "public")
reference = f"alembic_verify_{uuid4().hex}"
savepoint = connection.begin_nested()
try:
connection.execute(CreateSchema(reference))
connection.execute(select(func.set_config("search_path", reference, True)))
with Operations.context(MigrationContext.configure(connection)):
for script in reversed(list(scripts.walk_revisions(base="base", head=revision))):
script.module.upgrade()
wanted = snapshot(connection, reference)
finally:
savepoint.rollback()
if actual != wanted:
raise RuntimeError("Legacy schema differs from the recorded migrations")
migration.stamp(scripts, revision)
+16
View File
@@ -0,0 +1,16 @@
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
def upgrade() -> None:
${upgrades if upgrades else "pass"}
def downgrade() -> None:
${downgrades if downgrades else "pass"}
+87
View File
@@ -0,0 +1,87 @@
import sqlalchemy as sa
from alembic import op
revision = "0001_init"
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
"users",
sa.Column("id", sa.Uuid(), nullable=False),
sa.Column("username", sa.Text(), nullable=False),
sa.Column("display_name", sa.Text(), nullable=False),
sa.Column("password_hash", sa.Text(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.CheckConstraint("password_hash LIKE '$argon2id$%'", name="users_password_hash_check"),
sa.CheckConstraint("username ~ '^[a-z0-9_]{3,32}$'", name="users_username_format"),
sa.CheckConstraint(
"char_length(display_name) BETWEEN 1 AND 100", name="users_display_name_check"
),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("username", name="users_username_key"),
)
op.create_table(
"sessions",
sa.Column("token_hash", sa.LargeBinary(), nullable=False),
sa.Column("user_id", sa.Uuid(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("expires_at", sa.DateTime(timezone=True), nullable=False),
sa.CheckConstraint("expires_at > created_at", name="sessions_check"),
sa.CheckConstraint("octet_length(token_hash) = 32", name="sessions_token_hash_check"),
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("token_hash"),
)
op.create_index("sessions_user_idx", "sessions", ["user_id"], unique=False)
op.create_table(
"chats",
sa.Column("id", sa.Uuid(), nullable=False),
sa.Column("title", sa.Text(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("last_message_at", sa.DateTime(timezone=True), nullable=True),
sa.CheckConstraint("char_length(title) BETWEEN 1 AND 100", name="chats_title_check"),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"chat_members",
sa.Column("chat_id", sa.Uuid(), nullable=False),
sa.Column("user_id", sa.Uuid(), nullable=False),
sa.Column("position", sa.SmallInteger(), nullable=False),
sa.Column("chat_created_at", sa.DateTime(timezone=True), nullable=False),
sa.CheckConstraint("position BETWEEN 1 AND 100", name="chat_members_position_check"),
sa.ForeignKeyConstraint(["chat_id"], ["chats.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("chat_id", "user_id"),
)
op.create_index(
"chat_members_user_idx",
"chat_members",
["user_id", "chat_created_at", "chat_id"],
unique=False,
)
op.create_table(
"messages",
sa.Column("id", sa.Uuid(), nullable=False),
sa.Column("chat_id", sa.Uuid(), nullable=False),
sa.Column("sender_id", sa.Uuid(), nullable=False),
sa.Column("text", sa.Text(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.CheckConstraint("char_length(text) BETWEEN 1 AND 4000", name="messages_text_check"),
sa.ForeignKeyConstraint(
["chat_id", "sender_id"],
["chat_members.chat_id", "chat_members.user_id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
"messages_history_idx", "messages", ["chat_id", "created_at", "id"], unique=False
)
def downgrade() -> None:
raise RuntimeError("Downgrade would delete application data")
+33
View File
@@ -0,0 +1,33 @@
import sqlalchemy as sa
from alembic import op
revision = "0002_idempotency_keys"
down_revision = "0001_init"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
"idempotency_keys",
sa.Column("chat_id", sa.Uuid(), nullable=False),
sa.Column("user_id", sa.Uuid(), nullable=False),
sa.Column("key", sa.Text(), nullable=False),
sa.Column("fingerprint", sa.LargeBinary(), nullable=False),
sa.Column("message_id", sa.Uuid(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.CheckConstraint("key ~ '^[A-Za-z0-9._:-]{1,128}$'", name="idempotency_keys_key_check"),
sa.CheckConstraint(
"octet_length(fingerprint) = 32", name="idempotency_keys_fingerprint_check"
),
sa.ForeignKeyConstraint(
["chat_id", "user_id"],
["chat_members.chat_id", "chat_members.user_id"],
),
sa.ForeignKeyConstraint(["message_id"], ["messages.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("chat_id", "user_id", "key"),
)
def downgrade() -> None:
raise RuntimeError("Downgrade would delete application data")
+77
View File
@@ -0,0 +1,77 @@
import sqlalchemy as sa
from alembic import op
revision = "0003_attachments"
down_revision = "0002_idempotency_keys"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.drop_constraint("messages_text_check", "messages", type_="check")
op.create_check_constraint("messages_text_check", "messages", "char_length(text) <= 4000")
op.create_table(
"attachments",
sa.Column("id", sa.Uuid(), nullable=False),
sa.Column("chat_id", sa.Uuid(), nullable=False),
sa.Column("owner_id", sa.Uuid(), nullable=False),
sa.Column("filename", sa.Text(), nullable=False),
sa.Column("content_type", sa.Text(), nullable=False),
sa.Column("size_bytes", sa.BigInteger(), nullable=False),
sa.Column("sha256", sa.Text(), nullable=False),
sa.Column("width", sa.Integer(), nullable=False),
sa.Column("height", sa.Integer(), nullable=False),
sa.Column("object_key", sa.Text(collation="C"), nullable=False),
sa.Column("status", sa.Text(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("object_key", name="attachments_object_key_key"),
sa.UniqueConstraint("id", "chat_id", name="attachments_chat_key"),
sa.ForeignKeyConstraint(
["chat_id", "owner_id"],
["chat_members.chat_id", "chat_members.user_id"],
name="attachments_owner_fkey",
),
sa.CheckConstraint(
"char_length(filename) BETWEEN 1 AND 255", name="attachments_filename_check"
),
sa.CheckConstraint(
"content_type IN ('image/png', 'image/jpeg')", name="attachments_content_type_check"
),
sa.CheckConstraint(
"size_bytes BETWEEN 1 AND 10485760", name="attachments_size_bytes_check"
),
sa.CheckConstraint("sha256 ~ '^[0-9a-f]{64}$'", name="attachments_sha256_check"),
sa.CheckConstraint("width > 0", name="attachments_width_check"),
sa.CheckConstraint("height > 0", name="attachments_height_check"),
sa.CheckConstraint("status IN ('pending', 'ready')", name="attachments_status_check"),
)
op.create_index(
"attachments_pending_idx",
"attachments",
["created_at"],
postgresql_where=sa.text("status = 'pending'"),
)
op.create_table(
"message_attachments",
sa.Column("message_id", sa.Uuid(), nullable=False),
sa.Column("position", sa.SmallInteger(), nullable=False),
sa.Column("chat_id", sa.Uuid(), nullable=False),
sa.Column("attachment_id", sa.Uuid(), nullable=False),
sa.PrimaryKeyConstraint("message_id", "position"),
sa.UniqueConstraint("message_id", "attachment_id"),
sa.CheckConstraint("position BETWEEN 0 AND 9", name="message_attachments_position_check"),
sa.ForeignKeyConstraint(["message_id"], ["messages.id"], ondelete="CASCADE"),
sa.ForeignKeyConstraint(
["attachment_id", "chat_id"],
["attachments.id", "attachments.chat_id"],
name="message_attachments_attachment_fkey",
ondelete="RESTRICT",
),
)
op.create_index("message_attachments_attachment_idx", "message_attachments", ["attachment_id"])
def downgrade() -> None:
raise RuntimeError("Downgrade would delete application data")
+146
View File
@@ -0,0 +1,146 @@
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
revision = "0004_jobs"
down_revision = "0003_attachments"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.drop_constraint("attachments_status_check", "attachments", type_="check")
op.create_check_constraint(
"attachments_status_check",
"attachments",
"status IN ('pending', 'queued', 'processing', 'ready', 'failed')",
)
for name in ("staging_key", "original_key"):
op.add_column("attachments", sa.Column(name, sa.Text(collation="C"), nullable=True))
op.create_unique_constraint(f"attachments_{name}_key", "attachments", [name])
op.add_column(
"attachments",
sa.Column("published_version", sa.Integer(), nullable=False, server_default="0"),
)
op.create_check_constraint(
"attachments_published_version_check", "attachments", "published_version >= 0"
)
op.add_column("attachments", sa.Column("error_code", sa.Text(), nullable=True))
op.create_check_constraint(
"attachments_error_code_check",
"attachments",
"error_code IN ('invalid_image', 'processing_failed', 'retry_exhausted')",
)
op.alter_column("attachments", "object_key", nullable=True)
attachments = sa.table(
"attachments",
sa.column("status"),
sa.column("object_key"),
sa.column("original_key"),
sa.column("staging_key"),
sa.column("published_version"),
)
op.execute(
attachments.update()
.where(attachments.c.status == "ready")
.values(original_key=attachments.c.object_key, published_version=1)
)
op.execute(
attachments.update()
.where(attachments.c.status == "pending")
.values(staging_key=attachments.c.object_key)
)
op.create_index(
"attachments_staged_idx",
"attachments",
["updated_at"],
postgresql_where=sa.column("staging_key").is_not(None),
)
op.create_table(
"attachment_variants",
sa.Column("attachment_id", sa.Uuid(), sa.ForeignKey("attachments.id"), nullable=False),
sa.Column("pipeline_version", sa.Integer(), nullable=False),
sa.Column("name", sa.Text(), nullable=False),
sa.Column("object_key", sa.Text(collation="C"), nullable=False),
sa.Column("content_type", sa.Text(), nullable=False),
sa.Column("size_bytes", sa.BigInteger(), nullable=False),
sa.Column("width", sa.Integer(), nullable=False),
sa.Column("height", sa.Integer(), nullable=False),
sa.Column("sha256", sa.Text(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.PrimaryKeyConstraint("attachment_id", "pipeline_version", "name"),
sa.UniqueConstraint("object_key", name="attachment_variants_object_key_key"),
sa.CheckConstraint(
"pipeline_version >= 1", name="attachment_variants_pipeline_version_check"
),
sa.CheckConstraint(
"name IN ('thumbnail', 'crop', 'optimized')", name="attachment_variants_name_check"
),
sa.CheckConstraint(
"content_type IN ('image/jpeg', 'image/png', 'image/webp')",
name="attachment_variants_content_type_check",
),
sa.CheckConstraint("size_bytes >= 1", name="attachment_variants_size_bytes_check"),
sa.CheckConstraint("width >= 1", name="attachment_variants_width_check"),
sa.CheckConstraint("height >= 1", name="attachment_variants_height_check"),
sa.CheckConstraint("sha256 ~ '^[0-9a-f]{64}$'", name="attachment_variants_sha256_check"),
)
op.create_table(
"jobs",
sa.Column("job_id", sa.Uuid(), primary_key=True),
sa.Column("attachment_id", sa.Uuid(), sa.ForeignKey("attachments.id"), nullable=False),
sa.Column("pipeline_version", sa.Integer(), nullable=False),
sa.Column("status", sa.Text(), nullable=False),
sa.Column("attempt", sa.Integer(), nullable=False),
sa.Column("claims", sa.Integer(), nullable=False, server_default="0"),
sa.Column("lease_token", sa.Uuid(), nullable=True),
sa.Column("lease_until", sa.DateTime(timezone=True), nullable=True),
sa.Column("next_attempt_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("last_error", sa.Text(), nullable=True),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=False),
sa.UniqueConstraint("attachment_id", "pipeline_version", name="jobs_effect_key"),
sa.CheckConstraint("pipeline_version >= 1", name="jobs_pipeline_version_check"),
sa.CheckConstraint(
"status IN ('queued', 'processing', 'done', 'failed', 'superseded')",
name="jobs_status_check",
),
sa.CheckConstraint("attempt >= 1", name="jobs_attempt_check"),
sa.CheckConstraint("claims >= 0", name="jobs_claims_check"),
)
op.create_index(
"jobs_lease_idx",
"jobs",
["lease_until"],
postgresql_where=sa.column("status") == "processing",
)
op.create_table(
"outbox",
sa.Column("id", sa.BigInteger(), sa.Identity(always=True), primary_key=True),
sa.Column("job_id", sa.Uuid(), sa.ForeignKey("jobs.job_id"), nullable=False),
sa.Column("payload", postgresql.JSONB(), nullable=False),
sa.Column("available_at", sa.DateTime(timezone=True), nullable=False),
sa.Column("published_at", sa.DateTime(timezone=True), nullable=True),
)
op.create_index(
"outbox_pending_idx",
"outbox",
["available_at", "id"],
postgresql_where=sa.column("published_at").is_(None),
)
op.create_index("outbox_job_idx", "outbox", ["job_id"])
op.create_table(
"job_events",
sa.Column("id", sa.BigInteger(), sa.Identity(always=True), primary_key=True),
sa.Column("job_id", sa.Uuid(), nullable=False),
sa.Column("attachment_id", sa.Uuid(), nullable=False),
sa.Column("kind", sa.Text(), nullable=False),
sa.Column("attempt", sa.Integer(), nullable=True),
sa.Column("detail", postgresql.JSONB(), nullable=False, server_default="{}"),
sa.Column("at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now()),
)
op.create_index("job_events_attachment_idx", "job_events", ["attachment_id", "id"])
def downgrade() -> None:
raise RuntimeError("Downgrade would delete pipeline data")
+20
View File
@@ -0,0 +1,20 @@
import sqlalchemy as sa
from alembic import op
revision = "0005_failed_registry"
down_revision = "0004_jobs"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_index(
"jobs_failed_idx",
"jobs",
[sa.column("updated_at").desc()],
postgresql_where=sa.column("status") == "failed",
)
def downgrade() -> None:
op.drop_index("jobs_failed_idx", table_name="jobs")
@@ -0,0 +1,28 @@
import sqlalchemy as sa
from alembic import op
revision = "0006_attachment_quarantine"
down_revision = "0005_failed_registry"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.add_column("attachments", sa.Column("quarantine_reason", sa.Text(), nullable=True))
op.create_check_constraint(
"attachments_quarantine_reason_check",
"attachments",
"quarantine_reason IN ('missing', 'size_mismatch', 'sha_mismatch')",
)
op.add_column(
"attachments", sa.Column("quarantined_at", sa.DateTime(timezone=True), nullable=True)
)
op.create_check_constraint(
"attachments_quarantine_check",
"attachments",
"(quarantine_reason IS NULL) = (quarantined_at IS NULL)",
)
def downgrade() -> None:
raise RuntimeError("Downgrade would delete quarantine data")
+5 -1
View File
@@ -1,10 +1,14 @@
# Topology worksheet, deliberately NOT a runnable stack (no application supplied).
# Implement compose.yaml or stack.yaml; do not submit this empty file as deployment.
# Service names below are logical roles, not imposed container names.
x-lab-number: 2
x-lab-number: 5
x-required-roles:
- api
- postgres
- load_balancer
- s3
- broker
- worker
# TODO: implement real images/builds, network wiring, volumes, healthchecks,
# credentials and bootstrap. Details: contracts/infrastructure.json and README.md.
services: {}
+446
View File
@@ -0,0 +1,446 @@
x-app: &app
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
networks: [backend]
x-s3-env: &s3-env
S3_ENDPOINT: ${S3_ENDPOINT:-http://s3:9000}
S3_REGION: ${S3_REGION:-us-east-1}
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_access_key_id
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_secret_access_key
S3_CONNECT_TIMEOUT_SECONDS: ${S3_CONNECT_TIMEOUT_SECONDS:-1}
S3_READ_TIMEOUT_SECONDS: ${S3_READ_TIMEOUT_SECONDS:-2}
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
IMAGE_CHECK_CONCURRENCY: ${IMAGE_CHECK_CONCURRENCY:-2}
UPLOAD_CONCURRENCY: ${UPLOAD_CONCURRENCY:-3}
UPLOAD_GRACE_SECONDS: ${UPLOAD_GRACE_SECONDS:-900}
UPLOAD_SWEEP_INTERVAL_SECONDS: ${UPLOAD_SWEEP_INTERVAL_SECONDS:-30}
UPLOAD_SWEEP_BATCH: ${UPLOAD_SWEEP_BATCH:-100}
x-pipeline: &pipeline
image: ${API_IMAGE:-mtusi-messenger:${COMPOSE_PROJECT_NAME}}
pull_policy: never
restart: unless-stopped
init: true
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
stop_grace_period: 10s
networks: [backend]
healthcheck:
test: ["CMD", "python", "-c", "import os,sys,time;sys.exit(time.time()-os.stat('/tmp/heartbeat').st_mtime>30)"]
interval: 10s
timeout: 5s
retries: 3
start_period: 30s
start_interval: 2s
depends_on:
migrate:
condition: service_completed_successfully
s3-init:
condition: service_completed_successfully
broker:
condition: service_healthy
x-pipeline-env: &pipeline-env
<<: *s3-env
DATABASE_URL_FILE: /run/secrets/database_url
BROKER_URL_FILE: /run/secrets/broker_url
DB_POOL_MAX_SIZE: ${PIPELINE_DB_POOL_MAX_SIZE:-4}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
HEARTBEAT_FILE: /tmp/heartbeat
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-60}
JOB_BACKOFF_BASE_SECONDS: ${JOB_BACKOFF_BASE_SECONDS:-2}
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400}
x-s3-client: &s3-client
image: rustfs/rc:v0.1.36@sha256:ab024bfebee49a750ce886b4c70963ccd9ddaa03f491704a90710641d7a26699
read_only: true
tmpfs: ["/tmp:size=16m"]
environment:
S3_ENDPOINT: ${S3_ENDPOINT:-http://s3:9000}
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
RC_CONFIG_DIR: /tmp/rc
user: "65534:65534"
volumes: ["./infra/s3:/s3:ro"]
secrets:
- s3_root_user
- s3_root_password
- s3_access_key_id
- s3_secret_access_key
- s3_reconciler_access_key_id
- s3_reconciler_secret_access_key
- s3_worker_access_key_id
- s3_worker_secret_access_key
cap_drop: [ALL]
security_opt: ["no-new-privileges:true"]
restart: "no"
networks: [backend]
deploy:
resources:
limits: {cpus: "0.5", memory: 64m}
services:
lb:
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
environment:
API_SERVER_MAXCONN: ${API_SERVER_MAXCONN:-64}
volumes: [./infra/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro]
ports:
- "127.0.0.1:${LB_HTTP_PORT:-18085}:8080"
- "127.0.0.1:${LB_STATS_PORT:-25085}:8404"
networks: [edge, backend]
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8404/healthz"]
interval: 2s
timeout: 2s
retries: 3
start_period: 60s
start_interval: 1s
sysctls:
net.ipv4.ip_local_port_range: "10240 65535"
net.ipv4.tcp_tw_reuse: "1"
stop_signal: SIGUSR1
stop_grace_period: 8s
restart: unless-stopped
read_only: true
cap_drop: [ALL]
deploy:
resources:
limits: {cpus: "${LB_CPUS:-1}", memory: 128m}
api:
<<: *app
build: .
environment:
<<: *s3-env
DATABASE_URL_FILE: /run/secrets/database_url
CACHE_URL_FILE: /run/secrets/cache_url
CURSOR_SECRET_FILE: /run/secrets/cursor_secret
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
WEB_CONCURRENCY: ${WEB_CONCURRENCY:-2}
DB_POOL_MAX_SIZE: ${DB_POOL_MAX_SIZE:-8}
REQUEST_TIMEOUT_SECONDS: ${REQUEST_TIMEOUT_SECONDS:-8}
MIN_TRANSFER_RATE_BYTES: ${MIN_TRANSFER_RATE_BYTES:-131072}
DB_ACQUIRE_TIMEOUT_SECONDS: ${DB_ACQUIRE_TIMEOUT_SECONDS:-1}
DB_COMMAND_TIMEOUT_SECONDS: ${DB_COMMAND_TIMEOUT_SECONDS:-2}
DRAIN_SECONDS: ${DRAIN_SECONDS:-2}
SHUTDOWN_TIMEOUT_SECONDS: ${SHUTDOWN_TIMEOUT_SECONDS:-6}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
MALLOC_MMAP_THRESHOLD_: ${MALLOC_MMAP_THRESHOLD_:-131072}
secrets: [database_url, cache_url, cursor_secret, s3_access_key_id, s3_secret_access_key]
healthcheck:
test: ["CMD", "python", "-c", "import sys,urllib.request;sys.exit(urllib.request.urlopen('http://127.0.0.1:8080/health/ready',timeout=2).status!=200)"]
interval: 5s
timeout: 3s
retries: 3
start_period: 30s
start_interval: 200ms
stop_grace_period: 8s
restart: unless-stopped
read_only: true
tmpfs: [/tmp]
sysctls:
net.ipv4.tcp_rmem: "4096 65536 262144"
net.ipv4.tcp_wmem: "4096 65536 262144"
depends_on:
migrate:
condition: service_completed_successfully
valkey:
condition: service_started
s3-init:
condition: service_completed_successfully
deploy:
replicas: ${API_REPLICAS:-2}
resources:
limits: {cpus: "${API_CPUS:-1}", memory: "${API_MEMORY:-512m}"}
migrate:
<<: *app
pull_policy: never
init: true
command: ["alembic", "upgrade", "head"]
environment:
DATABASE_URL_FILE: /run/secrets/database_url
LOG_LEVEL: ${LOG_LEVEL:-INFO}
secrets: [database_url]
healthcheck:
disable: true
restart: "no"
depends_on:
postgres:
condition: service_healthy
deploy:
resources:
limits: {cpus: "0.5", memory: 256m}
postgres:
image: postgres:17.11-alpine@sha256:266d3c257594e195b309ae9d1805e54c788f1d7b375f56bf6c367aac6c917e7b
user: "70:70"
command:
- postgres
- -c
- max_connections=${PG_MAX_CONNECTIONS:-200}
- -c
- shared_buffers=${PG_SHARED_BUFFERS:-256MB}
- -c
- shared_preload_libraries=pg_stat_statements
- -c
- pg_stat_statements.track=top
- -c
- track_io_timing=on
- -c
- idle_in_transaction_session_timeout=10s
environment:
POSTGRES_DB: messenger
POSTGRES_USER: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
secrets: [postgres_password]
volumes: [pgdata:/var/lib/postgresql/data]
shm_size: 256m
cpuset: ${PG_CPUSET:-}
healthcheck:
test: ["CMD", "pg_isready", "-h", "127.0.0.1", "-U", "messenger", "-d", "messenger"]
interval: 2s
timeout: 3s
retries: 30
start_period: 10s
start_interval: 200ms
stop_grace_period: 10s
restart: unless-stopped
networks: [backend]
deploy:
resources:
limits: {cpus: "${PG_CPUS:-2}", memory: "${PG_MEMORY:-1g}"}
valkey:
image: valkey/valkey:8.1.11-alpine@sha256:2602ace2be6569bc2bbb06f873776516ab9089821525be34f4305c67eb9db02a
user: "999:1000"
command:
- valkey-server
- /run/secrets/valkey.conf
- --appendonly
- "yes"
- --appendfsync
- always
- --maxmemory
- 64mb
- --maxmemory-policy
- volatile-lru
secrets: [valkey.conf]
volumes: [valkeydata:/data]
healthcheck:
test: ["CMD-SHELL", "REDISCLI_AUTH=\"$$(sed -n 's/^requirepass //p' /run/secrets/valkey.conf)\" valkey-cli ping | grep -q PONG"]
interval: 2s
timeout: 3s
retries: 30
stop_grace_period: 10s
restart: unless-stopped
networks: [backend]
deploy:
resources:
limits: {cpus: "0.5", memory: 128m}
s3:
image: rustfs/rustfs:1.0.4@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2
environment:
RUSTFS_ACCESS_KEY_FILE: /run/secrets/s3_root_user
RUSTFS_SECRET_KEY_FILE: /run/secrets/s3_root_password
RUSTFS_ADDRESS: ":9000"
RUSTFS_CONSOLE_ENABLE: "false"
RUSTFS_REGION: ${S3_REGION:-us-east-1}
RUSTFS_OBS_LOG_DIRECTORY: ""
RUSTFS_OBS_LOGGER_LEVEL: ${S3_LOG_LEVEL:-warn}
secrets: [s3_root_user, s3_root_password]
volumes: [s3data:/data]
cpuset: ${S3_CPUSET:-}
read_only: true
tmpfs: ["/tmp:size=64m"]
cap_drop: [ALL]
security_opt: ["no-new-privileges:true"]
healthcheck:
test: ["CMD", "curl", "-fsS", "-o", "/dev/null", "http://127.0.0.1:9000/health/ready"]
interval: 2s
timeout: 3s
retries: 30
start_period: 20s
stop_grace_period: 10s
restart: unless-stopped
networks: [backend]
deploy:
resources:
limits: {cpus: "${S3_CPUS:-1}", memory: "${S3_MEMORY:-512m}"}
reconciler:
<<: *app
pull_policy: never
profiles: [reconcile]
init: true
entrypoint: ["python", "-m", "messenger.attachments.entrypoints.reconcile"]
command: ["--dry-run"]
environment:
<<: *s3-env
DATABASE_URL_FILE: /run/secrets/database_url
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_reconciler_access_key_id
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_reconciler_secret_access_key
S3_READ_TIMEOUT_SECONDS: ${RECONCILE_S3_READ_TIMEOUT_SECONDS:-10}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
secrets: [database_url, s3_reconciler_access_key_id, s3_reconciler_secret_access_key]
healthcheck:
disable: true
restart: "no"
read_only: true
cpuset: ${RECONCILE_CPUSET:-}
depends_on:
postgres:
condition: service_healthy
s3:
condition: service_healthy
deploy:
resources:
limits: {cpus: "${RECONCILE_CPUS:-1}", memory: "${RECONCILE_MEMORY:-256m}"}
s3-init:
<<: *s3-client
entrypoint: ["/bin/sh", "/s3/init.sh"]
depends_on:
s3:
condition: service_healthy
s3-cli:
<<: *s3-client
profiles: [tools]
entrypoint: ["/bin/sh", "/s3/cli.sh"]
broker:
image: rabbitmq:4.1.8-management-alpine@sha256:54ef5ff505352c1beef05a97ee9bd6ab95b3559a76629ba0119b1d63d8d6e4b2
hostname: broker
user: "100:101"
restart: unless-stopped
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
ports:
- "127.0.0.1:${BROKER_MANAGEMENT_PORT:-25086}:15672"
networks: [backend, edge]
volumes:
- broker-data:/var/lib/rabbitmq
- ./infra/rabbitmq/rabbitmq.conf:/etc/rabbitmq/conf.d/20-messenger.conf:ro
- ./infra/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins:ro
- ./infra/rabbitmq/definitions.json:/etc/rabbitmq/definitions.d/10-topology.json:ro
secrets:
- source: rabbitmq_users
target: /etc/rabbitmq/definitions.d/20-users.json
- rabbitmq_ops_password
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "check_port_connectivity"]
interval: 10s
timeout: 10s
retries: 5
start_period: 60s
start_interval: 2s
stop_grace_period: 10s
deploy:
resources:
limits: {cpus: "1", memory: 512m}
relay:
<<: *pipeline
command: ["python", "-m", "messenger.relay"]
environment:
<<: *pipeline-env
OUTBOX_POLL_SECONDS: ${OUTBOX_POLL_SECONDS:-1}
SWEEP_INTERVAL_SECONDS: ${SWEEP_INTERVAL_SECONDS:-5}
secrets:
- database_url
- source: broker_url_api
target: broker_url
- s3_access_key_id
- s3_secret_access_key
deploy:
resources:
limits: {cpus: "0.5", memory: 192m}
worker:
<<: *pipeline
command: ["python", "-m", "messenger.worker"]
environment:
<<: *pipeline-env
WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2}
RENDER_TIMEOUT_SECONDS: ${RENDER_TIMEOUT_SECONDS:-30}
RENDER_MEMORY_MB: ${RENDER_MEMORY_MB:-448}
RENDER_TASKS_PER_CHILD: ${RENDER_TASKS_PER_CHILD:-100}
secrets:
- database_url
- source: broker_url_worker
target: broker_url
- source: s3_worker_access_key_id
target: s3_access_key_id
- source: s3_worker_secret_access_key
target: s3_secret_access_key
deploy:
resources:
limits: {cpus: "${WORKER_CPUS:-2}", memory: "${WORKER_MEMORY:-1g}"}
k6:
image: grafana/k6:2.3.0@sha256:2dd4756ec6e14e62778916e1eb850108e4b499304c02df56760fa0bdb0fba0b8
profiles: [bench]
environment:
BASE_URL: http://lb:8080
volumes: [./infra/k6:/scripts:ro]
networks: [edge]
deploy:
resources:
limits: {cpus: "${K6_CPUS:-2}", memory: "${K6_MEMORY:-512m}"}
secrets:
postgres_password:
file: ./secrets/postgres_password
database_url:
file: ./secrets/database_url
valkey.conf:
file: ./secrets/valkey.conf
cache_url:
file: ./secrets/cache_url
cursor_secret:
file: ./secrets/cursor_secret
s3_root_user:
file: ./secrets/s3_root_user
s3_root_password:
file: ./secrets/s3_root_password
s3_access_key_id:
file: ./secrets/s3_access_key_id
s3_secret_access_key:
file: ./secrets/s3_secret_access_key
s3_worker_access_key_id:
file: ./secrets/s3_worker_access_key_id
s3_worker_secret_access_key:
file: ./secrets/s3_worker_secret_access_key
rabbitmq_users:
file: ./secrets/rabbitmq_users.json
rabbitmq_ops_password:
file: ./secrets/rabbitmq_ops_password
broker_url_api:
file: ./secrets/broker_url_api
broker_url_worker:
file: ./secrets/broker_url_worker
s3_reconciler_access_key_id:
file: ./secrets/s3_reconciler_access_key_id
s3_reconciler_secret_access_key:
file: ./secrets/s3_reconciler_secret_access_key
volumes:
pgdata:
valkeydata:
s3data:
broker-data:
networks:
edge:
backend:
internal: true
+21
View File
@@ -0,0 +1,21 @@
# Состояния вложения и договор между producer/worker
Сообщение broker соответствует [jobs.schema.json](jobs.schema.json). Можно применять native headers брокера для trace context, но семантика carrier сохраняется; для проверки покажите отображение полей. `job_id` идентифицирует одну логическую работу и не меняется при redelivery; `attempt` начинается с 1 и отражает управляемую попытку обработки (broker redelivery сам по себе не создаёт новый job_id). Ключ эффекта — `(attachment_id, pipeline_version, variant)`.
| Переход | Условие | Что устойчиво сохранено |
| --- | --- | --- |
| нет → queued | Принимаем upload; только после durable handoff отвечаем 202 | Полный проверенный оригинал в staging, метаданные, намерение обработки |
| queued → processing | Worker захватил/арендовал работу | Попытка, lease/deadline или эквивалентная защита |
| processing → queued | Временная ошибка и остались попытки | Причина без секретов, время следующей попытки |
| processing → ready | Все обязательные объекты записаны и результат атомарно опубликован | Оригинал, thumbnail (на 4 ещё crop/optimized), метаданные/checksums |
| processing → failed | Ошибка постоянная или попытки исчерпаны | error_code и запись, доступная оператору |
| processing → queued | Истёк lease после смерти worker | Восстановленная работа, без дублирования эффектов |
| failed → queued | Явный операторский replay, доступен на 4 | Audit, новая попытка, прежний логический эффект защищён от дубля |
Повторная доставка уже ready-задачи — no-op с ack после проверки завершённого эффекта. Конкурентные попытки не перезаписывают более новый pipeline_version. Основной курс использует pipeline_version=1; версионирование нескольких pipeline — трек 5. Заявляйте готовность только когда все обещанные уровнем варианты доступны. Нельзя откатывать ready в processing из-за старого дубля.
**Окна отказа для защиты:** после staging до записи задания; после COMMIT до publish; после publish до confirm; после записи S3 до COMMIT результата; после COMMIT результата до ack. На 3 покажите сохранность успешно принятой работы и повторную доставку; на 4 автоматическое восстановление разрыва DB/broker (outbox/эквивалент) и зависшего processing.
Staging не удаляется до безопасной публикации результатов. Неуспешные/непривязанные исходники имеют документированный retention и cleanup; он не удаляет текущую работу. Broker принимает только ID/служебные данные, не произвольный URL для скачивания и не путь из клиентского filename. Worker берёт доверенные storage metadata из БД.
Ack подтверждает устойчивую обработку, publisher confirm — приём брокером; это разные границы. См. [RabbitMQ reliability](https://www.rabbitmq.com/docs/reliability). At-least-once + идемпотентный эффект не означает exactly-once доставку.
+4 -2
View File
@@ -34,7 +34,8 @@
"chat_id": "33333333-3333-4333-8333-333333333333",
"sender_id": "11111111-1111-4111-8111-111111111111",
"text": "Привет, Боб!",
"created_at": "2026-09-01T12:00:00Z"
"created_at": "2026-09-01T12:00:00Z",
"attachment_ids": []
},
"MessagePage": {
"items": [
@@ -43,7 +44,8 @@
"chat_id": "33333333-3333-4333-8333-333333333333",
"sender_id": "11111111-1111-4111-8111-111111111111",
"text": "Привет, Боб!",
"created_at": "2026-09-01T12:00:00Z"
"created_at": "2026-09-01T12:00:00Z",
"attachment_ids": []
}
],
"next_cursor": null
+33 -2
View File
@@ -1,10 +1,10 @@
{
"lab": 2,
"lab": 5,
"kind": "requirements, not runnable deployment",
"required_for_grade_3": [
{
"role": "api",
"count_min": 1,
"count_min": 2,
"student_implements": true,
"persistent_local_state": false
},
@@ -12,6 +12,37 @@
"role": "postgres",
"purpose": "users/chats/membership/messages/metadata",
"persistent_volume": true
},
{
"role": "load_balancer",
"public_entrypoint": true,
"backend_readiness": true
},
{
"role": "s3",
"choose_one": [
"MinIO",
"SeaweedFS",
"RustFS"
],
"private_bucket": true,
"persistent_volume": true
},
{
"role": "broker",
"choose_one": [
"RabbitMQ",
"Redis Streams",
"Valkey Streams",
"NATS JetStream",
"documented durable equivalent"
],
"persistent_volume": true,
"delivery": "at-least-once"
},
{
"role": "worker",
"separate_process": true
}
],
"optional_components": [
+63
View File
@@ -0,0 +1,63 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "urn:mtusi:messenger:attachment-job:v1",
"title": "Durable attachment processing job v1",
"type": "object",
"additionalProperties": false,
"required": [
"schema_version",
"job_id",
"type",
"attachment_id",
"pipeline_version",
"attempt",
"created_at"
],
"properties": {
"schema_version": {
"const": 1
},
"job_id": {
"type": "string",
"format": "uuid"
},
"type": {
"const": "attachment.process.v1"
},
"attachment_id": {
"type": "string",
"format": "uuid"
},
"pipeline_version": {
"type": "integer",
"minimum": 1
},
"attempt": {
"type": "integer",
"minimum": 1
},
"created_at": {
"type": "string",
"format": "date-time"
},
"traceparent": {
"type": "string",
"pattern": "^00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}$"
},
"tracestate": {
"type": "string",
"maxLength": 512
}
},
"examples": [
{
"schema_version": 1,
"job_id": "11111111-1111-4111-8111-111111111111",
"type": "attachment.process.v1",
"attachment_id": "22222222-2222-4222-8222-222222222222",
"pipeline_version": 1,
"attempt": 1,
"created_at": "2026-09-01T12:00:00Z"
}
]
}
+1493 -7
View File
File diff suppressed because it is too large Load Diff
+46 -3
View File
@@ -1,5 +1,48 @@
# Доказательства
# Индекс доказательств ЛР5
Храните небольшие обезличенные результаты: команды и stdout проверок, JSON/CSV агрегатов нагрузки, EXPLAIN, dashboard JSON, текст разбора отказа. Укажите дату, commit, аппаратные лимиты и профиль нагрузки.
Актуальный [REPORT.md](../REPORT.md) обновлён после независимого ревью **6096aa7948b8b666aa3892397a96d044a55f02c6 (M)**. Предыдущее review — **42575281b352d35bda17ee7601bae5548a996e91 (R)**; полные динамические серии — **0e921116610d289716af0a40ec823376eb8bbcbc (D)**. Validation на `b30e2f6a84419d1ca64525ffb40df92183cccaef` (V, runtime = R) подтвердила PostgreSQL outage, delivery subset и HTTP tRNS, но выявила четыре FAIL на 40 Мп PNG при штатной памяти.
Не добавляйте .env, session tokens, cookies, приватные ключи, credentials, реальные сообщения, raw dumps и signed URLs. Для скриншотов скрывайте секреты. Большие логи/бинарные traces сохраняйте отдельно по правилам преподавателя; одного скриншота без методики недостаточно.
В M изменён только renderer: плитки 256×256 и явное освобождение pixel core. 440 offline + 20 границ PASS, 2 Linux-only skips; 132 варианта совпали с V. Re-review не нашло major в статике/offline; **прежний major закрыт Linux/HTTP validation F** (`74c33160ac01618f70e9e1c6a121a5e45c3c7155`, runtime = M): пять граничных PNG, concurrency=2, принудительные лимиты и HTTP 8/48 PASS. 984 student tests passed / 2 Linux-only skips; Linux-эквивалент выполнен отдельно. Исходные FAIL V сохраняются и не становятся PASS. Аудит применимости V — [load-validation.md](load-validation.md), исходная инструкция адресных проверок — [RESULTS исправления памяти](review-png-memory-2026-11-07/RESULTS.md).
## Как читать каталог
| Файлы / каталог | Код и роль доказательства | Применимость |
| --- | --- | --- |
| [Адресная validation M](final-memory-validation-2026-11-07/RESULTS.md) | F, runtime = M | Linux 448 MiB/30 с, пять 40 Мп PNG × v1/v2; HTTP boundary 8 сценариев / 8 инвариантов и малая матрица 8/48 / 8 инвариантов; 19 ID / 115 объектов; major закрыт, семь minor сохранены |
| [Исправление памяти](review-png-memory-2026-11-07/RESULTS.md) | M; реализация `1a8020524909ebc5e2e43303436c9d1ce3c1a87b` | 440 + 20 passed / 2 skips, счётчик pixel buffers, 132 идентичных варианта; 28 хешей. Linux/HTTP выполняет следующий каталог validation F |
| [Аудит обновления отчёта](report-memory-audit-2026-11-07.md) | M + только документация | Лёгкие проверки, аудит новых хешей/чисел/ссылок; семь minor последнего review, без новых динамических прогонов |
| [Финальная validation](final-validation-2026-11-07/RESULTS.md), [аудит нагрузки](load-validation.md) | V, runtime = R | 980 tests, HTTP PNG и real DB outage; 12 адресных сценариев PASS; четыре 40 Мп PNG FAIL, один major; полный track2 не повторён |
| [Первый аудит отчёта](report-audit-2026-11-07.md) | R + изменения документации, до validation V и исправления M | Реальные лёгкие проверки того этапа, ссылки, хеши, арифметика; без Docker и новых динамических тестов |
| [forward-final-2026-11-06/RESULTS.md](forward-final-2026-11-06/RESULTS.md) | D, полная динамическая квалификация после поздних исправлений ЛР4 | Основная измеренная база: 819 passed / 1 skip, smoke/persistence/failover, уровень 4 и три повтора трека 2; до исправлений R |
| [review-trns-depth-2026-11-06/RESULTS.md](review-trns-depth-2026-11-06/RESULTS.md) | R, исправление глубины PNG tRNS | 430 unit + 20 границ, 114 совместимых вариантов, fixtures и 34 хеша; offline, не Linux/HTTP-квалификация |
| [review-fixes-2026-11-06/RESULTS.md](review-fixes-2026-11-06/RESULTS.md) | Реализация `3fad49d6b913afb122d2c1348ea8d9f99e25cc27`, архив `6e97bdbe9638c5a53951337fce639a1a0db7f92e` | История первого исправления: policy сохранена в R, renderer затем дополнен. 57 тестов не доказывали все tRNS; поздние major и исправление описаны в следующем каталоге |
| [forward-port.md](forward-port.md), [source-inventory.json](forward-final-2026-11-06/source-inventory.json), [forward-audit.json](forward-final-2026-11-06/forward-audit.json) | Перенос ЛР4 `d7478726a85791c21e065d58f610735a9e687433` → `4ed889c1e4008e3f6040ae2534bef99262d3b8ce` | Решения по 253 файлам и 25 хешей на D. Сверяется snapshot, не другой живой репозиторий |
| [sqlalchemy-2026-11-06/grade3/NOTES.md](sqlalchemy-2026-11-06/grade3/NOTES.md) | `24a51744f521aa585e50a931d0a0219d2e960197` | История после перехода на SQLAlchemy, до исправлений track2/forward/review; topology/ack — дополнительное свидетельство, не текущая policy |
| [sqlalchemy-2026-11-06/grade4/NOTES.md](sqlalchemy-2026-11-06/grade4/NOTES.md) | `e9ce6d0afacadc16f1666f4bb7d54d3d7377a269` | Исторический уровень 4; `level4-retry.json` — успешный повтор; исходные неуспешные результаты не переименовываются в PASS |
| [sqlalchemy-2026-11-06/track2/NOTES.md](sqlalchemy-2026-11-06/track2/NOTES.md) | Несколько промежуточных SHA внутри логов | История диагностики и исправлений; для итоговых чисел используется qualified, затем D |
| [sqlalchemy-2026-11-06/track2/qualified/RESULTS.md](sqlalchemy-2026-11-06/track2/qualified/RESULTS.md) | `9ba3076fa8ba707de932e053fc22f455d83b3210` | Старая квалификация 39/174 до позднего forward: run1, run2, run3-retry. Прерванный run3 исключён, повторена только эта серия |
| Все корневые `*.txt` и `*.json` в `evidence/` | Историческая реализация до SQLAlchemy/Alembic, даты/старые SHA — внутри файлов и истории Git | **Не подтверждают R, D или M.** Не использовать старые порты, asyncpg-мигратор, результаты и формулировки как текущие |
Последняя строка включает `contract-checks.txt`, `environment.txt`, `failover-upload.json`, `failover.txt`, `level3.json`, `level4.json`, `limits.txt`, `operator.txt`, `persistence.txt`, `pipeline-stand.txt`, `s3-outage.json`, `s3-security.txt`, `smoke.txt`, `stack.txt`, `student-tests.txt`, `topology.txt`, `upload-faults.txt`. Эти файлы оставлены для истории, без изменения сырья. Старые Markdown-итоги также читаются в пределах указанного выше SHA; их прежние заявления о полноте не распространяются на M. В частности, требования «нужен fix/review» в load-validation.md и RESULTS V описывают историческую остановку: fix и re-review M уже выполнены, Linux/HTTP-подтверждение завершено на F; старые документы не переписаны.
## Основные первичные данные D
- [level4-command.txt](forward-final-2026-11-06/level4-command.txt), [level4.json](forward-final-2026-11-06/level4.json): 17 сценариев, 8 инвариантов; 33 ID, 28 ready, 5 ожидаемых failed, 116 объектов.
- [track-run1.txt](forward-final-2026-11-06/track-run1.txt), [track-run1.json](forward-final-2026-11-06/track-run1.json); [track-run2.txt](forward-final-2026-11-06/track-run2.txt), [track-run2.json](forward-final-2026-11-06/track-run2.json); [track-run3.txt](forward-final-2026-11-06/track-run3.txt), [track-run3.json](forward-final-2026-11-06/track-run3.json): каждый 13 сценариев, 8 инвариантов, 13 ID, 58 объектов. [summary.json](forward-final-2026-11-06/summary.json): всего 39/24/39/174.
- [final-smoke.txt](forward-final-2026-11-06/final-smoke.txt), [persistence.txt](forward-final-2026-11-06/persistence.txt), [failover.txt](forward-final-2026-11-06/failover.txt): публичные проверки. [persistence-containers.txt](forward-final-2026-11-06/persistence-containers.txt), [failover-containers.txt](forward-final-2026-11-06/failover-containers.txt), [restore.txt](forward-final-2026-11-06/restore.txt): фактические операции со своим стендом.
- [student-test.txt](forward-final-2026-11-06/student-test.txt): 819 passed / 1 skipped до последних двух исправлений. Предыдущие offline-результаты R: [offline-tests.txt](review-trns-depth-2026-11-06/offline-tests.txt), [boundaries.txt](review-trns-depth-2026-11-06/boundaries.txt). Текущие M: [offline-tests.txt](review-png-memory-2026-11-07/offline-tests.txt), [boundaries.txt](review-png-memory-2026-11-07/boundaries.txt).
- [conditions-before.json](forward-final-2026-11-06/conditions-before.json), [conditions-track-start.json](forward-final-2026-11-06/conditions-track-start.json), остальные `conditions-*.json`: моментальные срезы общего Docker, не непрерывный контроль фоновой нагрузки.
- [down.txt](forward-final-2026-11-06/down.txt), [stopped-containers.txt](forward-final-2026-11-06/stopped-containers.txt), [retained-volumes.txt](forward-final-2026-11-06/retained-volumes.txt): остановка стенда D. Более поздняя остановка V — [down.txt](final-validation-2026-11-07/down.txt), [stopped-containers.txt](final-validation-2026-11-07/stopped-containers.txt), [retained-volumes.txt](final-validation-2026-11-07/retained-volumes.txt): четыре volume сохранены. Исправление M и отчёт Docker не запускали. Последняя остановка F — [down.txt](final-memory-validation-2026-11-07/down.txt), [пустой project](final-memory-validation-2026-11-07/stopped-containers.txt), [четыре volumes](final-memory-validation-2026-11-07/retained-volumes.txt).
## Не считать успехом или измерением производительности
- `crash_publish_confirm` и raw `window: after publish, before confirm` — историческое имя/описание; реальная точка находится **после Basic.Ack и до COMMIT outbox**. Потерю confirm данный сценарий не проверял.
- [grade3/limits.txt](sqlalchemy-2026-11-06/grade3/limits.txt) имеет **exit_code=1**, два ложных FAIL из-за порядка secrets. Это не PASS.
- [clock-observation.json](forward-final-2026-11-06/clock-observation.json): UTC/elapsed run2 = 1161.195/186.458 с, run3 = 571.513/180.259 с. Причина неизвестна; длительности исключены из RPS/SLO/сравнения разброса. Функциональные результаты пригодны.
- `no_orphans` проверяет выборку ID; на D сохранены 15 исторических/ожидаемых сообщений DLQ, после malformed-сценария V их 16; в F это число не выросло. Это не глобально пустые S3/DLQ.
- `forward-final-2026-11-06/baseline.txt` — 0 тестов; `baseline-regressions.txt` — ожидаемые 29 FAIL до исправления. `review-fixes-2026-11-06/regressions-fixture-error.txt` — неуспешная промежуточная fixture; `review-trns-depth-2026-11-06/regressions-before.txt` — воспроизведённый дефект. Их сохраняют как диагностику, не суммируют с PASS.
- Исторический [findings.json](review-trns-depth-2026-11-06/findings.json) содержит пять minor: окно confirm, limits, legacy reconcile, отдельный replay failed v2 и часы. Дополнительная документационная неточность `201` в `openspec/config.yaml` отражена в REPORT; конфиг этой фазе менять запрещено. Седьмой minor из review M — JobMessage принимает четыре значения вне JSON Schema; источник и ограничения — [аудит отчёта](report-memory-audit-2026-11-07.md). Исторические findings.json с пятью/шестью minor не перезаписываются.
Нагрузочных RPS/p95 для M здесь не заявлено. Финальный агент выполнил только отсутствующие/затронутые проверки и сохранил пригодные серии. После re-review M повторены только затронутые PNG/ресурсные проверки: четыре 40 Мп tRNS и grayscale16 без tRNS с импортами worker, HTTP subset 8/48, concurrency=2, v1/v2, принудительные лимиты и cleanup после sweep. Выполненная процедура и результаты — [validation F](final-memory-validation-2026-11-07/RESULTS.md). PostgreSQL outage, delivery subset и полный track2 повторно не нужны без нового основания.
Сохранять только обезличенные команды, exit codes, SHA, условия и агрегаты. Секреты, `.env`, credentials, session tokens/cookies, реальные сообщения, дампы и signed URLs в evidence не входят. Существующие сырые измерения неизменны; новые свидетельства записаны отдельно. Validation завершена, публикация не выполнялась и требует отдельной фазы.
+14
View File
@@ -0,0 +1,14 @@
date: 2026-10-29T00:36:33Z commit: 0b85edf
$ make check
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
$ make validate PYTHON=<venv с requirements-dev.txt>
<venv>/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
$ make lint
.venv/bin/ruff check src student-tests scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
All checks passed!
.venv/bin/ruff format --check src student-tests scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
159 files already formatted
.venv/bin/ty check src student-tests
All checks passed!
+58
View File
@@ -0,0 +1,58 @@
date: 2026-10-29T00:36:34Z commit: 0b85edf
host: Apple M4 Max, 16 CPU, 48 GiB RAM, macOS 15.1
docker: 28.3.2, VM: 16 CPU, 8217190400 bytes
compose: 2.38.2-desktop.1
images:
image: ${API_IMAGE:-mtusi-messenger:lab5}
image: ${API_IMAGE:-mtusi-messenger:lab5}
image: rustfs/rc:v0.1.36@sha256:ab024bfebee49a750ce886b4c70963ccd9ddaa03f491704a90710641d7a26699
image: haproxy:3.2.26-alpine@sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b
image: postgres:17.11-alpine@sha256:266d3c257594e195b309ae9d1805e54c788f1d7b375f56bf6c367aac6c917e7b
image: valkey/valkey:8.1.11-alpine@sha256:2602ace2be6569bc2bbb06f873776516ab9089821525be34f4305c67eb9db02a
image: rustfs/rustfs:1.0.4@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2
image: rabbitmq:4.1.8-management-alpine@sha256:54ef5ff505352c1beef05a97ee9bd6ab95b3559a76629ba0119b1d63d8d6e4b2
image: grafana/k6:2.3.0@sha256:2dd4756ec6e14e62778916e1eb850108e4b499304c02df56760fa0bdb0fba0b8
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS builder
COPY --from=ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 /uv /usr/local/bin/uv
FROM python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS runtime
python in image: Python 3.14.7
haproxy: HAProxy version 3.2.26-3e0f11a 2026/10/14 - https://haproxy.org/
rustfs: rustfs 1.0.4
rabbitmq: 4.1.8
packages (uv.lock):
fastapi 0.141.1
uvicorn 0.54.0
uvicorn-worker 0.4.0
gunicorn 26.2.0
asyncpg 0.32.0
argon2-cffi 25.1.0
pydantic 2.13.5
pydantic-settings 2.15.0
dishka 1.10.1
structlog 26.1.0
redis 8.1.0
aiobotocore 3.10.0
botocore 1.43.117
aiohttp 3.14.5
pillow 13.0.0
faststream 0.7.8
aio-pika 10.2.1
aiormq 7.2.4
dishka-faststream 0.7.0
process users (service uid command):
api 10001 python
broker 100 beam.smp
broker 100 epmd
broker 100 erl_child_setup
broker 100 inet_gethost
broker 100 sh
lb 99 haproxy
postgres 70 postgres
relay 10001 docker-init
relay 10001 python
s3 10001 rustfs
valkey 999 tini
valkey 999 valkey-server
worker 10001 docker-init
worker 10001 python
worker limits: 2 CPU, memory.max 1024 MiB; render: WORKER_CONCURRENCY=2 processes, RLIMIT_AS 448 MiB, timeout 30 s, 100 tasks per process
+10
View File
@@ -0,0 +1,10 @@
{
"ok": true,
"scenario": "failover-upload",
"upload_instance": "70cfba801128",
"download_instance": "095cb9cc85bd",
"sha256_equal": true,
"hook_seconds": 2.877,
"download_ok_after_seconds": 2.886,
"restored": true
}
+39
View File
@@ -0,0 +1,39 @@
date: 2026-10-29T00:33:32Z commit: 0b85edf
== before: api replicas (hostname = X-Instance-Id), state, StartedAt, FinishedAt
095cb9cc85bd running started=2026-10-29T00:33:12.427394173Z finished=2026-10-29T00:33:03.853644169Z
70cfba801128 running started=2026-10-29T00:33:12.607365173Z finished=2026-10-29T00:33:03.666460502Z
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:18085"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 133, "failed_attempts": 0, "first_recovery_seconds": 3.005}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
== after: api replicas
095cb9cc85bd running started=2026-10-29T00:33:12.427394173Z finished=2026-10-29T00:33:03.853644169Z
70cfba801128 exited started=2026-10-29T00:33:12.607365173Z finished=2026-10-29T00:33:39.052027754Z
== stopped replica: 70cfba801128; shutdown: signal, drain window with readiness 503, close, exit
{"event":"Handling signal: term","level":"info","ts":"2026-10-29T00:33:36.479119Z"}
{"event":"Draining for 2.0 s","level":"info","ts":"2026-10-29T00:33:36.486455Z"}
{"event":"Draining for 2.0 s","level":"info","ts":"2026-10-29T00:33:36.558375Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"b3d9118f93b94471b698d536dda11072","duration_ms":0.772,"event":"request.handled","level":"info","ts":"2026-10-29T00:33:37.011026Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"3c1324def7e74f3484c4fbd242f7f70b","duration_ms":0.655,"event":"request.handled","level":"info","ts":"2026-10-29T00:33:37.515877Z"}
{"method":"GET","route":"/health/ready","status":503,"request_id":"e56c9504272b45a89b7372020eb80d15","duration_ms":0.733,"event":"request.handled","level":"info","ts":"2026-10-29T00:33:37.588547Z"}
{"event":"Shutting down","level":"info","ts":"2026-10-29T00:33:38.487910Z"}
{"event":"Shutting down","level":"info","ts":"2026-10-29T00:33:38.560300Z"}
{"event":"service.stopped","level":"info","ts":"2026-10-29T00:33:38.592638Z"}
{"event":"Finished server process [13]","level":"info","ts":"2026-10-29T00:33:38.592934Z"}
{"event":"Worker (pid:13) was sent SIGTERM!","level":"info","ts":"2026-10-29T00:33:38.624866Z"}
{"event":"service.stopped","level":"info","ts":"2026-10-29T00:33:38.664775Z"}
{"event":"Finished server process [14]","level":"info","ts":"2026-10-29T00:33:38.665027Z"}
{"event":"Worker (pid:14) was sent SIGTERM!","level":"info","ts":"2026-10-29T00:33:38.725950Z"}
{"event":"Shutting down: Master","level":"info","ts":"2026-10-29T00:33:38.834487Z"}
$ scripts/restore.sh
Container mtusi2026lab5-api-1 Running
Container mtusi2026lab5-api-2 Starting
Container mtusi2026lab5-api-2 Started
Container mtusi2026lab5-api-1 Waiting
Container mtusi2026lab5-api-2 Waiting
Container mtusi2026lab5-api-1 Healthy
Container mtusi2026lab5-api-2 Healthy
== after restore
095cb9cc85bd running started=2026-10-29T00:33:12.427394173Z finished=2026-10-29T00:33:03.853644169Z
70cfba801128 running started=2026-10-29T00:33:51.687259594Z finished=2026-10-29T00:33:39.052027754Z
@@ -0,0 +1,55 @@
# Адресная validation исправления памяти PNG
**PASS. Прежний major закрыт динамически.** Измерен HEAD `74c33160ac01618f70e9e1c6a121a5e45c3c7155`, runtime побайтно равен прошедшему review `6096aa7948b8b666aa3892397a96d044a55f02c6` (M). Реализация, конфигурация и нормативные файлы в этой фазе не менялись. Публикация не выполнялась и требует отдельной фазы.
Исходные четыре HTTP FAIL и Linux MemoryError на V сохранены в [предыдущей validation](../final-validation-2026-11-07/RESULTS.md). Они не переименованы в PASS: здесь новый образ и новые результаты после отдельного fix/re-review. От V изменён только renderer, поэтому три пригодных повтора track2 на D, PostgreSQL outage и delivery subset на V приняты без повторения. Решения по каждой серии — [load-validation.md](../load-validation.md); SHA, diff, 53 прежних и 28 fix-хешей — [audit.json](audit.json).
## Условия и методика
2026-11-07 по локальной дате; UTC команд — 2026-11-06. Darwin arm64, Docker 28.3.2, Linux aarch64, VM 16 CPU / 8 217 190 400 байт. Project `mtusi2026lab5`, API 18085, stats/UI 25085/25086, все published ports на loopback. Использованы сохранённые volumes, не чистый clone. Worker: 2 CPU / 1 GiB; renderer RLIMIT_AS=448 MiB, 30 с, concurrency=2. Значения не повышались. Образ и закреплённые версии — [build.txt](build.txt), [runtime.txt](runtime.txt), [conditions.json](conditions.json).
Снимки до/после и внутри серий не показывают чужих работающих контейнеров. Специальная фоновая нагрузка не запускалась. Load average хоста: 1.67/2.11/2.34 перед этапом, 2.62/2.65/2.53 перед проверками, 6.41/4.18/3.19 после. Непрерывного контроля хоста нет; throughput, RPS, p95 и новые SLO не заявляются. Длительности — диагностические монотонные интервалы конкретных команд/рендеров, не benchmark. [Условия после](conditions-after.json) подтверждают восстановленные 448 MiB/30 с/concurrency=2 и отсутствие OOM.
Linux-пробник запускает новые процессы с **импортами messenger.worker**, настоящим RLIMIT_AS и alarm=30 с на каждый рендер. Пять файлов проходят v1/v2, затем обычное изображение в том же процессе. Два дополнительных процесса одновременно рендерят RGB16; пересечение измерено монотонными отметками внутри render. Пробник использует те же четыре сохранённые PNG 8000×5000; пятый получается удалением только tRNS из grayscale16. Входные SHA сохранены. Реальный HTTP использует LB/API/relay/broker/worker и ту же конфигурацию. При concurrency=2 журнал БД подтверждает перекрытие claimed→done в обеих версиях.
После диагностических процессов worker пересоздан без изменения образа/лимитов для отдельного cgroup peak HTTP — [reset-worker-peak.txt](reset-worker-peak.txt). Это не повтор нагрузки. Ожидаемые отказы создаются только на двух новых заданиях: 0.01 с и 200 MiB. После каждого лимиты восстановлены и обычная загрузка достигает ready. Перед SQL/S3-инвариантами дождались штатного sweep. Старые данные и DLQ не удалялись.
## Команды и результаты
Команды выполнялись из корня репозитория. `source evidence/final-memory-validation-2026-11-07/env.sh` задаёт несекретные Compose-параметры. Обёртка `python3 scripts/capture_evidence.py <новый-файл> -- <команда>` сохраняет SHA, команду, exit code и elapsed; существующие результаты не перезаписывает.
| Команда / проверка | Результат | Первичные данные |
| --- | --- | --- |
| `make check validate lint` | PASS | [checks.txt](checks.txt) |
| `openspec validate --all --strict`; `openspec list --json` | 22 PASS, changes=[] | [openspec.txt](openspec.txt), [active-changes.txt](active-changes.txt) |
| `make student-test PYTEST_ARGS='-q --tb=short'` | 984 passed, 2 Linux-only skipped, 19 stack deselected; 171.26 с pytest. Пропуски не названы PASS; Linux-эквивалент выполнен отдельно | [student-test.txt](student-test.txt) |
| `docker compose build`; `docker compose up -d --wait`; `make test` | Сборка, миграции/готовность и публичный smoke PASS | [build.txt](build.txt), [up.txt](up.txt), [smoke.txt](smoke.txt) |
| `.venv/bin/python evidence/final-memory-validation-2026-11-07/linux-runner.py` | Пять 40 Мп PNG × v1/v2 и обычный render после каждого PASS; два параллельных RGB16 × v1/v2 PASS | [linux.txt](linux.txt), [linux.json](linux.json), [child](linux-child.py), [runner](linux-runner.py) |
| `PYTHONPATH=src .venv/bin/python evidence/final-memory-validation-2026-11-07/targeted.py png-boundary` | 8 сценариев и 8 инвариантов PASS; 11 ID, 9 ready, 2 ожидаемых failed, 59 S3-объектов | [команда](png-boundary.txt), [JSON](png-boundary.json), [обвязка](targeted.py) |
| `PYTHONPATH=src .venv/bin/python evidence/final-memory-validation-2026-11-07/targeted.py png-http` | 8 fixtures, 48 сравнений вариантов v1/v2 с независимым белым эталоном; 8 инвариантов PASS, 8 ID / 56 объектов | [команда](png-http.txt), [JSON](png-http.json) |
Граничные HTTP-проверки: четыре прежних tRNS и grayscale16 без tRNS достигают ready в v1/v2; исходник неизменен; SHA, длина, MIME и размеры вариантов согласованы с байтами. Белая область белая, соседний RGB16 с отличием младшего бита остаётся непрозрачным. Все 30 хешей пяти файлов × двух версий × трёх вариантов совпали между Linux и HTTP. Поздняя v1 и дубль v2 не изменили опубликованный снимок; по шесть строк вариантов на ID. Два одновременных HTTP-вложения также проходят обе версии. Малая матрица включает grayscale 1/2/4/8/16, RGB8/16 и RGB16 Adam7/filter=4/EXIF=6.
| Linux-файл | Peak RSS процесса, KiB | HTTP: обе версии |
| --- | ---: | --- |
| grayscale2 tRNS | 343 076 | ready |
| grayscale4 tRNS | 342 956 | ready |
| grayscale16 tRNS | 365 508 | ready |
| grayscale16 без tRNS | 365 492 | ready |
| RGB16 tRNS | 406 312 | ready |
При двух **реальных HTTP jobs** cgroup peak worker = **885 428 224 байт (844.41 MiB) / 1 GiB**, все memory.events=0. Диагностический Linux-запуск, включающий idle worker, управляющий процесс и два дополнительных дочерних процесса, дал другой peak: 1 026 285 568 байт / 1 GiB, также без OOM. Это разные условия; диагностический peak не выдаётся за память штатных HTTP jobs. RSS не равен RLIMIT_AS или cgroup memory.
Инварианты обеих HTTP-серий проверяют terminal, single_effect, no_ready_rollback, monotonic_publication, bytes_match_metadata, bounded_attempts, no_orphans и no_lost_202. После sweep нет staging/pending outbox/дублирующих эффектов для новых ID; S3 inventory согласован с БД. DLQ осталась 16: это сохранённые исторические/ожидаемые записи, не новые ошибки этой серии. Проверка scoped, не глобальная очистка.
## Завершение и ограничения
Свои контейнеры остановлены через `make down` без `-v`: [до остановки](final-containers.txt), [down](down.txt), [пустой project](stopped-containers.txt), [четыре volumes](retained-volumes.txt), [пустой общий running list](running-containers-after.txt). [Ретроспективный срез Docker events](container-events.json) ограничен последними 256 событиями daemon и подтверждает финальную остановку; он не используется как полная история промежуточных worker-stop.
Семь minor независимого review сохранены в [findings.json](findings.json) и ограничениях [REPORT](../../REPORT.md). Новых major не обнаружено. Потеря publisher confirm, все возможные отказы диска/сети и изолированная throughput-матрица не доказаны; выбран трек 2. Исходный major памяти закрывается только для проверенных сценариев и закреплённой версии Pillow.
Context7 вызван для Pillow, но вернул исчерпание месячной квоты. Использован официальный [Pillow: Image lifecycle](https://pillow.readthedocs.io/en/stable/reference/open_files.html): `Image.close()` уничтожает image core, контекстный менеджер сам core не уничтожает. Эта справка не заменяет выполненные Linux-проверки.
Перед коммитом проверены разрешённый scope, отсутствие секретов в tracked файлах, локальные ссылки и сохранность runtime/нормативных файлов; результаты — [final-audit.json](final-audit.json), [secret-scan.json](secret-scan.json), [final-checks.txt](final-checks.txt). Контрольные суммы новых артефактов — [sha256.json](sha256.json). Push и Telegram не выполнялись.
Полный `git diff --cached --check` обнаружил 17 trailing-whitespace строк в сыром выводе smoke и двух HTTP-команд. Вывод сохранён без редактирования; отдельная проверка документов/обвязки проходит. Это формат console output, не результат сценария приложения.
@@ -0,0 +1,11 @@
date: 2026-11-06T22:54:44Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {}
$ openspec list --json
{
"changes": [],
"root": {
"path": "<repo>",
"source": "nearest"
}
}
exit_code: 0 elapsed_seconds: 0.974
@@ -0,0 +1,153 @@
import ast
import hashlib
import json
import re
import subprocess
from pathlib import Path
ROOT = Path.cwd()
FOLDER = Path(__file__).resolve().parent.relative_to(ROOT)
MEASURED = "74c33160ac01618f70e9e1c6a121a5e45c3c7155"
REVIEWED = "6096aa7948b8b666aa3892397a96d044a55f02c6"
def git(*args):
return subprocess.check_output(["git", *args], text=True).strip()
assert git("rev-parse", "HEAD") == MEASURED
assert git("branch", "--show-current") == "solution/bpi2303-kostylev"
paths = git("diff", "--name-only", MEASURED).splitlines()
assert all(p in {"REPORT.md", "AGENTS.md"} or p.startswith("evidence/") for p in paths)
runtime_diff = git(
"diff",
"--name-only",
REVIEWED,
"--",
"src",
"infra",
"compose.yaml",
"Dockerfile",
"pyproject.toml",
"uv.lock",
"alembic",
"scripts",
"student-tests",
"openspec",
)
assert not runtime_diff
assert not git(
"diff", "--name-only", "upstream/main", "--", "contracts", "tests", "README.md", "COURSE.md"
)
subprocess.run(["git", "diff", "--check"], check=True)
whitespace = subprocess.run(["git", "diff", "--cached", "--check"], capture_output=True, text=True)
raw_whitespace = re.findall(r"^([^\n:]+):\d+: trailing whitespace\.$", whitespace.stdout, re.M)
assert whitespace.returncode in (0, 2)
assert set(raw_whitespace) <= {
str(FOLDER / "png-boundary.txt"),
str(FOLDER / "png-http.txt"),
str(FOLDER / "smoke.txt"),
}
subprocess.run(
["git", "diff", "--cached", "--check", "--", ".", f":(exclude){FOLDER}/*.txt"],
check=True,
)
tracked = set(git("ls-files").splitlines())
docs = [
Path("REPORT.md"),
Path("AGENTS.md"),
Path("evidence/README.md"),
Path("evidence/load-validation.md"),
FOLDER / "RESULTS.md",
]
links = 0
for doc in docs:
content = doc.read_text()
assert len(re.findall(r"^```", content, re.M)) % 2 == 0, doc
for target in re.findall(r"\]\(([^)]+)\)", content):
if re.match(r"(?:https?://|#)", target):
continue
destination = (doc.parent / target.split("#")[0]).resolve()
assert destination.exists(), (doc, target)
relative = str(destination.relative_to(ROOT))
assert relative in tracked or any(p.startswith(relative + "/") for p in tracked), relative
links += 1
json_files = 0
for name in tracked:
if name.endswith(".json"):
json.loads(Path(name).read_text())
json_files += 1
for path in FOLDER.glob("*.py"):
ast.parse(path.read_text(), filename=str(path))
hashes = 0
for manifest, key in [
("evidence/final-validation-2026-11-07/sha256.json", None),
("evidence/review-png-memory-2026-11-07/checks.json", "sha256"),
]:
entries = json.loads(Path(manifest).read_text())
if key:
entries = entries[key]
for name, expected in entries.items():
assert hashlib.sha256(Path(name).read_bytes()).hexdigest() == expected, name
hashes += 1
accepted = []
for name in [
"evidence/forward-final-2026-11-06/level4.json",
*[f"evidence/forward-final-2026-11-06/track-run{n}.json" for n in (1, 2, 3)],
"evidence/final-validation-2026-11-07/postgres-outage-retry.json",
"evidence/final-validation-2026-11-07/delivery-targeted.json",
]:
data = json.loads(Path(name).read_text())
scenarios = data.get("scenarios", data.get("cases"))
assert data["result"] == "PASS"
assert all(x["result"] == "PASS" for x in scenarios + data["invariants"])
accepted.append(
{
"file": name,
"source_sha": data["source_sha"],
"scenarios": len(scenarios),
"invariants": len(data["invariants"]),
}
)
own_containers = subprocess.check_output(
["docker", "ps", "-aq", "--filter", "label=com.docker.compose.project=mtusi2026lab5"], text=True
).strip()
assert not own_containers
volumes = subprocess.check_output(
[
"docker",
"volume",
"ls",
"--filter",
"label=com.docker.compose.project=mtusi2026lab5",
"--format",
"{{.Name}}",
],
text=True,
).splitlines()
assert len(volumes) == 4
report = {
"measured_sha": MEASURED,
"reviewed_runtime": REVIEWED,
"runtime_equal": True,
"normative_equal_to_upstream_main": True,
"changed_paths": paths,
"local_links_verified": links,
"tracked_json_parsed": json_files,
"previous_and_fix_hashes_verified": hashes,
"raw_diff_check_exit": whitespace.returncode,
"preserved_raw_trailing_whitespace_lines": len(raw_whitespace),
"docs_and_helpers_diff_check": "PASS",
"accepted_without_rerun": accepted,
"own_containers": [],
"retained_volumes": volumes,
"result": "PASS",
}
(FOLDER / "final-audit.json").write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n")
print(
json.dumps(
{k: v for k, v in report.items() if k not in {"changed_paths", "accepted_without_rerun"}},
ensure_ascii=False,
indent=2,
)
)
@@ -0,0 +1,25 @@
{
"head": "74c33160ac01618f70e9e1c6a121a5e45c3c7155",
"reviewed_runtime": "6096aa7948b8b666aa3892397a96d044a55f02c6",
"runtime_review_equal": true,
"runtime_diff_since_previous_validation": [
"src/messenger/attachments/infrastructure/images.py"
],
"previous_artifact_hashes_verified": 53,
"platform": "macOS-15.1-arm64-arm-64bit-Mach-O",
"host_load": [
1.66796875,
2.11279296875,
2.3447265625
],
"docker": "28.3.2 16 8217190400",
"running_containers_before": "",
"image_fixture_hashes": {
"rgb16-40mp.png": "3c4418a6f6a7676298b30b70ebbde9d12929f1345152f4fae979caf5ba1cb3f7",
"gray4-40mp.png": "64e665928c08ac3721324af4f8e2e9d2e98230dc1be389dde7bbf365650b08cd",
"gray2-40mp.png": "e1238de6a5be9dbce36abee904f7233f8ff7be59e405b528671940630cce11f6",
"gray16-40mp.png": "b59784ae916d50b41b15afa4bdd474a8699f099da55efd53580d3f97180f3800"
},
"fix_hashes_verified": 28,
"linux_http_variant_hashes_equal": 30
}
@@ -0,0 +1,90 @@
date: 2026-11-06T22:54:41Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ docker compose build
#1 [internal] load local bake definitions
#1 reading from stdin 441B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 1.65kB done
#2 DONE 0.0s
#3 [internal] load metadata for ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142
#3 DONE 0.0s
#4 [internal] load metadata for docker.io/library/python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d
#4 DONE 1.6s
#5 [internal] load .dockerignore
#5 transferring context: 453B done
#5 DONE 0.0s
#6 [builder 1/7] FROM docker.io/library/python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d
#6 resolve docker.io/library/python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d 0.0s done
#6 DONE 0.0s
#7 FROM ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142
#7 resolve ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 0.0s done
#7 DONE 0.0s
#8 [internal] load build context
#8 transferring context: 55.94kB 0.0s done
#8 DONE 0.0s
#9 [builder 4/7] COPY pyproject.toml uv.lock README.md ./
#9 CACHED
#10 [builder 3/7] WORKDIR /build
#10 CACHED
#11 [builder 2/7] COPY --from=ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 /uv /usr/local/bin/uv
#11 CACHED
#12 [builder 5/7] RUN uv sync --locked --no-dev --no-install-project --no-editable
#12 CACHED
#13 [builder 6/7] COPY src ./src
#13 DONE 0.1s
#14 [builder 7/7] RUN uv sync --locked --no-dev --no-editable
#14 0.246 Resolved 84 packages in 9ms
#14 0.261 Building mtusi-messenger @ file:///build
#14 3.076 Built mtusi-messenger @ file:///build
#14 3.081 Prepared 1 package in 2.82s
#14 3.086 Installed 1 package in 4ms
#14 3.306 Bytecode compiled 2301 files in 220ms
#14 3.306 + mtusi-messenger==1.5.0 (from file:///build)
#14 DONE 3.3s
#15 [runtime 2/6] RUN groupadd --system --gid 10001 messenger && useradd --system --uid 10001 --gid messenger --no-create-home --shell /usr/sbin/nologin messenger
#15 CACHED
#16 [runtime 3/6] COPY --from=builder --chown=root:root /opt/venv /opt/venv
#16 DONE 0.7s
#17 [runtime 4/6] WORKDIR /app
#17 DONE 0.0s
#18 [runtime 5/6] COPY --chown=root:root alembic.ini ./
#18 DONE 0.0s
#19 [runtime 6/6] COPY --chown=root:root alembic ./alembic
#19 DONE 0.0s
#20 exporting to image
#20 exporting layers
#20 exporting layers 3.1s done
#20 exporting manifest sha256:822ff6808de5ef24f7f560bfbf7d074f03882cf60f79ec17b72ec20b27fcb882
#20 exporting manifest sha256:822ff6808de5ef24f7f560bfbf7d074f03882cf60f79ec17b72ec20b27fcb882 done
#20 exporting config sha256:9ad245995fe138e23bc22e352d3a77ee0bf65ae6979997c6da067bd8d5315782 done
#20 exporting attestation manifest sha256:cf7e1da74a249e6859a38405addb0350aab512b93f6e62e66405ae1936db4e38 done
#20 exporting manifest list sha256:9a4299f2f673c414d67c3cc1f1debf4a56d9358f4a1ae85703152d48e8ef1608 done
#20 naming to docker.io/library/mtusi-messenger:lab5-memory-validation done
#20 unpacking to docker.io/library/mtusi-messenger:lab5-memory-validation
#20 unpacking to docker.io/library/mtusi-messenger:lab5-memory-validation 0.6s done
#20 DONE 3.8s
#21 resolving provenance for metadata file
#21 DONE 0.0s
api Built
exit_code: 0 elapsed_seconds: 14.282
@@ -0,0 +1,14 @@
date: 2026-11-06T22:54:42Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {}
$ make check validate lint
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
.venv/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
.venv/bin/ruff check src student-tests scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
All checks passed!
.venv/bin/ruff format --check src student-tests scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
198 files already formatted
.venv/bin/ty check src student-tests alembic
All checks passed!
exit_code: 0 elapsed_seconds: 0.650
@@ -0,0 +1,11 @@
{
"at": "2026-11-06T23:18:53.248018+00:00",
"host_load": [
6.40869140625,
4.1806640625,
3.1875
],
"running": "mtusi2026lab5-worker-1 Up About a minute (healthy)\nmtusi2026lab5-api-1 Up 6 minutes (healthy)\nmtusi2026lab5-api-2 Up 6 minutes (healthy)\nmtusi2026lab5-relay-1 Up 6 minutes (healthy)\nmtusi2026lab5-broker-1 Up 6 minutes (healthy)\nmtusi2026lab5-postgres-1 Up 6 minutes (healthy)\nmtusi2026lab5-lb-1 Up 6 minutes (healthy)\nmtusi2026lab5-s3-1 Up 6 minutes (healthy)\nmtusi2026lab5-valkey-1 Up 6 minutes (healthy)",
"worker_limits": "448\n30\n2",
"memory_events": "low 0\nhigh 0\nmax 0\noom 0\noom_kill 0\noom_group_kill 0"
}
@@ -0,0 +1,166 @@
{
"platform": "macOS-15.1-arm64-arm-64bit-Mach-O",
"host_load": [
2.62109375,
2.6455078125,
2.53076171875
],
"running": "mtusi2026lab5-api-1 Up 2 minutes (healthy)\nmtusi2026lab5-api-2 Up 2 minutes (healthy)\nmtusi2026lab5-worker-1 Up 2 minutes (healthy)\nmtusi2026lab5-relay-1 Up 2 minutes (healthy)\nmtusi2026lab5-broker-1 Up 2 minutes (healthy)\nmtusi2026lab5-postgres-1 Up 2 minutes (healthy)\nmtusi2026lab5-lb-1 Up 2 minutes (healthy)\nmtusi2026lab5-s3-1 Up 2 minutes (healthy)\nmtusi2026lab5-valkey-1 Up 2 minutes (healthy)",
"containers": [
{
"name": "/mtusi2026lab5-api-1",
"id": "d1dcbda238669764840b38a8b9cf22d889ffc356945e165f019c4814bb96553d",
"image": "sha256:9a4299f2f673c414d67c3cc1f1debf4a56d9358f4a1ae85703152d48e8ef1608",
"limits": {
"Memory": 536870912,
"NanoCpus": 1000000000,
"PortBindings": {}
},
"volumes": []
},
{
"name": "/mtusi2026lab5-api-2",
"id": "1eaf0fe05de650a1c2f7ced3e360aabbf8ad59566f40beefc2d745fa5277688e",
"image": "sha256:9a4299f2f673c414d67c3cc1f1debf4a56d9358f4a1ae85703152d48e8ef1608",
"limits": {
"Memory": 536870912,
"NanoCpus": 1000000000,
"PortBindings": {}
},
"volumes": []
},
{
"name": "/mtusi2026lab5-worker-1",
"id": "a9afb0e9cc245a54eb871ddd44fcf8661949789de59603ded5236b5f9e9f1d7c",
"image": "sha256:9a4299f2f673c414d67c3cc1f1debf4a56d9358f4a1ae85703152d48e8ef1608",
"limits": {
"Memory": 1073741824,
"NanoCpus": 2000000000,
"PortBindings": {}
},
"volumes": []
},
{
"name": "/mtusi2026lab5-relay-1",
"id": "63225b5eff8e1eb2870376c487b8925f9dbbe9bb8a636f4e2cdc12a24becf577",
"image": "sha256:9a4299f2f673c414d67c3cc1f1debf4a56d9358f4a1ae85703152d48e8ef1608",
"limits": {
"Memory": 201326592,
"NanoCpus": 500000000,
"PortBindings": {}
},
"volumes": []
},
{
"name": "/mtusi2026lab5-migrate-1",
"id": "34901a09ef7b837c6ce87116d2035d842762d2c86f8562cade96d3915a80e6f0",
"image": "sha256:9a4299f2f673c414d67c3cc1f1debf4a56d9358f4a1ae85703152d48e8ef1608",
"limits": {
"Memory": 268435456,
"NanoCpus": 500000000,
"PortBindings": {}
},
"volumes": []
},
{
"name": "/mtusi2026lab5-s3-init-1",
"id": "6e80e83ed5c5470bf22c5a9cd7c835788fbdff94f1f28f8649df6b667c153f89",
"image": "sha256:ab024bfebee49a750ce886b4c70963ccd9ddaa03f491704a90710641d7a26699",
"limits": {
"Memory": 67108864,
"NanoCpus": 500000000,
"PortBindings": {}
},
"volumes": []
},
{
"name": "/mtusi2026lab5-broker-1",
"id": "be1942ad69b426f8b7c9189b0209021b169c6c8d0ee633f302d6d659a4143377",
"image": "sha256:54ef5ff505352c1beef05a97ee9bd6ab95b3559a76629ba0119b1d63d8d6e4b2",
"limits": {
"Memory": 536870912,
"NanoCpus": 1000000000,
"PortBindings": {
"15672/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "25086"
}
]
}
},
"volumes": [
"mtusi2026lab5_broker-data"
]
},
{
"name": "/mtusi2026lab5-postgres-1",
"id": "a0b9f2742b9737ac0e32423d767438cab12af55a00cc1d68515ca9f07c2758ed",
"image": "sha256:266d3c257594e195b309ae9d1805e54c788f1d7b375f56bf6c367aac6c917e7b",
"limits": {
"Memory": 1073741824,
"NanoCpus": 2000000000,
"PortBindings": {}
},
"volumes": [
"mtusi2026lab5_pgdata"
]
},
{
"name": "/mtusi2026lab5-lb-1",
"id": "4ddcc75182e6044288c7a8c7bddca7b8c5fc6dab9b18c429e61ab1d292680111",
"image": "sha256:5893840576071e6217cd52ebdcc14f454c6f7a631056fa6f4e0f40d3cac4215b",
"limits": {
"Memory": 134217728,
"NanoCpus": 1000000000,
"PortBindings": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "18085"
}
],
"8404/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": "25085"
}
]
}
},
"volumes": []
},
{
"name": "/mtusi2026lab5-s3-1",
"id": "29b3e7c3a260f035ba99f5ce5f3e8a8b7077c56377b17e25503f16fb7fbad7c3",
"image": "sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2",
"limits": {
"Memory": 536870912,
"NanoCpus": 1000000000,
"PortBindings": {}
},
"volumes": [
"mtusi2026lab5_s3data"
]
},
{
"name": "/mtusi2026lab5-valkey-1",
"id": "647882797ca28a7e07453f00bd198433c80d8a8b8e7013279bc8954eafe11db6",
"image": "sha256:2602ace2be6569bc2bbb06f873776516ab9089821525be34f4305c67eb9db02a",
"limits": {
"Memory": 134217728,
"NanoCpus": 500000000,
"PortBindings": {}
},
"volumes": [
"mtusi2026lab5_valkeydata"
]
}
],
"fixture_sha256": {
"rgb16-40mp.png": "3c4418a6f6a7676298b30b70ebbde9d12929f1345152f4fae979caf5ba1cb3f7",
"gray4-40mp.png": "64e665928c08ac3721324af4f8e2e9d2e98230dc1be389dde7bbf365650b08cd",
"gray2-40mp.png": "e1238de6a5be9dbce36abee904f7233f8ff7be59e405b528671940630cce11f6",
"gray16-40mp.png": "b59784ae916d50b41b15afa4bdd474a8699f099da55efd53580d3f97180f3800"
}
}
@@ -0,0 +1,151 @@
{
"command": [
"docker",
"events",
"--since",
"2026-11-06T23:15:45Z",
"--until",
"2026-11-06T23:19:06.697928+00:00",
"--filter",
"type=container",
"--filter",
"label=com.docker.compose.project=mtusi2026lab5",
"--filter",
"event=stop",
"--filter",
"event=die",
"--filter",
"event=start",
"--format",
"{{json .}}"
],
"events": [
{
"timeNano": 1794007134212820139,
"id": "4ddcc75182e6044288c7a8c7bddca7b8c5fc6dab9b18c429e61ab1d292680111",
"action": "stop",
"name": "mtusi2026lab5-lb-1",
"exitCode": null
},
{
"timeNano": 1794007134214724139,
"id": "4ddcc75182e6044288c7a8c7bddca7b8c5fc6dab9b18c429e61ab1d292680111",
"action": "die",
"name": "mtusi2026lab5-lb-1",
"exitCode": "0"
},
{
"timeNano": 1794007134242785764,
"id": "63225b5eff8e1eb2870376c487b8925f9dbbe9bb8a636f4e2cdc12a24becf577",
"action": "stop",
"name": "mtusi2026lab5-relay-1",
"exitCode": null
},
{
"timeNano": 1794007134243810347,
"id": "63225b5eff8e1eb2870376c487b8925f9dbbe9bb8a636f4e2cdc12a24becf577",
"action": "die",
"name": "mtusi2026lab5-relay-1",
"exitCode": "0"
},
{
"timeNano": 1794007134261625889,
"id": "cb275ee9574b376bec77f26bdc24d2149568a272094f374b866d89d42b8067ce",
"action": "stop",
"name": "mtusi2026lab5-worker-1",
"exitCode": null
},
{
"timeNano": 1794007134263340222,
"id": "cb275ee9574b376bec77f26bdc24d2149568a272094f374b866d89d42b8067ce",
"action": "die",
"name": "mtusi2026lab5-worker-1",
"exitCode": "0"
},
{
"timeNano": 1794007135530081667,
"id": "be1942ad69b426f8b7c9189b0209021b169c6c8d0ee633f302d6d659a4143377",
"action": "stop",
"name": "mtusi2026lab5-broker-1",
"exitCode": null
},
{
"timeNano": 1794007135532395875,
"id": "be1942ad69b426f8b7c9189b0209021b169c6c8d0ee633f302d6d659a4143377",
"action": "die",
"name": "mtusi2026lab5-broker-1",
"exitCode": "0"
},
{
"timeNano": 1794007136578760167,
"id": "d1dcbda238669764840b38a8b9cf22d889ffc356945e165f019c4814bb96553d",
"action": "stop",
"name": "mtusi2026lab5-api-1",
"exitCode": null
},
{
"timeNano": 1794007136581296250,
"id": "d1dcbda238669764840b38a8b9cf22d889ffc356945e165f019c4814bb96553d",
"action": "die",
"name": "mtusi2026lab5-api-1",
"exitCode": "0"
},
{
"timeNano": 1794007136606883084,
"id": "1eaf0fe05de650a1c2f7ced3e360aabbf8ad59566f40beefc2d745fa5277688e",
"action": "stop",
"name": "mtusi2026lab5-api-2",
"exitCode": null
},
{
"timeNano": 1794007136610714375,
"id": "1eaf0fe05de650a1c2f7ced3e360aabbf8ad59566f40beefc2d745fa5277688e",
"action": "die",
"name": "mtusi2026lab5-api-2",
"exitCode": "0"
},
{
"timeNano": 1794007136730887167,
"id": "647882797ca28a7e07453f00bd198433c80d8a8b8e7013279bc8954eafe11db6",
"action": "stop",
"name": "mtusi2026lab5-valkey-1",
"exitCode": null
},
{
"timeNano": 1794007136732779084,
"id": "647882797ca28a7e07453f00bd198433c80d8a8b8e7013279bc8954eafe11db6",
"action": "die",
"name": "mtusi2026lab5-valkey-1",
"exitCode": "0"
},
{
"timeNano": 1794007136795874292,
"id": "a0b9f2742b9737ac0e32423d767438cab12af55a00cc1d68515ca9f07c2758ed",
"action": "stop",
"name": "mtusi2026lab5-postgres-1",
"exitCode": null
},
{
"timeNano": 1794007136796859125,
"id": "a0b9f2742b9737ac0e32423d767438cab12af55a00cc1d68515ca9f07c2758ed",
"action": "die",
"name": "mtusi2026lab5-postgres-1",
"exitCode": "0"
},
{
"timeNano": 1794007136819412875,
"id": "29b3e7c3a260f035ba99f5ce5f3e8a8b7077c56377b17e25503f16fb7fbad7c3",
"action": "stop",
"name": "mtusi2026lab5-s3-1",
"exitCode": null
},
{
"timeNano": 1794007136823326750,
"id": "29b3e7c3a260f035ba99f5ce5f3e8a8b7077c56377b17e25503f16fb7fbad7c3",
"action": "die",
"name": "mtusi2026lab5-s3-1",
"exitCode": "0"
}
],
"limitation": "Docker retains only the last 256 events; this is a partial retrospective snapshot."
}
@@ -0,0 +1,53 @@
date: 2026-11-06T23:18:53Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ make down
docker compose --profile bench --profile tools --profile reconcile down
Container mtusi2026lab5-relay-1 Stopping
Container mtusi2026lab5-lb-1 Stopping
Container mtusi2026lab5-api-2 Stopping
Container mtusi2026lab5-api-1 Stopping
Container mtusi2026lab5-worker-1 Stopping
Container mtusi2026lab5-lb-1 Stopped
Container mtusi2026lab5-lb-1 Removing
Container mtusi2026lab5-relay-1 Stopped
Container mtusi2026lab5-relay-1 Removing
Container mtusi2026lab5-lb-1 Removed
Container mtusi2026lab5-worker-1 Stopped
Container mtusi2026lab5-worker-1 Removing
Container mtusi2026lab5-relay-1 Removed
Container mtusi2026lab5-worker-1 Removed
Container mtusi2026lab5-broker-1 Stopping
Container mtusi2026lab5-broker-1 Stopped
Container mtusi2026lab5-broker-1 Removing
Container mtusi2026lab5-broker-1 Removed
Container mtusi2026lab5-api-1 Stopped
Container mtusi2026lab5-api-1 Removing
Container mtusi2026lab5-api-2 Stopped
Container mtusi2026lab5-api-2 Removing
Container mtusi2026lab5-api-1 Removed
Container mtusi2026lab5-api-2 Removed
Container mtusi2026lab5-valkey-1 Stopping
Container mtusi2026lab5-migrate-1 Stopping
Container mtusi2026lab5-s3-init-1 Stopping
Container mtusi2026lab5-migrate-1 Stopped
Container mtusi2026lab5-migrate-1 Removing
Container mtusi2026lab5-s3-init-1 Stopped
Container mtusi2026lab5-s3-init-1 Removing
Container mtusi2026lab5-migrate-1 Removed
Container mtusi2026lab5-postgres-1 Stopping
Container mtusi2026lab5-s3-init-1 Removed
Container mtusi2026lab5-s3-1 Stopping
Container mtusi2026lab5-valkey-1 Stopped
Container mtusi2026lab5-valkey-1 Removing
Container mtusi2026lab5-valkey-1 Removed
Container mtusi2026lab5-postgres-1 Stopped
Container mtusi2026lab5-postgres-1 Removing
Container mtusi2026lab5-s3-1 Stopped
Container mtusi2026lab5-s3-1 Removing
Container mtusi2026lab5-postgres-1 Removed
Container mtusi2026lab5-s3-1 Removed
Network mtusi2026lab5_edge Removing
Network mtusi2026lab5_backend Removing
Network mtusi2026lab5_backend Removed
Network mtusi2026lab5_edge Removed
exit_code: 0 elapsed_seconds: 3.356
@@ -0,0 +1,8 @@
export COMPOSE_PROJECT_NAME=mtusi2026lab5
export COMPOSE_FILE=compose.yaml
export API_IMAGE=mtusi-messenger:lab5-memory-validation
export LB_HTTP_PORT=18085
export LB_STATS_PORT=25085
export BROKER_MANAGEMENT_PORT=25086
export BASE_URL=http://127.0.0.1:18085
export NO_PROXY=localhost,127.0.0.1,::1
@@ -0,0 +1,100 @@
{
"measured_sha": "74c33160ac01618f70e9e1c6a121a5e45c3c7155",
"reviewed_runtime": "6096aa7948b8b666aa3892397a96d044a55f02c6",
"runtime_equal": true,
"normative_equal_to_upstream_main": true,
"changed_paths": [
"AGENTS.md",
"REPORT.md",
"evidence/README.md",
"evidence/final-memory-validation-2026-11-07/RESULTS.md",
"evidence/final-memory-validation-2026-11-07/active-changes.txt",
"evidence/final-memory-validation-2026-11-07/audit-files.py",
"evidence/final-memory-validation-2026-11-07/audit.json",
"evidence/final-memory-validation-2026-11-07/build.txt",
"evidence/final-memory-validation-2026-11-07/checks.txt",
"evidence/final-memory-validation-2026-11-07/conditions-after.json",
"evidence/final-memory-validation-2026-11-07/conditions.json",
"evidence/final-memory-validation-2026-11-07/container-events.json",
"evidence/final-memory-validation-2026-11-07/down.txt",
"evidence/final-memory-validation-2026-11-07/env.sh",
"evidence/final-memory-validation-2026-11-07/final-audit.json",
"evidence/final-memory-validation-2026-11-07/final-checks.txt",
"evidence/final-memory-validation-2026-11-07/final-containers.txt",
"evidence/final-memory-validation-2026-11-07/findings.json",
"evidence/final-memory-validation-2026-11-07/linux-child.py",
"evidence/final-memory-validation-2026-11-07/linux-runner.py",
"evidence/final-memory-validation-2026-11-07/linux.json",
"evidence/final-memory-validation-2026-11-07/linux.txt",
"evidence/final-memory-validation-2026-11-07/openspec.txt",
"evidence/final-memory-validation-2026-11-07/png-boundary.json",
"evidence/final-memory-validation-2026-11-07/png-boundary.txt",
"evidence/final-memory-validation-2026-11-07/png-http.json",
"evidence/final-memory-validation-2026-11-07/png-http.txt",
"evidence/final-memory-validation-2026-11-07/reset-worker-peak.txt",
"evidence/final-memory-validation-2026-11-07/retained-volumes.txt",
"evidence/final-memory-validation-2026-11-07/running-containers-after.txt",
"evidence/final-memory-validation-2026-11-07/runtime.txt",
"evidence/final-memory-validation-2026-11-07/scan-secrets.py",
"evidence/final-memory-validation-2026-11-07/secret-scan.json",
"evidence/final-memory-validation-2026-11-07/sha256.json",
"evidence/final-memory-validation-2026-11-07/smoke.txt",
"evidence/final-memory-validation-2026-11-07/stopped-containers.txt",
"evidence/final-memory-validation-2026-11-07/student-test.txt",
"evidence/final-memory-validation-2026-11-07/targeted.py",
"evidence/final-memory-validation-2026-11-07/up.txt",
"evidence/load-validation.md"
],
"local_links_verified": 208,
"tracked_json_parsed": 111,
"previous_and_fix_hashes_verified": 81,
"raw_diff_check_exit": 2,
"preserved_raw_trailing_whitespace_lines": 17,
"docs_and_helpers_diff_check": "PASS",
"accepted_without_rerun": [
{
"file": "evidence/forward-final-2026-11-06/level4.json",
"source_sha": "0e921116610d289716af0a40ec823376eb8bbcbc",
"scenarios": 17,
"invariants": 8
},
{
"file": "evidence/forward-final-2026-11-06/track-run1.json",
"source_sha": "0e921116610d289716af0a40ec823376eb8bbcbc",
"scenarios": 13,
"invariants": 8
},
{
"file": "evidence/forward-final-2026-11-06/track-run2.json",
"source_sha": "0e921116610d289716af0a40ec823376eb8bbcbc",
"scenarios": 13,
"invariants": 8
},
{
"file": "evidence/forward-final-2026-11-06/track-run3.json",
"source_sha": "0e921116610d289716af0a40ec823376eb8bbcbc",
"scenarios": 13,
"invariants": 8
},
{
"file": "evidence/final-validation-2026-11-07/postgres-outage-retry.json",
"source_sha": "b30e2f6a84419d1ca64525ffb40df92183cccaef",
"scenarios": 1,
"invariants": 8
},
{
"file": "evidence/final-validation-2026-11-07/delivery-targeted.json",
"source_sha": "b30e2f6a84419d1ca64525ffb40df92183cccaef",
"scenarios": 12,
"invariants": 8
}
],
"own_containers": [],
"retained_volumes": [
"mtusi2026lab5_broker-data",
"mtusi2026lab5_pgdata",
"mtusi2026lab5_s3data",
"mtusi2026lab5_valkeydata"
],
"result": "PASS"
}
@@ -0,0 +1,14 @@
date: 2026-11-06T23:23:20Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ make check validate lint
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
.venv/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
.venv/bin/ruff check src student-tests scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
All checks passed!
.venv/bin/ruff format --check src student-tests scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
198 files already formatted
.venv/bin/ty check src student-tests alembic
All checks passed!
exit_code: 0 elapsed_seconds: 0.530
@@ -0,0 +1,15 @@
date: 2026-11-06T23:18:53Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ docker compose ps -a --format '{{.Name}} {{.ID}} {{.State}} {{.Status}}'
mtusi2026lab5-api-1 d1dcbda23866 running Up 6 minutes (healthy)
mtusi2026lab5-api-2 1eaf0fe05de6 running Up 6 minutes (healthy)
mtusi2026lab5-broker-1 be1942ad69b4 running Up 6 minutes (healthy)
mtusi2026lab5-lb-1 4ddcc75182e6 running Up 6 minutes (healthy)
mtusi2026lab5-migrate-1 34901a09ef7b exited Exited (0) 6 minutes ago
mtusi2026lab5-postgres-1 a0b9f2742b97 running Up 6 minutes (healthy)
mtusi2026lab5-relay-1 63225b5eff8e running Up 6 minutes (healthy)
mtusi2026lab5-s3-1 29b3e7c3a260 running Up 6 minutes (healthy)
mtusi2026lab5-s3-init-1 6e80e83ed5c5 exited Exited (0) 6 minutes ago
mtusi2026lab5-valkey-1 647882797ca2 running Up 6 minutes (healthy)
mtusi2026lab5-worker-1 cb275ee9574b running Up About a minute (healthy)
exit_code: 0 elapsed_seconds: 0.127
@@ -0,0 +1,37 @@
[
{
"severity": "minor",
"file": "src/messenger/attachments/application/pipeline.py:230",
"problem": "Сохранено из ревью 544b9c78d39d0e9dd07f841894c390895896605a: after_publish_before_confirm вызывается после publish(), уже проверившего Basic.Ack. crash_publish_confirm доказывает сбой после confirm до COMMIT outbox, а не потерю подтверждения."
},
{
"severity": "minor",
"file": "scripts/limits.py:10",
"problem": "Сохранено из первого ревью: S3_CLIENT_SECRETS не отсортирован, сравнение с sorted(secrets) даёт ложные FAIL. evidence/sqlalchemy-2026-11-06/grade3/limits.txt содержит exit_code=1; этот запуск нельзя обозначать PASS."
},
{
"severity": "minor",
"file": "scripts/reconcile_track.py:396",
"problem": "Сохранено из первого ревью: демонстратор ожидает upload 201 и attachments/, поэтому непригоден для квалификации ЛР5 с 202 queued. Текущие pipeline evidence его не используют."
},
{
"severity": "minor",
"file": "src/messenger/attachments/application/pipeline.py:304",
"problem": "Сохранено из первого ревью: failed upgrade v2 при опубликованной ready v1 нельзя отдельно повторить через replay/reprocess. V1 остаётся доступной; подтверждение исходного ревью — test_failed_new_version_keeps_ready_original."
},
{
"severity": "minor",
"file": "evidence/forward-final-2026-11-06/clock-observation.json",
"problem": "Сохранено из первого ревью: в повторах 2/3 UTC-интервалы расходятся с elapsed (1161.195/186.458 с и 571.513/180.259 с). Причина не установлена; длительности исключены из выводов о производительности."
},
{
"severity": "minor",
"file": "openspec/config.yaml:130",
"problem": "Сохранена документационная неточность: design требует upload 201 вместо нормативного 202 ЛР5; конфиг вне scope validation."
},
{
"severity": "minor",
"file": "src/messenger/attachments/entrypoints/schemas.py:67",
"problem": "Независимое review M: attempt=\"1\", pipeline_version=true, числовой created_at и traceparent=null принимаются вне jobs.schema.json с bus/ack вместо reject. Штатный relay формирует корректные сообщения; критичного последствия не установлено. Источник: evidence/report-memory-audit-2026-11-07.md; повторные пробы в validation не выполнялись."
}
]
@@ -0,0 +1,58 @@
import hashlib
import json
import resource
import signal
import sys
import time
from io import BytesIO
from pathlib import Path
import messenger.worker
from PIL import Image
from messenger.attachments.infrastructure.images import RenderLimits, render_variants
resource.setrlimit(resource.RLIMIT_AS, (448 << 20, 448 << 20))
data = Path(sys.argv[1]).read_bytes()
transparent = sys.argv[3] == "true"
limits = RenderLimits(10485760, 40000000)
versions = []
for version in (1, 2):
signal.alarm(30)
began = time.monotonic()
variants = render_variants(data, limits, version)
ended = time.monotonic()
signal.alarm(0)
assert [(v.name, v.width, v.height) for v in variants] == [
("thumbnail", 256, 160),
("crop", 128, 128),
("optimized", 1280, 800),
]
for variant in variants:
with Image.open(BytesIO(variant.data)) as image:
assert (image.getpixel((5, image.height // 2)) == (255, 255, 255)) == transparent
assert image.getpixel((image.width - 6, image.height // 2)) != (255, 255, 255)
versions.append(
{
"version": version,
"started_monotonic": began,
"finished_monotonic": ended,
"render_seconds": ended - began,
"variants": {v.name: hashlib.sha256(v.data).hexdigest() for v in variants},
}
)
signal.alarm(30)
assert len(render_variants(Path(sys.argv[2]).read_bytes(), limits)) == 3
signal.alarm(0)
print(
json.dumps(
{
"file": Path(sys.argv[1]).name,
"input_sha256": hashlib.sha256(data).hexdigest(),
"versions": versions,
"ordinary_after": True,
"max_rss_kib": resource.getrusage(resource.RUSAGE_SELF).ru_maxrss,
"result": "PASS",
}
),
flush=True,
)
@@ -0,0 +1,89 @@
import base64
import hashlib
import json
import subprocess
from pathlib import Path
folder = Path(__file__).parent
fixtures = {
p.name: p.read_bytes()
for p in Path("evidence/final-validation-2026-11-07/fixtures").glob("*.png")
}
data = fixtures["gray16-40mp.png"]
result, offset = data[:8], 8
while offset < len(data):
size = int.from_bytes(data[offset : offset + 4], "big") + 12
if data[offset + 4 : offset + 8] != b"tRNS":
result += data[offset : offset + size]
offset += size
fixtures["gray16-opaque-40mp.png"] = result
fixtures["sample.png"] = Path("tests/fixtures/sample.png").read_bytes()
bootstrap = """
import base64,json,sys,subprocess,time
from pathlib import Path
p=json.load(sys.stdin)
d=Path('/tmp/png-memory-validation')
d.mkdir(exist_ok=True)
for name,data in p['fixtures'].items():
(d/name).write_bytes(base64.b64decode(data))
def command(name):
return [sys.executable,'-c',p['code'],str(d/name),str(d/'sample.png'),'false' if 'opaque' in name else 'true']
results=[]
for name in sorted(p['fixtures']):
if name=='sample.png':
continue
output=subprocess.check_output(command(name),text=True,timeout=65)
row=json.loads(output)
results.append(row)
print(json.dumps({'case':row}),flush=True)
children=[subprocess.Popen(command('rgb16-40mp.png'),stdout=subprocess.PIPE,stderr=subprocess.PIPE,text=True) for _ in range(2)]
parallel=[]
try:
for child in children:
out,err=child.communicate(timeout=65)
assert child.returncode==0,(child.returncode,err)
parallel.append(json.loads(out))
finally:
for child in children:
if child.poll() is None:
child.kill()
child.wait()
overlap=any(max(a['started_monotonic'],b['started_monotonic'])<min(a['finished_monotonic'],b['finished_monotonic']) for a in parallel[0]['versions'] for b in parallel[1]['versions'])
assert overlap
peak=int(Path('/sys/fs/cgroup/memory.peak').read_text())
limit=int(Path('/sys/fs/cgroup/memory.max').read_text())
assert peak<limit
print(json.dumps({'result':'PASS','cases':results,'concurrent':parallel,'render_overlap':overlap,'cgroup_peak':peak,'cgroup_limit':limit,'memory_events':Path('/sys/fs/cgroup/memory.events').read_text()}),flush=True)
"""
payload = {
"code": (folder / "linux-child.py").read_text(),
"fixtures": {name: base64.b64encode(data).decode() for name, data in fixtures.items()},
}
output = folder / "linux.json"
if output.exists():
raise SystemExit("Result exists; do not repeat completed evidence")
process = subprocess.Popen(
["docker", "compose", "exec", "-T", "worker", "python", "-c", bootstrap],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
)
process.stdin.write(json.dumps(payload))
process.stdin.close()
lines = []
for line in process.stdout:
print(line, end="", flush=True)
lines.append(line)
code = process.wait()
report = {
"source_sha": subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip(),
"exit_code": code,
"input_sha256": {name: hashlib.sha256(data).hexdigest() for name, data in fixtures.items()},
}
if code == 0:
report.update(json.loads(lines[-1]))
else:
report["result"] = "FAIL"
output.write_text(json.dumps(report, indent=2) + "\n")
raise SystemExit(code)
@@ -0,0 +1,238 @@
{
"source_sha": "74c33160ac01618f70e9e1c6a121a5e45c3c7155",
"exit_code": 0,
"input_sha256": {
"rgb16-40mp.png": "3c4418a6f6a7676298b30b70ebbde9d12929f1345152f4fae979caf5ba1cb3f7",
"gray4-40mp.png": "64e665928c08ac3721324af4f8e2e9d2e98230dc1be389dde7bbf365650b08cd",
"gray2-40mp.png": "e1238de6a5be9dbce36abee904f7233f8ff7be59e405b528671940630cce11f6",
"gray16-40mp.png": "b59784ae916d50b41b15afa4bdd474a8699f099da55efd53580d3f97180f3800",
"gray16-opaque-40mp.png": "e3f239d818da5f02cd7b5d1cc4a2c542ed4fc4a7fbc604598500e7810e246e2f",
"sample.png": "99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75"
},
"result": "PASS",
"cases": [
{
"file": "gray16-40mp.png",
"input_sha256": "b59784ae916d50b41b15afa4bdd474a8699f099da55efd53580d3f97180f3800",
"versions": [
{
"version": 1,
"started_monotonic": 192.032995711,
"finished_monotonic": 193.256173795,
"render_seconds": 1.2231780839999828,
"variants": {
"thumbnail": "99b591aa444566a5c425692f989a8cee8621615ec6aa7911e273e2c47f07d027",
"crop": "8ea8ec6f95dc1d1697327cd4640e59c2adce777564d349703df9f581dde2f450",
"optimized": "7667253d3e6bb37c83e75c2955705e4d5b97a7ee515df4aac5099c9ab3f97335"
}
},
{
"version": 2,
"started_monotonic": 193.258607545,
"finished_monotonic": 194.489094088,
"render_seconds": 1.230486543000012,
"variants": {
"thumbnail": "a17f036f331d17eb03302ddf06741e2f22a8da3394e85e122194fe45282de352",
"crop": "9de07bd2f684859366c50919650f159adc93f9027150de2f51cafac502794daf",
"optimized": "e9d888a5186c3f4824ef866fe97606e2d0a486a312551bfd571e02d2f509a4b7"
}
}
],
"ordinary_after": true,
"max_rss_kib": 365508,
"result": "PASS"
},
{
"file": "gray16-opaque-40mp.png",
"input_sha256": "e3f239d818da5f02cd7b5d1cc4a2c542ed4fc4a7fbc604598500e7810e246e2f",
"versions": [
{
"version": 1,
"started_monotonic": 195.17374863,
"finished_monotonic": 195.46179888,
"render_seconds": 0.28805024999999773,
"variants": {
"thumbnail": "59472ec8f914eb4502ffd2591a59ac68b05cccefeedc678f5ad2919cd2c6a3a2",
"crop": "91eed7d7e1f422bfc3827903cc6801a37387d642a1b4fcc08e23b2de4840a3d7",
"optimized": "c5216644c9e66c732de7523bef11b7024bf0417adb1d134d8f2ce259fd8b6ed1"
}
},
{
"version": 2,
"started_monotonic": 195.464219338,
"finished_monotonic": 195.744785005,
"render_seconds": 0.28056566700001895,
"variants": {
"thumbnail": "13ea6ae5bd526b8b0ad4e88ff72498ff48c6d50f8d12e81ad6773a1eaa9fc177",
"crop": "2d5dbe60802e4aa1c3ff20c112df454c70a12e2c9fccc99137802a5556e270bf",
"optimized": "38fc10be1e1f56da14304d26c52c11032900002c70de502ea1b7c1639535633e"
}
}
],
"ordinary_after": true,
"max_rss_kib": 365492,
"result": "PASS"
},
{
"file": "gray2-40mp.png",
"input_sha256": "e1238de6a5be9dbce36abee904f7233f8ff7be59e405b528671940630cce11f6",
"versions": [
{
"version": 1,
"started_monotonic": 196.461284589,
"finished_monotonic": 196.747503755,
"render_seconds": 0.2862191659999951,
"variants": {
"thumbnail": "ce63aabedb566aea34ad71f5a146f8dc8f0fd27c1f28f5ad1a28ffdf4630b053",
"crop": "43956a7b626be7786964c28ae7bf0cb96b2b914335a1b8129772c7bd88ee95ed",
"optimized": "059fb496f80d0ad3c73ea4d257f754b726f5d8dacfefd42ea7cedd6ff3368b24"
}
},
{
"version": 2,
"started_monotonic": 196.750391839,
"finished_monotonic": 197.01864788,
"render_seconds": 0.2682560410000008,
"variants": {
"thumbnail": "efb7970658ce2e7ed86bf5f3d5d695b81cd396e717d699fd9e69ffb294d5d870",
"crop": "cb1ce90bf86c1178ac5f0830e3d34ed54296a0e81231b422ba9f622dd22c7daa",
"optimized": "38dc2af32b8bbc1f15fbff2fcfeb5fa0d5ac6ed75225afc575e80254d2a54d0c"
}
}
],
"ordinary_after": true,
"max_rss_kib": 343076,
"result": "PASS"
},
{
"file": "gray4-40mp.png",
"input_sha256": "64e665928c08ac3721324af4f8e2e9d2e98230dc1be389dde7bbf365650b08cd",
"versions": [
{
"version": 1,
"started_monotonic": 197.695555797,
"finished_monotonic": 197.978069006,
"render_seconds": 0.2825132090000011,
"variants": {
"thumbnail": "9130484055a59c8c813ea7e48b32e27a3c424b4107ca4f872c8711ad34234610",
"crop": "c3bbbc98cc4a63ea0aab370b4e81bdc66a353a8ca7beb9c83a2c28af9f44b641",
"optimized": "e23b8d975b6973b848ba57cb68925d6f88156f44d9dcbe52d194e006e49dcefa"
}
},
{
"version": 2,
"started_monotonic": 197.980502798,
"finished_monotonic": 198.257521881,
"render_seconds": 0.277019082999999,
"variants": {
"thumbnail": "814c3cc7149871ae2614c4e71f9ffd35e86063bad1c8f94c2aeb5c0dacd516c3",
"crop": "beb44557013393b7c1a85b1df2fd74ffaf8bd32606092bad48c300b7d7a676fb",
"optimized": "b7a3cf6655e630458fb5341d7a79e742dafcf26590724a0440e3dfe82e4986f7"
}
}
],
"ordinary_after": true,
"max_rss_kib": 342956,
"result": "PASS"
},
{
"file": "rgb16-40mp.png",
"input_sha256": "3c4418a6f6a7676298b30b70ebbde9d12929f1345152f4fae979caf5ba1cb3f7",
"versions": [
{
"version": 1,
"started_monotonic": 198.959187048,
"finished_monotonic": 199.736227465,
"render_seconds": 0.7770404170000234,
"variants": {
"thumbnail": "be34d8832da928389bfebfc6c1f16a5f871bca150c4cfcb6480c28b9734038ec",
"crop": "8d4a59604fea3ea6ad475b5bb12c0c9fd30a48297bd1b7bd41ac1ee82105df96",
"optimized": "30e30ca074118f4fd00c1670bdfe93a03b083da861af109fe863f6baab4549af"
}
},
{
"version": 2,
"started_monotonic": 199.738488423,
"finished_monotonic": 200.507796924,
"render_seconds": 0.7693085009999834,
"variants": {
"thumbnail": "ec9b5fc973ee1c36c8bbb4f11fcc376a255a8a2b52067d958b57aeb272eb7f3d",
"crop": "6d73d731eff497a00f8535f705e4a2e79a376d08d559d9afeb8b815aa56a3bb2",
"optimized": "a1de31c50abed6c9309af3cd7bc4fcabdfefe8d38d2b6eb946f91e52cb69e687"
}
}
],
"ordinary_after": true,
"max_rss_kib": 406312,
"result": "PASS"
}
],
"concurrent": [
{
"file": "rgb16-40mp.png",
"input_sha256": "3c4418a6f6a7676298b30b70ebbde9d12929f1345152f4fae979caf5ba1cb3f7",
"versions": [
{
"version": 1,
"started_monotonic": 201.216312716,
"finished_monotonic": 202.037238716,
"render_seconds": 0.8209259999999858,
"variants": {
"thumbnail": "be34d8832da928389bfebfc6c1f16a5f871bca150c4cfcb6480c28b9734038ec",
"crop": "8d4a59604fea3ea6ad475b5bb12c0c9fd30a48297bd1b7bd41ac1ee82105df96",
"optimized": "30e30ca074118f4fd00c1670bdfe93a03b083da861af109fe863f6baab4549af"
}
},
{
"version": 2,
"started_monotonic": 202.0398138,
"finished_monotonic": 202.834078508,
"render_seconds": 0.7942647080000143,
"variants": {
"thumbnail": "ec9b5fc973ee1c36c8bbb4f11fcc376a255a8a2b52067d958b57aeb272eb7f3d",
"crop": "6d73d731eff497a00f8535f705e4a2e79a376d08d559d9afeb8b815aa56a3bb2",
"optimized": "a1de31c50abed6c9309af3cd7bc4fcabdfefe8d38d2b6eb946f91e52cb69e687"
}
}
],
"ordinary_after": true,
"max_rss_kib": 404584,
"result": "PASS"
},
{
"file": "rgb16-40mp.png",
"input_sha256": "3c4418a6f6a7676298b30b70ebbde9d12929f1345152f4fae979caf5ba1cb3f7",
"versions": [
{
"version": 1,
"started_monotonic": 201.216906382,
"finished_monotonic": 202.031220341,
"render_seconds": 0.8143139590000033,
"variants": {
"thumbnail": "be34d8832da928389bfebfc6c1f16a5f871bca150c4cfcb6480c28b9734038ec",
"crop": "8d4a59604fea3ea6ad475b5bb12c0c9fd30a48297bd1b7bd41ac1ee82105df96",
"optimized": "30e30ca074118f4fd00c1670bdfe93a03b083da861af109fe863f6baab4549af"
}
},
{
"version": 2,
"started_monotonic": 202.033759216,
"finished_monotonic": 202.824064842,
"render_seconds": 0.7903056260000199,
"variants": {
"thumbnail": "ec9b5fc973ee1c36c8bbb4f11fcc376a255a8a2b52067d958b57aeb272eb7f3d",
"crop": "6d73d731eff497a00f8535f705e4a2e79a376d08d559d9afeb8b815aa56a3bb2",
"optimized": "a1de31c50abed6c9309af3cd7bc4fcabdfefe8d38d2b6eb946f91e52cb69e687"
}
}
],
"ordinary_after": true,
"max_rss_kib": 404776,
"result": "PASS"
}
],
"render_overlap": true,
"cgroup_peak": 1026285568,
"cgroup_limit": 1073741824,
"memory_events": "low 0\nhigh 0\nmax 0\noom 0\noom_kill 0\noom_group_kill 0\n"
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,28 @@
date: 2026-11-06T22:54:43Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {}
$ openspec validate --all --strict
- Validating...
✓ spec/lab1-event-publication
✓ spec/lab1-messenger-chats
✓ spec/lab1-messenger-history
✓ spec/lab1-messenger-identity
✓ spec/lab1-service-operability
✓ spec/lab2-auth-sessions
✓ spec/lab2-dependency-failures
✓ spec/lab2-history-index
✓ spec/lab2-persistent-storage
✓ spec/lab2-session-cache
✓ spec/lab3-failover-operations
✓ spec/lab3-idempotent-messages
✓ spec/lab3-load-balancing
✓ spec/lab4-attachments
✓ spec/lab4-object-storage
✓ spec/lab4-storage-reconciler
✓ spec/lab4-upload-resilience
✓ spec/lab5-attachment-pipeline
✓ spec/lab5-image-variants
✓ spec/lab5-job-delivery
✓ spec/lab5-job-recovery
✓ spec/lab5-versioned-pipeline
Totals: 22 passed, 0 failed (22 items)
exit_code: 0 elapsed_seconds: 0.921
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,12 @@
date: 2026-11-06T23:15:49Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ .venv/bin/python evidence/final-memory-validation-2026-11-07/targeted.py png-boundary
gray2 PASS
gray4 PASS
gray16 PASS
rgb16 PASS
gray16-without-trns PASS
concurrent-rgb16 PASS
forced-timeout PASS
forced-memory PASS
exit_code: 0 elapsed_seconds: 95.742
@@ -0,0 +1,742 @@
{
"mode": "png-http",
"source_sha": "74c33160ac01618f70e9e1c6a121a5e45c3c7155",
"started_at": "2026-11-06T23:17:43.287659Z",
"cases": [
{
"name": "gray2",
"started_at": "2026-11-06T23:17:44.380294Z",
"observed": {
"attachment_id": "01a1b327-5f46-7727-8fb2-3d557bcfe643",
"input_sha256": "80754a3aa0c8a6014dc7a282b2009d49d064a5c02ed48e634d05d01c0aa3df6b",
"input_bytes": 189,
"versions": [
{
"version": 1,
"variants": [
{
"name": "crop",
"sha256": "def030bc04042aa23362c895a36b18d1d9748360df045decaf68eaeb0aa68deb",
"bytes": 1324,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "fd49dc2d33e7b7963cd8f8f6ef0f0b80117e2c4a7dfb4fd2ee79285e47ff789a",
"bytes": 98,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "1b6f714677aa69673da7ed9eefba73376b8df42eae70a3d91002d2aab7272d9e",
"bytes": 332,
"dimensions": [
64,
64
]
}
]
},
{
"version": 2,
"variants": [
{
"name": "crop",
"sha256": "d14b6cc6fe415bd8c4fef55402a4fb196bc4f39d493ee505d536594b28841697",
"bytes": 1489,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "c8f23e1adbf1add646f23531e270dc25d5108453d50947dec3e73700b0d6741f",
"bytes": 96,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "93107a3ba1a8aba475f8993dfb0d03658cef12a416c08a230653370921dcc00b",
"bytes": 335,
"dimensions": [
64,
64
]
}
]
}
],
"stale_and_duplicate_noop": true
},
"result": "PASS",
"elapsed_seconds": 4.395
},
{
"name": "gray4",
"started_at": "2026-11-06T23:17:48.776246Z",
"observed": {
"attachment_id": "01a1b327-706a-74da-b85b-267a032e36ab",
"input_sha256": "d0ed5b64b3b875be881dd286bedb7948fd06570f9ef1d2cfe41b665a838e426b",
"input_bytes": 263,
"versions": [
{
"version": 1,
"variants": [
{
"name": "crop",
"sha256": "43323e552e3c79e1a1688478d72c2ce370c21e55f1560958f9f6a225bc32f909",
"bytes": 1034,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "dbc0ec3736c18df42f26b8f396b2eb243a18c6a0f5b6bbef8bf4ff7e563032c3",
"bytes": 90,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "d594ebb80ca7939643379ba54392070444eb900ca40bec9c6beee75175fd81ab",
"bytes": 330,
"dimensions": [
64,
64
]
}
]
},
{
"version": 2,
"variants": [
{
"name": "crop",
"sha256": "16e27d4c1df7aac7185381a1f4c8c9cceb05647e98f941c41e38f4dfe4c5ec75",
"bytes": 1197,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "cd31de25056767d9050108c4475d4b72ccd1ab3c36c1c96159b104019e4e3493",
"bytes": 92,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "86afdaf8b40f77c2426ebf10c8d603535d75caa4fc720462be9acc43e39d4fbd",
"bytes": 330,
"dimensions": [
64,
64
]
}
]
}
],
"stale_and_duplicate_noop": true
},
"result": "PASS",
"elapsed_seconds": 4.114
},
{
"name": "rgb16",
"started_at": "2026-11-06T23:17:52.890838Z",
"observed": {
"attachment_id": "01a1b327-807d-7398-8d62-e5d3486f1e9c",
"input_sha256": "e8e5f64cf3a0312b17549aed29f062e3cb03d0c1bf327396c6a25c4b88dec89f",
"input_bytes": 724,
"versions": [
{
"version": 1,
"variants": [
{
"name": "crop",
"sha256": "6386114c3d0b89c4df88745eec318b5db1a779d488e1b08f34ac34138c7feb99",
"bytes": 671,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "fed7e1bf230e91296a5ea9a85b51d190152639bb2963b661f872029d852cc4ad",
"bytes": 94,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "af0a65a6596a0905a79403a9a6ef32a1301671a98ae3c8b5c3d6ced2d20a1009",
"bytes": 332,
"dimensions": [
64,
64
]
}
]
},
{
"version": 2,
"variants": [
{
"name": "crop",
"sha256": "dedcbac123226e3012a4dbd178b7aae7a7aba4f2c44c91be274c86804238b208",
"bytes": 696,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "bc09a1696563daae4385190d2c52afac8230e18fff4b5eba701a42f0facde043",
"bytes": 94,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "218bc7fd6fa995a3c4cf725016714408073699d13f39d0d364ffe3595856d272",
"bytes": 333,
"dimensions": [
64,
64
]
}
]
}
],
"stale_and_duplicate_noop": true
},
"result": "PASS",
"elapsed_seconds": 4.989
},
{
"name": "gray1",
"started_at": "2026-11-06T23:17:57.880356Z",
"observed": {
"attachment_id": "01a1b327-93fd-7099-8ab3-600c201aa01d",
"input_sha256": "1bf59ee41fbd12bf572ac294e0505cc00b904363dd479d643b43062199dd67e3",
"input_bytes": 154,
"versions": [
{
"version": 1,
"variants": [
{
"name": "crop",
"sha256": "1b88218fd7e3ff00d6fa3e4bb732411617126591b2b6837aecdcaef426327eda",
"bytes": 380,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "315ce3f53ac2012226bbeb906c7d37997a7f6fabb3d0ede23a797e66fe4b51ee",
"bytes": 66,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "c5745603d7848377a38bb5228f7817f5d4d4f5af26dadd7d3b2fb97b6a598a8e",
"bytes": 308,
"dimensions": [
64,
64
]
}
]
},
{
"version": 2,
"variants": [
{
"name": "crop",
"sha256": "45eac1bd54dba273142a01a3f01a1530787db5a9fe04aa2483862256dbf16132",
"bytes": 380,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "8c5e7cc56874d00f7d5731a6a89461b264ef4e3b450899b63f4608231180b5aa",
"bytes": 66,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "19305cfd18dc8f3e504d6ef5667ddd7be788836e16317dba5b2c6f590b6a2667",
"bytes": 308,
"dimensions": [
64,
64
]
}
]
}
],
"stale_and_duplicate_noop": true
},
"result": "PASS",
"elapsed_seconds": 3.969
},
{
"name": "gray8",
"started_at": "2026-11-06T23:18:01.850592Z",
"observed": {
"attachment_id": "01a1b327-a380-7186-b76d-46a83b6ad53f",
"input_sha256": "31cb54aacd9e1c324b14e38377f83a21d4084dc134aa3d3e1e5c40e3d9c5dd2f",
"input_bytes": 286,
"versions": [
{
"version": 1,
"variants": [
{
"name": "crop",
"sha256": "14a6e4afbe7e4cf766330007adda1c14168f16957f9409f402a8699a0e5de62f",
"bytes": 621,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "d35d7d59302099ea5fea9e91a405f4ebf8823aae1f53a59f88a09015619136fa",
"bytes": 74,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "d8fac3c82defab08dbb276681b1a7fb2545d883830dae5f965349474897373c7",
"bytes": 324,
"dimensions": [
64,
64
]
}
]
},
{
"version": 2,
"variants": [
{
"name": "crop",
"sha256": "dba34622f93edcd2d3449e217eb9605b1fac739c7c873a875af5d88d8e76bf2e",
"bytes": 637,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "3d4823a2da9971a444b16cf060be5f0b2b7a16bf50a26e7343283d48b562d105",
"bytes": 76,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "d9d4ed6ef383acdf227745e511acaffddf6e90c4f100d0f6ea117f5783581d29",
"bytes": 324,
"dimensions": [
64,
64
]
}
]
}
],
"stale_and_duplicate_noop": true
},
"result": "PASS",
"elapsed_seconds": 4.033
},
{
"name": "gray16",
"started_at": "2026-11-06T23:18:05.884188Z",
"observed": {
"attachment_id": "01a1b327-b349-7332-b73c-db1221023da8",
"input_sha256": "f7fbc2506997045f18891037f3cde42cf1e3b55461948f790779817317574f77",
"input_bytes": 344,
"versions": [
{
"version": 1,
"variants": [
{
"name": "crop",
"sha256": "e49a69181bafd0ebb4348db7030ad2cbf632b296a65f0ba05fe984b3d2b1ccdc",
"bytes": 632,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "751dc647784804af94b6cda23248840f73cab0cfe03227c4568b75195c00603a",
"bytes": 80,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "1bc87b25d02a179dc0cf5a883fb624fda094ba042ed9476c883ae1c12da6f1b6",
"bytes": 322,
"dimensions": [
64,
64
]
}
]
},
{
"version": 2,
"variants": [
{
"name": "crop",
"sha256": "a94faef9b08b5ab6ab239b6618c0e92b0ab92abca889acd714d6d9179dde90ef",
"bytes": 662,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "b22468814595a3ae63a9b326ed55fefb9a833a0e621be5f366b113ad6cf18a12",
"bytes": 72,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "d2267d9adb990db045e8c186737a4bdf66aa4e8d82d785c0bb3d8e87c34c5072",
"bytes": 323,
"dimensions": [
64,
64
]
}
]
}
],
"stale_and_duplicate_noop": true
},
"result": "PASS",
"elapsed_seconds": 4.099
},
{
"name": "rgb8",
"started_at": "2026-11-06T23:18:09.984254Z",
"observed": {
"attachment_id": "01a1b327-c34a-7194-8fbd-164055cfd3ef",
"input_sha256": "8c27c74500758b1a24ccc96261334265e304d55530780aefc7ef4a1109c11852",
"input_bytes": 385,
"versions": [
{
"version": 1,
"variants": [
{
"name": "crop",
"sha256": "c36bf54d185cfcf7abddd219a5e586e11b0c4d10007df5db55978f74ddcad2d0",
"bytes": 1069,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "7b78675ebd18218e82922e75072a801eea74b4d5f26cde2b5810407c86509b88",
"bytes": 116,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "f6e37a29401efe000eb8deb1490975d745f621f2ab229f4d85162945189e1791",
"bytes": 385,
"dimensions": [
64,
64
]
}
]
},
{
"version": 2,
"variants": [
{
"name": "crop",
"sha256": "fd82664e5924528cd7916b3b9e30b71517fa13c2763a8705e750fd4293f3027c",
"bytes": 1184,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "a05ef5a9f1305b2941cc99ab594eb3671bb87babe35d28ac97127791881137bb",
"bytes": 120,
"dimensions": [
64,
64
]
},
{
"name": "thumbnail",
"sha256": "3cac9f1ca274bcac1dc05cf186cd88eb622fd947fb1a7958a1175e77623a96d6",
"bytes": 392,
"dimensions": [
64,
64
]
}
]
}
],
"stale_and_duplicate_noop": true
},
"result": "PASS",
"elapsed_seconds": 3.994
},
{
"name": "rgb16-adam7-filter4-exif6",
"started_at": "2026-11-06T23:18:13.978929Z",
"observed": {
"attachment_id": "01a1b327-d2e9-72fc-9b7e-a5d8d6e2f8b7",
"input_sha256": "b9c1cb1e309024e4578d1f17bf6bb0f0645aad4d8973e16098b65c54cfd4930a",
"input_bytes": 1297,
"versions": [
{
"version": 1,
"variants": [
{
"name": "crop",
"sha256": "f257bf8fa4f30f0e4df6672de140799375cebd2bf735a656432cf702663414a1",
"bytes": 601,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "cb92af5a047068048eba212d944513edb2c454f64e124339820d46c24e69ea45",
"bytes": 112,
"dimensions": [
63,
65
]
},
{
"name": "thumbnail",
"sha256": "110cf7571f07d2db04821e8ef1861f74b5a16978851a4b0082ca60aedc1d29e4",
"bytes": 419,
"dimensions": [
63,
65
]
}
]
},
{
"version": 2,
"variants": [
{
"name": "crop",
"sha256": "0a7fea5640c5877026100e65e39848e7b15ee5eebb93897ebbeb95d441e8d652",
"bytes": 675,
"dimensions": [
128,
128
]
},
{
"name": "optimized",
"sha256": "9d4b7431a72adfc10284e4443c4e56b4cd19a67c0729979041fc8b0bc2c6ca34",
"bytes": 116,
"dimensions": [
63,
65
]
},
{
"name": "thumbnail",
"sha256": "529ceb55a8675e5ed870ed7917d7f1a5753c898b689f3e431e403b9b3682a732",
"bytes": 440,
"dimensions": [
63,
65
]
}
]
}
],
"stale_and_duplicate_noop": true
},
"result": "PASS",
"elapsed_seconds": 4.082
}
],
"conditions": {
"host_load": [
5.41796875,
3.67138671875,
2.95068359375
],
"containers": [
"mtusi2026lab5-api-1 d1dcbda23866 running Up 5 minutes (healthy)",
"mtusi2026lab5-api-2 1eaf0fe05de6 running Up 5 minutes (healthy)",
"mtusi2026lab5-broker-1 be1942ad69b4 running Up 5 minutes (healthy)",
"mtusi2026lab5-lb-1 4ddcc75182e6 running Up 5 minutes (healthy)",
"mtusi2026lab5-migrate-1 34901a09ef7b exited Exited (0) 5 minutes ago",
"mtusi2026lab5-postgres-1 a0b9f2742b97 running Up 5 minutes (healthy)",
"mtusi2026lab5-relay-1 63225b5eff8e running Up 5 minutes (healthy)",
"mtusi2026lab5-s3-1 29b3e7c3a260 running Up 5 minutes (healthy)",
"mtusi2026lab5-s3-init-1 6e80e83ed5c5 exited Exited (0) 5 minutes ago",
"mtusi2026lab5-valkey-1 647882797ca2 running Up 5 minutes (healthy)",
"mtusi2026lab5-worker-1 cb275ee9574b running Up 41 seconds (healthy)"
],
"running": "mtusi2026lab5-worker-1 Up 42 seconds (healthy)\nmtusi2026lab5-api-1 Up 5 minutes (healthy)\nmtusi2026lab5-api-2 Up 5 minutes (healthy)\nmtusi2026lab5-relay-1 Up 5 minutes (healthy)\nmtusi2026lab5-broker-1 Up 5 minutes (healthy)\nmtusi2026lab5-postgres-1 Up 5 minutes (healthy)\nmtusi2026lab5-lb-1 Up 5 minutes (healthy)\nmtusi2026lab5-s3-1 Up 5 minutes (healthy)\nmtusi2026lab5-valkey-1 Up 5 minutes (healthy)\n",
"worker_limits": "448\n30\n2\n"
},
"accepted_ids": [
"01a1b327-5f46-7727-8fb2-3d557bcfe643",
"01a1b327-706a-74da-b85b-267a032e36ab",
"01a1b327-807d-7398-8d62-e5d3486f1e9c",
"01a1b327-93fd-7099-8ab3-600c201aa01d",
"01a1b327-a380-7186-b76d-46a83b6ad53f",
"01a1b327-b349-7332-b73c-db1221023da8",
"01a1b327-c34a-7194-8fbd-164055cfd3ef",
"01a1b327-d2e9-72fc-9b7e-a5d8d6e2f8b7"
],
"invariants": [
{
"id": "terminal",
"statement": "every 202 reaches its expected terminal state",
"result": "PASS",
"details": {
"accepted": 8
}
},
{
"id": "single_effect",
"statement": "one variant set per (attachment_id, pipeline_version, variant)",
"result": "PASS",
"details": {
"rows": 0
}
},
{
"id": "no_ready_rollback",
"statement": "ready never returns to queued or processing",
"result": "PASS",
"details": {
"traced": 8
}
},
{
"id": "monotonic_publication",
"statement": "published_version only moves forward",
"result": "PASS",
"details": {
"sampled": 8
}
},
{
"id": "bytes_match_metadata",
"statement": "sha256, size and real dimensions match served bytes",
"result": "PASS",
"details": {
"verified": 8
}
},
{
"id": "bounded_attempts",
"statement": "attempt <= JOB_MAX_ATTEMPTS",
"result": "PASS",
"details": {
"rows": 0
}
},
{
"id": "no_orphans",
"statement": "no pending outbox, messages, dead letters, staging, objects",
"result": "PASS",
"details": {
"queues": {
"attachments.process": [
0,
0
],
"attachments.process.dlq": [
16,
0
]
},
"s3_objects": 56,
"scoped_attachments": 8
}
},
{
"id": "no_lost_202",
"statement": "every 202 is present in PostgreSQL and the API",
"result": "PASS",
"details": {
"accepted": 8
}
}
],
"finished_at": "2026-11-06T23:18:30.279606Z",
"result": "PASS"
}
@@ -0,0 +1,12 @@
date: 2026-11-06T23:17:43Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ .venv/bin/python evidence/final-memory-validation-2026-11-07/targeted.py png-http
gray2 PASS
gray4 PASS
rgb16 PASS
gray1 PASS
gray8 PASS
gray16 PASS
rgb8 PASS
rgb16-adam7-filter4-exif6 PASS
exit_code: 0 elapsed_seconds: 47.160
@@ -0,0 +1,10 @@
date: 2026-11-06T23:15:46Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ docker compose up -d --no-deps --force-recreate --wait worker
Container mtusi2026lab5-worker-1 Recreate
Container mtusi2026lab5-worker-1 Recreated
Container mtusi2026lab5-worker-1 Starting
Container mtusi2026lab5-worker-1 Started
Container mtusi2026lab5-worker-1 Waiting
Container mtusi2026lab5-worker-1 Healthy
exit_code: 0 elapsed_seconds: 3.133
@@ -0,0 +1,8 @@
date: 2026-11-06T23:19:15Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ docker volume ls --filter label=com.docker.compose.project=mtusi2026lab5 --format '{{.Name}}'
mtusi2026lab5_broker-data
mtusi2026lab5_pgdata
mtusi2026lab5_s3data
mtusi2026lab5_valkeydata
exit_code: 0 elapsed_seconds: 0.024
@@ -0,0 +1,4 @@
date: 2026-11-06T23:19:15Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ docker ps --format '{{.Names}} {{.Status}}'
exit_code: 0 elapsed_seconds: 0.024
@@ -0,0 +1,7 @@
date: 2026-11-06T23:15:05Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ docker compose exec -T worker python -c 'import hashlib,platform,importlib.metadata; from pathlib import Path; import messenger.attachments.infrastructure.images as m; print(platform.platform()); print({name:importlib.metadata.version(name) for name in ("sqlalchemy","alembic","Pillow","faststream","aio-pika")}); print("images.py sha256",hashlib.sha256(Path(m.__file__).read_bytes()).hexdigest())'
Linux-6.10.14-linuxkit-aarch64-with-glibc2.41
{'sqlalchemy': '2.0.45', 'alembic': '1.16.5', 'Pillow': '13.0.0', 'faststream': '0.7.8', 'aio-pika': '10.2.1'}
images.py sha256 97c6e9c1ef13c8854be9cd2cc11e4279d1d340ba3ab360dfa3e05772923ea743
exit_code: 0 elapsed_seconds: 0.380
@@ -0,0 +1,63 @@
import json
import re
import subprocess
from pathlib import Path
ROOT = Path.cwd()
files = set(subprocess.check_output(["git", "ls-files", "-z"]).decode().split("\0")) - {""}
files.update(
str(p) for p in Path("evidence/final-memory-validation-2026-11-07").rglob("*") if p.is_file()
)
patterns = {
"private_key": r"-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----",
"github_token": r"\b(?:gh[pousr]_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{50,})\b",
"openai_token": r"\bsk-(?:proj-)?[A-Za-z0-9_-]{35,}\b",
"aws_key": r"\b(?:AKIA|ASIA)[A-Z0-9]{16}\b",
"telegram_token": r"\b[0-9]{8,12}:[A-Za-z0-9_-]{35}\b",
"bearer_literal": r"Bearer [A-Za-z0-9_-]{24,}",
"credential_url": r"\b(?:amqps?|postgres(?:ql)?|redis|https?)://[^\s\"\'{}$<>:/]+:[^\s\"\'{}$<>@/]+@",
"secret_literal": r"""["'](?:password|secret|token|access_token|secret_access_key)["']\s*:\s*["'][A-Za-z0-9_+/=-]{24,}["']""",
}
allow = {
("contracts/examples.json", 5, "secret_literal"): "unchanged skeleton example placeholder",
("contracts/openapi.json", 3096, "secret_literal"): "unchanged skeleton example placeholder",
("examples/requests.http", 20, "secret_literal"): "unchanged skeleton example placeholder",
("scripts/broker-secrets.sh", 17, "credential_url"): "printf format; no credential literal",
(
"student-tests/api/test_operability.py",
131,
"credential_url",
): "synthetic unavailable endpoint u:p",
(
"student-tests/api/test_operability.py",
143,
"credential_url",
): "synthetic unavailable endpoint u:p",
("student-tests/conftest.py", 141, "credential_url"): "ephemeral test database literal",
}
findings = []
for name in sorted(files):
if re.search(r"(^|/)(?:\.env|secrets|volumes)(?:/|$)", name):
findings.append({"file": name, "rule": "forbidden_path"})
try:
text = Path(name).read_text()
except UnicodeDecodeError, OSError:
continue
for rule, pattern in patterns.items():
for match in re.finditer(pattern, text):
line = text.count("\n", 0, match.start()) + 1
item = {"file": name, "line": line, "rule": rule}
if (name, line, rule) in allow:
item["reviewed_non_secret"] = allow[name, line, rule]
findings.append(item)
report = {
"files_scanned": len(files),
"patterns": list(patterns),
"candidates": findings,
"unresolved": sum("reviewed_non_secret" not in f for f in findings),
}
Path("evidence/final-memory-validation-2026-11-07/secret-scan.json").write_text(
json.dumps(report, indent=2) + "\n"
)
print(json.dumps(report, indent=2))
raise SystemExit(bool(report["unresolved"]))
@@ -0,0 +1,58 @@
{
"files_scanned": 804,
"patterns": [
"private_key",
"github_token",
"openai_token",
"aws_key",
"telegram_token",
"bearer_literal",
"credential_url",
"secret_literal"
],
"candidates": [
{
"file": "contracts/examples.json",
"line": 5,
"rule": "secret_literal",
"reviewed_non_secret": "unchanged skeleton example placeholder"
},
{
"file": "contracts/openapi.json",
"line": 3096,
"rule": "secret_literal",
"reviewed_non_secret": "unchanged skeleton example placeholder"
},
{
"file": "examples/requests.http",
"line": 20,
"rule": "secret_literal",
"reviewed_non_secret": "unchanged skeleton example placeholder"
},
{
"file": "scripts/broker-secrets.sh",
"line": 17,
"rule": "credential_url",
"reviewed_non_secret": "printf format; no credential literal"
},
{
"file": "student-tests/api/test_operability.py",
"line": 131,
"rule": "credential_url",
"reviewed_non_secret": "synthetic unavailable endpoint u:p"
},
{
"file": "student-tests/api/test_operability.py",
"line": 143,
"rule": "credential_url",
"reviewed_non_secret": "synthetic unavailable endpoint u:p"
},
{
"file": "student-tests/conftest.py",
"line": 141,
"rule": "credential_url",
"reviewed_non_secret": "ephemeral test database literal"
}
],
"unresolved": 0
}
@@ -0,0 +1,37 @@
{
"evidence/final-memory-validation-2026-11-07/RESULTS.md": "e4dd4dfc47ae8095458028235b1e89373b815edeeceddbd09f116f9ad9f4450b",
"evidence/final-memory-validation-2026-11-07/active-changes.txt": "b817c4f054d652d43cc5b0059aa3808fe18d4a4582a3676c34f0d9418efa992d",
"evidence/final-memory-validation-2026-11-07/audit-files.py": "864e3a7032755da30afeef71431649e87c955cea4dc48021c14575b5ac243ded",
"evidence/final-memory-validation-2026-11-07/audit.json": "68e3f1a5806fe4b65f1e8e8efe0b66c5e55cccd4ce492b7a325d4cc89323ca69",
"evidence/final-memory-validation-2026-11-07/build.txt": "62ca4051248a5ba0c1d5380456dc972572da8c08e27b840992b24f500ab57bb7",
"evidence/final-memory-validation-2026-11-07/checks.txt": "6a1195478b3eb211d21352cb6ed00e690196ccc54e0db3a3fe3ac4e5f6b19336",
"evidence/final-memory-validation-2026-11-07/conditions-after.json": "e72877504561b2e4ab95ffa5ad2e616ff3599ba0887fd10b378f9425cf62376c",
"evidence/final-memory-validation-2026-11-07/conditions.json": "c970c484ad92ada00d33f4df86113928b0ef0321b1b7740441a8c1e10f4b5c30",
"evidence/final-memory-validation-2026-11-07/container-events.json": "bfce3b6295e23ea06f4f29beb1b83b4a5b2ec5e07c4230d3ba68d1dc0c241d39",
"evidence/final-memory-validation-2026-11-07/down.txt": "0b80c02939c9224df3e8f5f98ae6320b6ffc71a8a28c001e7b3ee9ae113a6f39",
"evidence/final-memory-validation-2026-11-07/env.sh": "fa41c289402a362827d3edc88bd0e8301e55d279df09f658f800a94bff96b05d",
"evidence/final-memory-validation-2026-11-07/final-audit.json": "2c6308899417e6da60875de9c262828fe7caccd30bffb223d8ce53635f5845ad",
"evidence/final-memory-validation-2026-11-07/final-checks.txt": "7405e049b92aa01667afe431a64e3c6d5ffc1827c03a4bed480a5158802a08d8",
"evidence/final-memory-validation-2026-11-07/final-containers.txt": "dd5432219d35baeee61392605910c2864b71b83e8972377254eff268670422c5",
"evidence/final-memory-validation-2026-11-07/findings.json": "a2b9cc2a425aa0326fd72c6bdab9a5dc69ea4d90fef2c3ce239fbbb514e978a1",
"evidence/final-memory-validation-2026-11-07/linux-child.py": "c293f49bd273fe7c3c6bb0ac90f2ccb28a02117a4fdae758d04e8c006d4e89ab",
"evidence/final-memory-validation-2026-11-07/linux-runner.py": "680052df464d87d97a9717469d53d27f4f2391f740b0aaa23fa52a77a52c9a83",
"evidence/final-memory-validation-2026-11-07/linux.json": "febd60518391e7d6f479908e48856a6c0a774fd5763f33cf02655e414d6b1fe3",
"evidence/final-memory-validation-2026-11-07/linux.txt": "51f31e560852514bdba1777db1ceade9284ff13610d60afaf7a128f171cd7b29",
"evidence/final-memory-validation-2026-11-07/openspec.txt": "dc82d21ab66012b5960a0f76e82eef10d7df082497119d18efb7aed5009efd3d",
"evidence/final-memory-validation-2026-11-07/png-boundary.json": "a6452fb7b502597058641878464ee383eab334b0d77377bfe54565aeb4279df1",
"evidence/final-memory-validation-2026-11-07/png-boundary.txt": "1aba30dc29b1bae3f7e1d8fb64a7e331effb85fa45a2f3a123ddbe7dd743c6ad",
"evidence/final-memory-validation-2026-11-07/png-http.json": "0dab50ef2d4ed22425d27ccdefaac316ed4b8c7b0a759c2c616eb9239ebba618",
"evidence/final-memory-validation-2026-11-07/png-http.txt": "68ae6e09e67a9df204f0346ebec3b9b185bcf2c67a0a0946aff620408ba867a2",
"evidence/final-memory-validation-2026-11-07/reset-worker-peak.txt": "97c9b5d430649b61f83fb7904414690f50e742b0b53e39c9b4324d60c1b6b2f9",
"evidence/final-memory-validation-2026-11-07/retained-volumes.txt": "27347d997d6f8466d94b0a5bb06350f183c5e30ef9ad2c3858cdc24a316bf5e4",
"evidence/final-memory-validation-2026-11-07/running-containers-after.txt": "44b284098615df613f91d9bc745f236f6ede62f1ea95a9de06e10ed712ffb799",
"evidence/final-memory-validation-2026-11-07/runtime.txt": "1f35a3f37a7e4d4689c8154384b08c9800077d4f77251d576f03921605a28b2e",
"evidence/final-memory-validation-2026-11-07/scan-secrets.py": "27130687bae2d636d9780759559524b347ec3733aa2df722c837378f2d2f39b1",
"evidence/final-memory-validation-2026-11-07/secret-scan.json": "27f7763fd6af6a10d3ddd0c8ae0a3f71dcad4eeb000afa5af5379bb646fb8e30",
"evidence/final-memory-validation-2026-11-07/smoke.txt": "ba0b81113210431ecfe0a085024efd650b4963e1eaf21b2837f6163523a70afc",
"evidence/final-memory-validation-2026-11-07/stopped-containers.txt": "f543710a6a0f639673d62148635409ecec6bea71c8987dc036017d4692505bed",
"evidence/final-memory-validation-2026-11-07/student-test.txt": "1cf669fbca4aee91e87e74089522325f7214ad6406c031013a73c8b935593ac1",
"evidence/final-memory-validation-2026-11-07/targeted.py": "cba7c461fded4eb88247f113a2328780fe985a3c1bdc27a26df47277a2374ffc",
"evidence/final-memory-validation-2026-11-07/up.txt": "1fd736cd42363f734649be3011f92abee46bc9210b4fd513aa2daba9d5f4a666"
}
@@ -0,0 +1,6 @@
date: 2026-11-06T23:15:03Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ make test
python3 tests/smoke.py --base-url "http://127.0.0.1:18085"
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
exit_code: 0 elapsed_seconds: 1.706
@@ -0,0 +1,4 @@
date: 2026-11-06T23:19:15Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ docker ps -a --filter label=com.docker.compose.project=mtusi2026lab5 --format '{{.Names}} {{.State}}'
exit_code: 0 elapsed_seconds: 0.028
@@ -0,0 +1,20 @@
date: 2026-11-06T22:54:40Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ make student-test 'PYTEST_ARGS=-q --tb=short'
.venv/bin/pytest -q --tb=short
........................................................................ [ 7%]
........................................................................ [ 14%]
........................................................................ [ 21%]
........................................................................ [ 29%]
........................................................................ [ 36%]
........................................................................ [ 43%]
........................................................................ [ 51%]
........................................................................ [ 58%]
........................................................................ [ 65%]
........................................................................ [ 73%]
........................................s............................... [ 80%]
........................................................................ [ 87%]
......................................................................s. [ 94%]
.................................................. [100%]
984 passed, 2 skipped, 19 deselected in 171.26s (0:02:51)
exit_code: 0 elapsed_seconds: 172.902
@@ -0,0 +1,310 @@
import hashlib
import json
import os
import struct
import sys
import time
from io import BytesIO
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
sys.path[:0] = [str(ROOT / "scripts"), str(ROOT / "student-tests")]
import pipeline_suite as ps
from PIL import Image
from messenger.attachments.infrastructure.images import RenderLimits, render_variants
from png_trns_fixtures import png_with_trns
MODE = sys.argv.pop(1)
OUT = Path(__file__).parent / (MODE + ".json")
if OUT.exists():
raise SystemExit("Result exists; do not repeat completed evidence")
SUITE = ps.Suite(ps.arguments())
STACK = SUITE.stack
REPORT = {
"mode": MODE,
"source_sha": ps.run(["git", "rev-parse", "HEAD"]).strip(),
"started_at": ps.now(),
"cases": [],
}
LIMITS = RenderLimits(10485760, 40000000)
def save():
REPORT["accepted_ids"] = SUITE.api.accepted if SUITE.api else []
OUT.write_text(json.dumps(REPORT, ensure_ascii=False, indent=2) + "\n")
def case(name, function):
row = {"name": name, "started_at": ps.now()}
REPORT["cases"].append(row)
save()
began = time.monotonic()
try:
row["observed"] = function()
row["result"] = "PASS"
except Exception as error:
row.update(result="FAIL", error=str(error))
row["elapsed_seconds"] = round(time.monotonic() - began, 3)
save()
print(name, row["result"], row.get("error", ""), flush=True)
def containers():
return STACK.dc("ps", "-a", "--format", "{{.Name}} {{.ID}} {{.State}} {{.Status}}").splitlines()
def png(name, data, reference):
att = SUITE.api.upload(data, name=name + ".png")
ident = att["id"]
results = []
for version in (1, 2):
if version == 2:
STACK.admin("reprocess", "--attachment-id", ident, "--pipeline-version", "2")
ps.poll(lambda: SUITE.record(ident)["published_version"] == 2, 90, "published v2")
ready = SUITE.api.wait(ident)
SUITE.verify(ready)
assert SUITE.api.content(ident)["bytes"] == data
expected = {r.name: r for r in render_variants(reference, LIMITS, version)}
variants = []
for variant in ready["variants"]:
content = SUITE.api.content(ident, variant["name"])["bytes"]
assert content == expected[variant["name"]].data, (
variant["name"] + " differs from independent white reference"
)
with Image.open(BytesIO(content)) as image:
assert not image.getexif()
assert not any(key in image.info for key in ("icc_profile", "xmp", "transparency"))
variants.append(
{
"name": variant["name"],
"sha256": hashlib.sha256(content).hexdigest(),
"bytes": len(content),
"dimensions": [variant["width"], variant["height"]],
}
)
results.append({"version": version, "variants": variants})
before = SUITE.snapshot(ident)
STACK.publish(SUITE.payload(ident, 1))
STACK.publish(SUITE.payload(ident, 2))
SUITE.drained()
assert SUITE.snapshot(ident) == before
assert len(STACK.sql("variants", id=ident)) == 6
return {
"attachment_id": ident,
"input_sha256": hashlib.sha256(data).hexdigest(),
"input_bytes": len(data),
"versions": results,
"stale_and_duplicate_noop": True,
}
FIXTURES = ROOT / "evidence/final-validation-2026-11-07/fixtures"
ps.SQL["timed_events"] = (
"SELECT attachment_id,job_id,kind,at FROM job_events WHERE attachment_id = ANY(:'ids'::uuid[]) AND kind IN ('claimed','done') ORDER BY id"
)
def without_trns(data):
result, offset = data[:8], 8
while offset < len(data):
size = struct.unpack(">I", data[offset : offset + 4])[0] + 12
if data[offset + 4 : offset + 8] != b"tRNS":
result += data[offset : offset + size]
offset += size
return result
def verify_large(ident, data, transparent):
ready = SUITE.api.wait(ident)
SUITE.verify(ready)
assert SUITE.api.content(ident)["bytes"] == data
variants = []
for variant in ready["variants"]:
content = SUITE.api.content(ident, variant["name"])["bytes"]
with Image.open(BytesIO(content)) as image:
left = image.getpixel((5, image.height // 2))
right = image.getpixel((image.width - 6, image.height // 2))
assert (left == (255, 255, 255)) == transparent
assert right != (255, 255, 255)
assert not image.getexif()
variants.append({**variant, "left_pixel": left, "right_pixel": right})
return variants
def duplicate_check(ident):
before = SUITE.snapshot(ident)
STACK.publish(SUITE.payload(ident, 1))
STACK.publish(SUITE.payload(ident, 2))
SUITE.drained()
assert SUITE.snapshot(ident) == before
assert len(STACK.sql("variants", id=ident)) == 6
def large(name, data, transparent=True):
att = SUITE.api.upload(data, name=name + ".png")
ident = att["id"]
versions = [{"version": 1, "variants": verify_large(ident, data, transparent)}]
STACK.admin("reprocess", "--attachment-id", ident, "--pipeline-version", "2")
ps.poll(lambda: SUITE.record(ident)["published_version"] == 2, 90, "v2 publication")
versions.append({"version": 2, "variants": verify_large(ident, data, transparent)})
duplicate_check(ident)
return {
"attachment_id": ident,
"input_sha256": hashlib.sha256(data).hexdigest(),
"bytes": len(data),
"versions": versions,
"memory_peak": int(STACK.cgroup("worker", "memory.peak")),
"memory_max": int(STACK.cgroup("worker", "memory.max")),
}
def concurrent():
data = (FIXTURES / "rgb16-40mp.png").read_bytes()
SUITE.drained()
STACK.stop("worker")
try:
ids = [SUITE.api.upload(data, name="concurrent-rgb16.png")["id"] for _ in range(2)]
SUITE.queued(2)
finally:
ps.run(["docker", "start", STACK.dc("ps", "-aq", "worker").strip()])
versions = []
for version in (1, 2):
if version == 2:
STACK.stop("worker")
try:
for ident in ids:
STACK.admin("reprocess", "--attachment-id", ident, "--pipeline-version", "2")
SUITE.queued(2)
finally:
ps.run(["docker", "start", STACK.dc("ps", "-aq", "worker").strip()])
for ident in ids:
ps.poll(
lambda: SUITE.record(ident)["published_version"] == version,
90,
"concurrent publication",
)
variants = {ident: verify_large(ident, data, True) for ident in ids}
events = STACK.sql("timed_events", ids="{" + ",".join(ids) + "}")
job_ids = {
row["job_id"]
for ident in ids
for row in STACK.sql("jobs", id=ident)
if row["pipeline_version"] == version
}
selected = [e for e in events if e["job_id"] in job_ids]
claims = [e["at"] for e in selected if e["kind"] == "claimed"]
done = [e["at"] for e in selected if e["kind"] == "done"]
assert len(claims) == len(done) == 2
assert max(claims) < min(done), selected
versions.append(
{
"version": version,
"events": selected,
"processing_overlapped": True,
"variants": variants,
}
)
for ident in ids:
duplicate_check(ident)
peak, limit = (int(STACK.cgroup("worker", name)) for name in ("memory.peak", "memory.max"))
assert peak < limit
return {
"attachment_ids": ids,
"versions": versions,
"memory_peak": peak,
"memory_max": limit,
"memory_events": STACK.cgroup("worker", "memory.events"),
}
def forced(name, **overrides):
data = (FIXTURES / "rgb16-40mp.png").read_bytes()
result = SUITE.limited(data, **overrides)
STACK.restore()
result["next_normal"] = SUITE.smoke_pipeline()
return result
try:
SUITE.detect_api()
SUITE.api = ps.Api(SUITE.args)
dead_before = STACK.queues()[ps.DLQ][0]
REPORT["conditions"] = {
"host_load": os.getloadavg(),
"containers": containers(),
"running": ps.run(["docker", "ps", "--format", "{{.Names}} {{.Status}}"]),
"worker_limits": STACK.dc(
"exec",
"-T",
"worker",
"printenv",
"RENDER_MEMORY_MB",
"RENDER_TIMEOUT_SECONDS",
"WORKER_CONCURRENCY",
),
}
save()
if MODE == "png-http":
folder = ROOT / "evidence/review-trns-depth-2026-11-06/fixtures"
for name in ("gray2", "gray4", "rgb16"):
case(
name,
lambda name=name: png(
name,
(folder / (name + ".png")).read_bytes(),
(folder / (name + "-white.png")).read_bytes(),
),
)
for name, depth, color in [
("gray1", 1, (0,)),
("gray8", 8, (85,)),
("gray16", 16, (12345,)),
("rgb8", 8, (255, 0, 0)),
]:
case(
name,
lambda name=name, depth=depth, color=color: png(name, *png_with_trns(depth, color)),
)
case(
"rgb16-adam7-filter4-exif6",
lambda: png(
"adam7",
*png_with_trns(
16,
(12345, 23456, 34567),
size=(65, 63),
interlace=1,
filtering=4,
orientation=6,
),
),
)
elif MODE == "png-boundary":
for name in ("gray2", "gray4", "gray16", "rgb16"):
case(
name, lambda name=name: large(name, (FIXTURES / (name + "-40mp.png")).read_bytes())
)
case(
"gray16-without-trns",
lambda: large(
"gray16-opaque", without_trns((FIXTURES / "gray16-40mp.png").read_bytes()), False
),
)
case("concurrent-rgb16", concurrent)
case("forced-timeout", lambda: forced("timeout", FAULT_RENDER_TIMEOUT_SECONDS="0.01"))
case("forced-memory", lambda: forced("memory", FAULT_RENDER_MEMORY_MB="200"))
ids = "{" + ",".join(SUITE.api.accepted) + "}"
ps.poll(lambda: not STACK.sql("staging_left", ids=ids), 45, "staging sweep")
SUITE.drained()
REPORT["invariants"] = SUITE.invariants(dead_before)
finally:
STACK.restore()
REPORT["finished_at"] = ps.now()
REPORT["result"] = (
"PASS"
if REPORT["cases"]
and all(x.get("result") == "PASS" for x in REPORT["cases"] + REPORT.get("invariants", []))
else "FAIL"
)
save()
raise SystemExit(0 if REPORT["result"] == "PASS" else 1)
@@ -0,0 +1,94 @@
date: 2026-11-06T23:12:23Z commit: 74c33160ac01618f70e9e1c6a121a5e45c3c7155
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-memory-validation"}
$ docker compose up -d --wait
Network mtusi2026lab5_backend Creating
Network mtusi2026lab5_backend Created
Network mtusi2026lab5_edge Creating
Network mtusi2026lab5_edge Created
Container mtusi2026lab5-valkey-1 Creating
Container mtusi2026lab5-broker-1 Creating
Container mtusi2026lab5-lb-1 Creating
Container mtusi2026lab5-postgres-1 Creating
Container mtusi2026lab5-s3-1 Creating
Container mtusi2026lab5-s3-1 Created
Container mtusi2026lab5-valkey-1 Created
Container mtusi2026lab5-s3-init-1 Creating
Container mtusi2026lab5-lb-1 Created
Container mtusi2026lab5-broker-1 Created
Container mtusi2026lab5-postgres-1 Created
Container mtusi2026lab5-migrate-1 Creating
Container mtusi2026lab5-s3-init-1 Created
Container mtusi2026lab5-migrate-1 Created
Container mtusi2026lab5-api-2 Creating
Container mtusi2026lab5-worker-1 Creating
Container mtusi2026lab5-api-1 Creating
Container mtusi2026lab5-relay-1 Creating
Container mtusi2026lab5-api-2 Created
Container mtusi2026lab5-relay-1 Created
Container mtusi2026lab5-api-1 Created
Container mtusi2026lab5-worker-1 Created
Container mtusi2026lab5-broker-1 Starting
Container mtusi2026lab5-valkey-1 Starting
Container mtusi2026lab5-postgres-1 Starting
Container mtusi2026lab5-s3-1 Starting
Container mtusi2026lab5-lb-1 Starting
Container mtusi2026lab5-s3-1 Started
Container mtusi2026lab5-s3-1 Waiting
Container mtusi2026lab5-postgres-1 Started
Container mtusi2026lab5-postgres-1 Waiting
Container mtusi2026lab5-valkey-1 Started
Container mtusi2026lab5-broker-1 Started
Container mtusi2026lab5-lb-1 Started
Container mtusi2026lab5-postgres-1 Healthy
Container mtusi2026lab5-migrate-1 Starting
Container mtusi2026lab5-migrate-1 Started
Container mtusi2026lab5-s3-1 Healthy
Container mtusi2026lab5-s3-init-1 Starting
Container mtusi2026lab5-s3-init-1 Started
Container mtusi2026lab5-s3-init-1 Waiting
Container mtusi2026lab5-migrate-1 Waiting
Container mtusi2026lab5-broker-1 Waiting
Container mtusi2026lab5-migrate-1 Waiting
Container mtusi2026lab5-s3-init-1 Waiting
Container mtusi2026lab5-broker-1 Waiting
Container mtusi2026lab5-migrate-1 Waiting
Container mtusi2026lab5-s3-init-1 Waiting
Container mtusi2026lab5-s3-init-1 Exited
Container mtusi2026lab5-migrate-1 Exited
Container mtusi2026lab5-s3-init-1 Exited
Container mtusi2026lab5-s3-init-1 Exited
Container mtusi2026lab5-migrate-1 Exited
Container mtusi2026lab5-migrate-1 Exited
Container mtusi2026lab5-api-1 Starting
Container mtusi2026lab5-broker-1 Healthy
Container mtusi2026lab5-relay-1 Starting
Container mtusi2026lab5-broker-1 Healthy
Container mtusi2026lab5-worker-1 Starting
Container mtusi2026lab5-api-1 Started
Container mtusi2026lab5-api-2 Starting
Container mtusi2026lab5-worker-1 Started
Container mtusi2026lab5-relay-1 Started
Container mtusi2026lab5-api-2 Started
Container mtusi2026lab5-relay-1 Waiting
Container mtusi2026lab5-postgres-1 Waiting
Container mtusi2026lab5-migrate-1 Waiting
Container mtusi2026lab5-s3-1 Waiting
Container mtusi2026lab5-lb-1 Waiting
Container mtusi2026lab5-worker-1 Waiting
Container mtusi2026lab5-broker-1 Waiting
Container mtusi2026lab5-valkey-1 Waiting
Container mtusi2026lab5-s3-init-1 Waiting
Container mtusi2026lab5-api-1 Waiting
Container mtusi2026lab5-api-2 Waiting
Container mtusi2026lab5-migrate-1 Exited
Container mtusi2026lab5-s3-1 Healthy
Container mtusi2026lab5-s3-init-1 Exited
Container mtusi2026lab5-broker-1 Healthy
Container mtusi2026lab5-postgres-1 Healthy
Container mtusi2026lab5-valkey-1 Healthy
Container mtusi2026lab5-api-1 Healthy
Container mtusi2026lab5-api-2 Healthy
Container mtusi2026lab5-worker-1 Healthy
Container mtusi2026lab5-relay-1 Healthy
Container mtusi2026lab5-lb-1 Healthy
exit_code: 0 elapsed_seconds: 11.284
@@ -0,0 +1,60 @@
# Финальная validation ЛР5
Измерен HEAD `b30e2f6a84419d1ca64525ffb40df92183cccaef`; runtime совпадает с прошедшим review `42575281b352d35bda17ee7601bae5548a996e91`. Изменяются только документы и evidence. Полные три повтора трека 2 не запускались заново: применимость и первичные хеши проверены в [аудите](../load-validation.md), [audit.json](audit.json) и [historical-hashes.json](historical-hashes.json).
## Условия
Дата каталога — 2026-11-07 Europe/Moscow; сырые UTC-метки начинаются 2026-11-06T21:15. Darwin arm64, Docker 28.3.2, Linux VM 16 CPU / 8 217 190 400 байт RAM. Основной project `mtusi2026lab5` изолирован собственными сетями и четырьмя сохранёнными volumes. HTTP 18085, stats 25085, broker UI 25086, только loopback. Чужие контейнеры не запускались и не останавливались.
Сборка и начальные функциональные проверки частично совпали по времени с собственным `make student-test` (его одноразовые контейнеры отражены в `postgres-outage*.json`). Перед HTTP PNG и проверками памяти student-test завершился, посторонних работающих Docker-контейнеров нет. Нагрузка хоста фиксируется срезами, непрерывного контроля CPU нет; RPS, p95 и новые SLO не заявляются.
Точные лимиты, image IDs и volumes — [runtime-containers.json](runtime-containers.json). Worker 2 CPU / 1 GiB, render 448 MiB / 30 с, concurrency=2; API ×2 по 1 CPU / 512 MiB. Реальные версии и хеш установленного images.py — [image-runtime.txt](image-runtime.txt). Конфигурация запуска — [env.sh](env.sh), без секретов. Fault-suite использует штатный `infra/compose.faults.yaml` и восстанавливает настройки.
## Выполнено
Все `.txt` содержат команду, исходный SHA, UTC и exit code. Команды выполняются из корня после `source evidence/final-validation-2026-11-07/env.sh`.
| Команда / файл | Наблюдение |
| --- | --- |
| `make check validate lint`, [checks.txt](checks.txt) | PASS |
| `make student-test PYTEST_ARGS='-q --tb=short'`, [student-test.txt](student-test.txt) | 980 passed, 1 Linux-only skip, 19 stack deselected; real-broker тесты включены |
| `openspec validate --all --strict`; `openspec list --json`, [openspec.txt](openspec.txt), [active-changes.txt](active-changes.txt) | 22 PASS, активных changes нет; новый change не создаётся для docs/evidence |
| `docker compose build`; `docker compose up -d --wait`, [build.txt](build.txt), [up.txt](up.txt) | PASS; сохранённые volumes, без удаления очередей/данных |
| `make test`, [smoke.txt](smoke.txt) | Публичный HTTP smoke PASS |
| `rabbitmqctl list_policies/list_queues`, [policy.txt](policy.txt), [queues.txt](queues.txt) | Эффективная policy `delivery-limit=-1` на существующей quorum queue; исходная DLQ=15 |
| `.venv/bin/python evidence/final-validation-2026-11-07/targeted.py postgres-outage-retry`, [команда](postgres-outage-retry.txt), [результат](postgres-outage-retry.json), [сырые requeue](postgres-outage-worker.log) | PASS: настоящий PostgreSQL exited, 12 `job.requeued`, затем ready без replay; job_id и attempt=1 сохранены, три варианта, DLQ=15; 8 инвариантов PASS |
| `targeted.py png-http`, [команда](png-http.txt), [результат](png-http.json) | 8 PNG × v1/v2 × 3 варианта = 48 побайтных сравнений с независимым белым эталоном PASS; оригиналы неизменны, metadata/hash/геометрия, удаление EXIF, stale/duplicate noop; 8 инвариантов PASS |
| `pipeline_suite.py --only …`, [команда](delivery-targeted.txt), [результат](delivery-targeted.json) | 12 адресных сценариев и 8 инвариантов PASS; 11 ID, 47 S3-объектов. DLQ 15 → 16 только от ожидаемого malformed message |
| `targeted.py png-limits`, [команда](png-limits.txt), [результат](png-limits.json) | Четыре FAIL для 40 Мп tRNS при штатных пределах; принудительные timeout/memory и последующее обычное задание PASS. Не переименовывать весь запуск в PASS |
PNG HTTP включает grayscale 1/2/4/8/16, RGB8/16, точного непрозрачного соседа 12346 и RGB16 с Adam7/filter=4/EXIF=6. Новые синтетические 40 Мп fixtures сохранены в [fixtures](fixtures); генератор — `large_png` в [targeted.py](targeted.py).
Policy сверена через Context7 `/rabbitmq/rabbitmq-website`; точная семантика 4.1 дополнительно проверена по [RabbitMQ 4.1](https://www.rabbitmq.com/docs/4.1/quorum-queues#poison-message-handling). Динамическое доказательство относится именно к RabbitMQ 4.1.8, а не к изменённой семантике nack в 4.3.
## Непригодные промежуточные проверки
Первый [postgres-outage.txt](postgres-outage.txt) имеет exit 1: `docker compose start worker` запустил зависимости, включая PostgreSQL, поэтому 12 ошибок не возникли. Это ошибка новой проверочной обвязки, а не дефект приложения. Исходная обвязка сохранена в [targeted-initial.py](targeted-initial.py). Повторён только этот сценарий с `docker start` точного ID своего worker; никаких старых пригодных серий не повторялось.
В `png-limits.json` проверка `no_orphans` выполнена до очередного штатного sweep: после последнего ready ещё оставался staging. Остальные семь инвариантов PASS. Read-only [cleanup-recheck](cleanup-recheck.txt) после sweep подтвердил отсутствие pending outbox/staging/nonterminal/дублей и точное совпадение 10 объектов S3 с БД для семи ID. Тяжёлые PNG не повторялись; исходный `no_orphans FAIL` не переписан.
## Незавершённая квалификация
Четыре валидных PNG 8000×5000 с tRNS приняты с 202, но дали failed/processing_failed на первой попытке. Worker жив, последующая обычная загрузка ready. **Major: не выполнен объявленный сценарий «Изображение на пределе пикселей» [OpenSpec](../../openspec/specs/lab5-image-variants/spec.md): PNG 8000×5000 при штатных пределах должен дать ready.** Это вывод о конкретном граничном сценарии, не заявление о потере данных или падении сервиса. Полное подтверждение «5» и готовность к публикации блокируются до отдельного fix/re-review. Реализация не менялась.
Пять прежних minor и документационная неточность `201` в openspec/config.yaml сохраняются в REPORT. Публикация и Telegram не выполнялись.
[resource-probe-worker.txt](resource-probe-worker.txt) воспроизводит `MemoryError` при 448 MiB и загруженных модулях worker: grayscale 2/4 — `flatten` при выделении белого RGB-фона, grayscale16 — преобразование `I → L`, RGB16 — маски/повторное декодирование в `apply_png_transparency`. Без tRNS gray2/gray4/RGB16 обрабатываются, gray16 всё ещё превышает предел. В облегчённом процессе без импортов worker [resource-probe-retry.txt](resource-probe-retry.txt) проходит grayscale, но падает RGB16: такой изолированный результат не заменяет HTTP-проверку реального worker. RSS пробника — наблюдение процесса, а ограничение — виртуальное адресное пространство RLIMIT_AS.
При штатном HTTP-прогоне peak контейнера составил 640 196 608 байт < 1 GiB; `MemoryError` возникает внутри ограниченного дочернего процесса. Увеличение лимита без учёта concurrency=2 и памяти worker не считается готовым решением. После исправления нужны ресурсная проверка новых PNG, отсутствие поломки точного tRNS и целевые регрессии. Полную принятую track2-матрицу повторять без нового основания не требуется.
Первая попытка скопировать диагностические fixtures через `docker compose cp` отклонена read-only rootfs (`probe-copy-*.txt`), последующий запуск отсутствующего файла завершился exit 2 (`resource-probe.txt`). Затем [invoke-probe.py](invoke-probe.py) передал только синтетические fixtures и код через stdin, записал их в разрешённый tmpfs `/tmp` и выполнил пробник. Эти ошибки обвязки не скрыты и не названы тестовыми PASS.
## Завершение и передача
Итог — **1 major, 6 сохранённых minor**, [findings.json](findings.json). Фаза validation заблокирована граничной обработкой PNG; назначенный агент должен исправить реализацию через OpenSpec и пройти review. В этой фазе новых изменений реализации/конфигурации/OpenSpec нет. Check/validate/lint, полный student-test и остальные адресные результаты сохраняются для аудита применимости, не становятся автоматически недействительными после документационного коммита.
`make down` без `-v` выполнен: [down.txt](down.txt), [stopped-containers.txt](stopped-containers.txt); контейнеров своего project нет. Четыре постоянных volume сохранены — [retained-volumes.txt](retained-volumes.txt). Итоговый список работающих Docker-контейнеров пуст — [running-containers-after.txt](running-containers-after.txt). Фоновых агентов и процессов этап не оставил. Push и Telegram не выполнялись.
Финальные `make check validate lint` — PASS ([checks-final.txt](checks-final.txt)); новый код evidence разобран Python AST. Проверены локальные ссылки и совпадение runtime с review, нормативных файлов со skeleton ([final-doc-audit.json](final-doc-audit.json)). Проверка tracked файлов и новых evidence по восьми шаблонам секретов не обнаружила реальных credentials; семь совпадений проверены как skeleton placeholders/тестовые значения ([secret-scan.json](secret-scan.json)). Это проверка содержимого, без чтения `.env` и `secrets/`. Концевые пробелы в новых текстовых логах нормализованы; результаты/значения не изменены, историческое сырьё не редактировалось.
@@ -0,0 +1,11 @@
date: 2026-11-06T21:15:54Z commit: b30e2f6a84419d1ca64525ffb40df92183cccaef
environment: {}
$ openspec list --json
{
"changes": [],
"root": {
"path": "<repo>",
"source": "nearest"
}
}
exit_code: 0 elapsed_seconds: 0.794
@@ -0,0 +1,142 @@
{
"head": "b30e2f6a84419d1ca64525ffb40df92183cccaef",
"review_runtime_equal": true,
"runtime_diff_from_D": [
"infra/rabbitmq/definitions.json",
"src/messenger/attachments/infrastructure/images.py"
],
"platform": "macOS-15.1-arm64-arm-64bit-Mach-O",
"host_load": [
3.61962890625,
2.6328125,
2.22509765625
],
"docker": "28.3.2 16 8217190400",
"retained_volumes": [
"mtusi2026lab5_broker-data",
"mtusi2026lab5_pgdata",
"mtusi2026lab5_s3data",
"mtusi2026lab5_valkeydata"
],
"series": [
{
"name": "level4",
"source_sha": "0e921116610d289716af0a40ec823376eb8bbcbc",
"scenarios": 17,
"invariants": 8,
"accepted": 33,
"config": {
"base_url": "http://127.0.0.1:18085",
"level": 4,
"only": "",
"expect_variants": "thumbnail,crop,optimized",
"max_attempts": 5,
"stall_seconds": 15.0,
"compose": "docker compose",
"compose_faults": "docker compose -f compose.yaml -f infra/compose.faults.yaml"
}
},
{
"name": "track-run1",
"source_sha": "0e921116610d289716af0a40ec823376eb8bbcbc",
"scenarios": 13,
"invariants": 8,
"accepted": 13,
"config": {
"base_url": "http://127.0.0.1:18085",
"level": 5,
"only": "smoke_pipeline,duplicate_after_ready,crash_commit_publish,crash_publish_confirm,crash_after_s3_before_commit,crash_after_commit_before_ack,lease_expiry_fencing,crash_before_side_effect,worker_kill_mid_task,duplicate_in_flight,reorder_attempts,reorder_versions,stale_after_new_version",
"expect_variants": "thumbnail,crop,optimized",
"max_attempts": 5,
"stall_seconds": 15.0,
"compose": "docker compose",
"compose_faults": "docker compose -f compose.yaml -f infra/compose.faults.yaml"
}
},
{
"name": "track-run2",
"source_sha": "0e921116610d289716af0a40ec823376eb8bbcbc",
"scenarios": 13,
"invariants": 8,
"accepted": 13,
"config": {
"base_url": "http://127.0.0.1:18085",
"level": 5,
"only": "smoke_pipeline,duplicate_after_ready,crash_commit_publish,crash_publish_confirm,crash_after_s3_before_commit,crash_after_commit_before_ack,lease_expiry_fencing,crash_before_side_effect,worker_kill_mid_task,duplicate_in_flight,reorder_attempts,reorder_versions,stale_after_new_version",
"expect_variants": "thumbnail,crop,optimized",
"max_attempts": 5,
"stall_seconds": 15.0,
"compose": "docker compose",
"compose_faults": "docker compose -f compose.yaml -f infra/compose.faults.yaml"
}
},
{
"name": "track-run3",
"source_sha": "0e921116610d289716af0a40ec823376eb8bbcbc",
"scenarios": 13,
"invariants": 8,
"accepted": 13,
"config": {
"base_url": "http://127.0.0.1:18085",
"level": 5,
"only": "smoke_pipeline,duplicate_after_ready,crash_commit_publish,crash_publish_confirm,crash_after_s3_before_commit,crash_after_commit_before_ack,lease_expiry_fencing,crash_before_side_effect,worker_kill_mid_task,duplicate_in_flight,reorder_attempts,reorder_versions,stale_after_new_version",
"expect_variants": "thumbnail,crop,optimized",
"max_attempts": 5,
"stall_seconds": 15.0,
"compose": "docker compose",
"compose_faults": "docker compose -f compose.yaml -f infra/compose.faults.yaml"
}
}
],
"evidence_sha256": {
"evidence/forward-final-2026-11-06/upload-negative.txt": "6cb7ad695b0715a2865e81d113bff729bf98d106a29c419e2ff16f7ee067c4b8",
"evidence/forward-final-2026-11-06/baseline.txt": "f6520adb750693e1c7ad31cdad2d1de327a302d15a17a763a035f35ea5b759f5",
"evidence/forward-final-2026-11-06/student-test.txt": "2976f98e550a14ee2c385f8a1b34a37626fdc602dfc6f848fbf81b0f105834fc",
"evidence/forward-final-2026-11-06/summary.json": "406cea849c5a294a7a744e18056ed54a554cccdf3f5b1133d580ea67cdc1a57f",
"evidence/forward-final-2026-11-06/track-run1.json": "5e90e87bcbf43115df39a37b95f50141772d92e3005f445e1a0c9b5d04050ad0",
"evidence/forward-final-2026-11-06/baseline-regressions.txt": "b0525cea37ce47958dc95e02866c1f014239a6cc8500cf76bf448d2b4f1423c9",
"evidence/forward-final-2026-11-06/conditions-level4-middle.json": "677c0e3499a45daf06cc5bc6f46338ceb873f4203ae137b8cb1c9606f13538eb",
"evidence/forward-final-2026-11-06/lint-runtime.txt": "5e3c5752c468b6f747e4dbafd91954660f8b80f820b63ff34704641e7d5db970",
"evidence/forward-final-2026-11-06/final-containers.txt": "e2ea3d831281e9cc6cc9b03ea1f00172e4eda23fb7244b8d9b60f7d211b5ec64",
"evidence/forward-final-2026-11-06/down.txt": "9dbe77c3dc7b1a17798bd117fd1c8b4cb9ab01a6122376ca5ab38d147ac7b9ff",
"evidence/forward-final-2026-11-06/stopped-containers.txt": "f7ac8e8c29b18a83193a089a2dd75aa0dfc103e54173e2421b853c00a0113338",
"evidence/forward-final-2026-11-06/unit-regressions.txt": "26d5cf96bdf415c5b17fe2a596b9228834995418b1b33a83c146f59617debc5a",
"evidence/forward-final-2026-11-06/track-run1.txt": "7966b1f45232223055f58b0031a6eeee987d42d5789798ec17df711f40c207ac",
"evidence/forward-final-2026-11-06/track-run3.txt": "4b8254db242784c6db3a0db7a8e363269a1aa486a1b26caaee254100f1ab0a52",
"evidence/forward-final-2026-11-06/source-inventory.json": "8977c7883b08b4a2ce7385ddf1c8da11bb4344e586dc71ba637118fcf9d8f506",
"evidence/forward-final-2026-11-06/conditions-stopped.json": "5ed4cc9e6c6969cd16b699a24ac747c7b4ee4c8b189be2f57cd610622891f00d",
"evidence/forward-final-2026-11-06/forward-audit.json": "675a9fcf1fb817bb043c8bcde35079617294da9c7832a529c4d7bfa2adc8f52d",
"evidence/forward-final-2026-11-06/conditions-before.json": "4ef9320729dc38a49b7e8dc3338a862fd69946ceaf64b4aed004bc6ac23ab1cc",
"evidence/forward-final-2026-11-06/track-run2.txt": "1ff4b753ab5627ee5393977203d5dc83f59d4c9e990e7171fc63a06061ceecb3",
"evidence/forward-final-2026-11-06/level4-command.txt": "2b9e49afc9e9ec0e8a8f2a3c491906b72c7439b4a2e30ff6ed0a96d9be4c73ed",
"evidence/forward-final-2026-11-06/level4.json": "904e2c40a6737947b1867c9051a36920c007f49ad59de057a168c1dcc345d87c",
"evidence/forward-final-2026-11-06/archive.txt": "54bc70e53d69969580bd0c88f373778f2a029e2329bbccac7844ff16055deceb",
"evidence/forward-final-2026-11-06/conditions-track-after1.json": "65e7d5a4652e102e6ad8ecbf74356b1c468e2d5ddaee492af21432d646aa4bdf",
"evidence/forward-final-2026-11-06/up.txt": "0baaa49727722eaf24ac4d8b3e083c09bbb53e278e557e42551221d0c59e5856",
"evidence/forward-final-2026-11-06/checks-before-commit.txt": "1b8bd42a69e070cffb07e12449ec749066ec92407fa5d94bd8ad766f40d93dff",
"evidence/forward-final-2026-11-06/checks-final.txt": "d0d3a9f7a24914365c772eabceb4ad2238c5922e30c866a26c5274f8fb570e81",
"evidence/forward-final-2026-11-06/failover.txt": "fcd1b67b77aa7936f9f0ae1c48982e9e4ad9f2e8b9705d2b856ff8cf360fdaa9",
"evidence/forward-final-2026-11-06/persistence-containers.txt": "229bf4c9809cf0e6a1d9cfd162949b413d7f990f57a30fbcd5f9c5b6e3f81e92",
"evidence/forward-final-2026-11-06/conditions-track-start.json": "64e99f2110c3ccf029fba7fe30bd1c9f01615cb5b43ffd77fe4a0f09e7030245",
"evidence/forward-final-2026-11-06/final-smoke.txt": "eec6f2507465824cd920fe78bf876dfbf8b905e84ebcd7b9d51e80d16d4c064b",
"evidence/forward-final-2026-11-06/findings.json": "2f0db619bebbc615dc33f78599210201e1d9441139adb33687dea7a46fc1f15b",
"evidence/forward-final-2026-11-06/network-regressions.txt": "30f0735c6d0bd2370cf39ac6855c06750ba18b282b978dcf6dddcf293145e02b",
"evidence/forward-final-2026-11-06/conditions-track-after2.json": "fa3a1808cc215afb3a422fe582c2d4cae5cf480411f4150977be30f9e24bf462",
"evidence/forward-final-2026-11-06/conditions-track-after3.json": "1054464f5526ee719579fbda81b9e7605a97a660fec9bdfc52f6e68ce94cfad1",
"evidence/forward-final-2026-11-06/specs-validation.txt": "79fe9fdb0bb258d6d7788a79d96587b748233001e97f2acd38bf9bfe0376d515",
"evidence/forward-final-2026-11-06/cache-outage.txt": "fbe1eb591256b35a93a8fd3f4fb299caf22f57159f0b68c984f7c75e5e8be9fc",
"evidence/forward-final-2026-11-06/failover-containers.txt": "4468a88f349073027fb07b2c81406e480e1b503b64fb828e58ecee688d7b2091",
"evidence/forward-final-2026-11-06/clock-observation.json": "d7ae11b8c7970cc71775f46fa0a1474e113da4cae9229d8f28bf85312dd8acc4",
"evidence/forward-final-2026-11-06/conditions-level4-start.json": "0cb8a9314b3afd4704c762b1b611f80beb9f30795475642ad2a22452f87993c0",
"evidence/forward-final-2026-11-06/images.txt": "adb50435b1c24cc0deb913c49ed19e3fdd4287b73719d418accad013ebb7489d",
"evidence/forward-final-2026-11-06/retained-volumes.txt": "ef4b62f79ed1cd0dc1e7313d65873c6a6ab35ff933bd8673a3431d3df5691449",
"evidence/forward-final-2026-11-06/openspec-final.txt": "a34016edea7844300b98aaf38e713df8b4b217924b515881b33a599cd1603b24",
"evidence/forward-final-2026-11-06/track-run3.json": "d190b7a1b4962c520d46931dc63601ed2655f1b4063bc7fea01b78b049a0bede",
"evidence/forward-final-2026-11-06/source-name-status.txt": "81abf426ff31f0253a5ced9ae43fdbbf2a56460afe7b5d299a32c6f664196b93",
"evidence/forward-final-2026-11-06/haproxy-errors.txt": "bf3b0b33f997fefc542860389e8a0fcc1856bbb17cd25b6103911610e87806a3",
"evidence/forward-final-2026-11-06/persistence.txt": "06574967e1dab9742841d54cabb7b0109aa063316e08c8db5525234f084f92de",
"evidence/forward-final-2026-11-06/smoke.txt": "709ddeeb3aa1c4e0b516d4b66038b0421929ee519665d79feccc907cc7bc89ac",
"evidence/forward-final-2026-11-06/restore.txt": "96805ba0f8cba25cb90f385809d0a0a6c75b468a25f87006d729fedc51759c7d",
"evidence/forward-final-2026-11-06/track-run2.json": "16fe12bd42f958a0d4962182da65bd4ee69e4b896fbce47daea724b0a1c618e8"
}
}
@@ -0,0 +1,90 @@
date: 2026-11-06T21:16:11Z commit: b30e2f6a84419d1ca64525ffb40df92183cccaef
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-validation"}
$ docker compose build
#1 [internal] load local bake definitions
#1 reading from stdin 434B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 1.65kB done
#2 DONE 0.0s
#3 [internal] load metadata for ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142
#3 DONE 0.0s
#4 [internal] load metadata for docker.io/library/python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d
#4 DONE 1.7s
#5 [internal] load .dockerignore
#5 transferring context: 453B done
#5 DONE 0.0s
#6 FROM ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142
#6 resolve ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 0.0s done
#6 DONE 0.0s
#7 [builder 1/7] FROM docker.io/library/python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d
#7 resolve docker.io/library/python:3.14-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d 0.0s done
#7 DONE 0.0s
#8 [internal] load build context
#8 transferring context: 51.62kB 0.0s done
#8 DONE 0.0s
#9 [builder 2/7] COPY --from=ghcr.io/astral-sh/uv:0.9.7@sha256:ba4857bf2a068e9bc0e64eed8563b065908a4cd6bfb66b531a9c424c8e25e142 /uv /usr/local/bin/uv
#9 CACHED
#10 [builder 4/7] COPY pyproject.toml uv.lock README.md ./
#10 CACHED
#11 [builder 3/7] WORKDIR /build
#11 CACHED
#12 [builder 5/7] RUN uv sync --locked --no-dev --no-install-project --no-editable
#12 CACHED
#13 [builder 6/7] COPY src ./src
#13 DONE 0.1s
#14 [builder 7/7] RUN uv sync --locked --no-dev --no-editable
#14 0.280 Resolved 84 packages in 12ms
#14 0.309 Building mtusi-messenger @ file:///build
#14 1.851 Built mtusi-messenger @ file:///build
#14 1.855 Prepared 1 package in 1.54s
#14 1.859 Installed 1 package in 3ms
#14 2.080 Bytecode compiled 2301 files in 221ms
#14 2.080 + mtusi-messenger==1.5.0 (from file:///build)
#14 DONE 2.1s
#15 [runtime 2/6] RUN groupadd --system --gid 10001 messenger && useradd --system --uid 10001 --gid messenger --no-create-home --shell /usr/sbin/nologin messenger
#15 CACHED
#16 [runtime 3/6] COPY --from=builder --chown=root:root /opt/venv /opt/venv
#16 DONE 0.4s
#17 [runtime 4/6] WORKDIR /app
#17 DONE 0.0s
#18 [runtime 5/6] COPY --chown=root:root alembic.ini ./
#18 DONE 0.0s
#19 [runtime 6/6] COPY --chown=root:root alembic ./alembic
#19 DONE 0.0s
#20 exporting to image
#20 exporting layers
#20 exporting layers 3.0s done
#20 exporting manifest sha256:5fa47645c125c166f4f83308eeda33e4679510f9548cae36141b4bcff1bec3cb
#20 exporting manifest sha256:5fa47645c125c166f4f83308eeda33e4679510f9548cae36141b4bcff1bec3cb done
#20 exporting config sha256:34e5f914cd69e5cff0b7745f9730b4d63d0a62480ef53de7b18914787a51c828 done
#20 exporting attestation manifest sha256:043b67091fa616197172d98abd054f1cd803a4b540ceb0bc4a8e30232d37359d done
#20 exporting manifest list sha256:9293b3138e99506510e947ba0cfc77ed4301f96344dd937d51d03e8c258121f2 done
#20 naming to docker.io/library/mtusi-messenger:lab5-validation done
#20 unpacking to docker.io/library/mtusi-messenger:lab5-validation
#20 unpacking to docker.io/library/mtusi-messenger:lab5-validation 0.6s done
#20 DONE 3.6s
#21 resolving provenance for metadata file
#21 DONE 0.0s
api Built
exit_code: 0 elapsed_seconds: 9.093
@@ -0,0 +1,14 @@
date: 2026-11-06T21:29:59Z commit: b30e2f6a84419d1ca64525ffb40df92183cccaef
environment: {}
$ make check validate lint
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
.venv/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
.venv/bin/ruff check src student-tests scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
All checks passed!
.venv/bin/ruff format --check src student-tests scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
197 files already formatted
.venv/bin/ty check src student-tests alembic
All checks passed!
exit_code: 0 elapsed_seconds: 0.535
@@ -0,0 +1,14 @@
date: 2026-11-06T21:15:52Z commit: b30e2f6a84419d1ca64525ffb40df92183cccaef
environment: {}
$ make check validate lint
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
.venv/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
.venv/bin/ruff check src student-tests scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
All checks passed!
.venv/bin/ruff format --check src student-tests scripts/capture_evidence.py alembic scripts/scaling.py tools scripts/probe.py scripts/limits.py scripts/lab4_scenarios.py scripts/lab4_seed.py scripts/upload_memory.py scripts/reconcile_check.py scripts/reconcile_track.py scripts/make_images.py scripts/pipeline_suite.py scripts/pipeline_evidence.py
197 files already formatted
.venv/bin/ty check src student-tests alembic
All checks passed!
exit_code: 0 elapsed_seconds: 0.580
@@ -0,0 +1,32 @@
{
"source_sha": "b30e2f6a84419d1ca64525ffb40df92183cccaef",
"at": "2026-11-06T21:26:03.661679Z",
"result": "PASS",
"accepted_ids": [
"01a1b2bc-cdc1-7315-82e0-39f3e53d87db",
"01a1b2bc-d211-7337-bd57-0ca1f3e33a0d",
"01a1b2bc-d744-77c1-8352-989f80848cab",
"01a1b2bc-dc37-7249-b7c3-f8901fb298de",
"01a1b2bc-f161-7119-986f-bc7c8fd99bf0",
"01a1b2bd-0192-70e7-a174-3275ca516e11",
"01a1b2bd-13b0-712a-9275-1d3cdd2eb49a"
],
"rows": {
"pending_outbox": [],
"staging_left": [],
"nonterminal": [],
"duplicate_effects": []
},
"s3_objects": 10,
"queues": {
"attachments.process": [
0,
0
],
"attachments.process.dlq": [
16,
0
]
},
"reason": "Read-only recheck after scheduled staging sweep; no scenario rerun. Initial no_orphans ran before the sweep."
}
@@ -0,0 +1,36 @@
date: 2026-11-06T21:25:54Z commit: b30e2f6a84419d1ca64525ffb40df92183cccaef
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-validation"}
$ .venv/bin/python evidence/final-validation-2026-11-07/recheck-cleanup.py
{
"source_sha": "b30e2f6a84419d1ca64525ffb40df92183cccaef",
"at": "2026-11-06T21:26:03.661679Z",
"result": "PASS",
"accepted_ids": [
"01a1b2bc-cdc1-7315-82e0-39f3e53d87db",
"01a1b2bc-d211-7337-bd57-0ca1f3e33a0d",
"01a1b2bc-d744-77c1-8352-989f80848cab",
"01a1b2bc-dc37-7249-b7c3-f8901fb298de",
"01a1b2bc-f161-7119-986f-bc7c8fd99bf0",
"01a1b2bd-0192-70e7-a174-3275ca516e11",
"01a1b2bd-13b0-712a-9275-1d3cdd2eb49a"
],
"rows": {
"pending_outbox": [],
"staging_left": [],
"nonterminal": [],
"duplicate_effects": []
},
"s3_objects": 10,
"queues": {
"attachments.process": [
0,
0
],
"attachments.process.dlq": [
16,
0
]
},
"reason": "Read-only recheck after scheduled staging sweep; no scenario rerun. Initial no_orphans ran before the sweep."
}
exit_code: 0 elapsed_seconds: 9.044
@@ -0,0 +1,896 @@
{
"suite": "lab5-pipeline-idempotency",
"started_at": "2026-11-06T21:22:22.429392Z",
"source_sha": "b30e2f6a84419d1ca64525ffb40df92183cccaef",
"config": {
"base_url": "http://127.0.0.1:18085",
"level": 5,
"only": "duplicate_after_ready,retry_exhausted,crash_commit_publish,crash_after_s3_before_commit,crash_after_commit_before_ack,lease_expiry_fencing,replay_failed,malformed_message_dead_lettered,duplicate_in_flight,reorder_attempts,reorder_versions,stale_after_new_version",
"expect_variants": "thumbnail,crop,optimized",
"max_attempts": 5,
"stall_seconds": 15.0,
"compose": "docker compose",
"compose_faults": "docker compose -f compose.yaml -f infra/compose.faults.yaml"
},
"invariants": [
{
"id": "terminal",
"statement": "every 202 reaches its expected terminal state",
"result": "PASS",
"details": {
"accepted": 11
}
},
{
"id": "single_effect",
"statement": "one variant set per (attachment_id, pipeline_version, variant)",
"result": "PASS",
"details": {
"rows": 0
}
},
{
"id": "no_ready_rollback",
"statement": "ready never returns to queued or processing",
"result": "PASS",
"details": {
"traced": 11
}
},
{
"id": "monotonic_publication",
"statement": "published_version only moves forward",
"result": "PASS",
"details": {
"sampled": 8
}
},
{
"id": "bytes_match_metadata",
"statement": "sha256, size and real dimensions match served bytes",
"result": "PASS",
"details": {
"verified": 10
}
},
{
"id": "bounded_attempts",
"statement": "attempt <= JOB_MAX_ATTEMPTS",
"result": "PASS",
"details": {
"rows": 0
}
},
{
"id": "no_orphans",
"statement": "no pending outbox, messages, dead letters, staging, objects",
"result": "PASS",
"details": {
"queues": {
"attachments.process": [
0,
0
],
"attachments.process.dlq": [
16,
0
]
},
"s3_objects": 47,
"scoped_attachments": 11
}
},
{
"id": "no_lost_202",
"statement": "every 202 is present in PostgreSQL and the API",
"result": "PASS",
"details": {
"accepted": 11
}
}
],
"accepted_ids": [
"01a1b2bd-dee8-7491-a9c1-90e56c2bb9e4",
"01a1b2bd-fe45-77cf-b9ef-53b5e01c32ac",
"01a1b2be-4b72-71c4-99f1-b93ee6662a6b",
"01a1b2be-6f6f-7200-a261-63dd237e9ec8",
"01a1b2be-a1dc-76f3-9861-667de097c2af",
"01a1b2be-c7f7-7326-b272-a341993c5bf9",
"01a1b2bf-47a0-77e8-97ed-907199a6caa7",
"01a1b2bf-b3a8-7754-af89-7d174f4540d1",
"01a1b2bf-ed3f-721d-ae2a-dd55e7ab970d",
"01a1b2c0-286d-77c5-8019-58526f2e09c5",
"01a1b2c0-5422-77cd-88f8-cd2c123fe78d"
],
"scenarios": [
{
"name": "duplicate_after_ready",
"level": 3,
"window": "redelivery of a finished job",
"seconds": 4.4,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2bd-dee8-7491-a9c1-90e56c2bb9e4",
"events": [
{
"kind": "enqueued",
"attempt": 1
},
{
"kind": "claimed",
"attempt": 1
},
{
"kind": "done",
"attempt": 1
},
{
"kind": "duplicate_noop",
"attempt": 1
}
]
}
},
{
"name": "retry_exhausted",
"level": 3,
"window": "transient error until JOB_MAX_ATTEMPTS",
"seconds": 19.6,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2bd-fe45-77cf-b9ef-53b5e01c32ac",
"jobs": [
{
"job_id": "01a1b2bd-fe54-7252-944d-9d5a09b3019d",
"pipeline_version": 1,
"status": "failed",
"attempt": 5
}
]
}
},
{
"name": "crash_commit_publish",
"level": 4,
"window": "after COMMIT, before publish",
"seconds": 9.2,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2be-4b72-71c4-99f1-b93ee6662a6b",
"exit_code": 137,
"after_crash": {
"outbox_published": false,
"status": "queued",
"containers": [
"mtusi2026lab5-relay-1 ee568583263a exited Exited (137) 1 second ago"
]
},
"variants": [
{
"pipeline_version": 1,
"name": "crop",
"sha256": "97bf1400b30a28c19420a30161c944f57b5e7d613533b76afe6ab2531cba0143",
"size_bytes": 1820,
"object_key": "variants/01a1b2be-4b72-71c4-99f1-b93ee6662a6b/1/crop-97bf1400b30a28c1.jpg"
},
{
"pipeline_version": 1,
"name": "optimized",
"sha256": "1090d84ed8411226010ae498b08e1b9e6d81c8eee02ee77143a0dc327b894beb",
"size_bytes": 2462,
"object_key": "variants/01a1b2be-4b72-71c4-99f1-b93ee6662a6b/1/optimized-1090d84ed8411226.webp"
},
{
"pipeline_version": 1,
"name": "thumbnail",
"sha256": "7bc40bf315c8e18e907889b23514d978be213a44223d64b737290188ee808594",
"size_bytes": 4679,
"object_key": "variants/01a1b2be-4b72-71c4-99f1-b93ee6662a6b/1/thumbnail-7bc40bf315c8e18e.jpg"
}
]
}
},
{
"name": "crash_after_s3_before_commit",
"level": 4,
"window": "after S3 write, before COMMIT",
"seconds": 12.4,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2be-6f6f-7200-a261-63dd237e9ec8",
"exit_code": 137,
"after_crash": {
"status": "processing",
"variant_rows": 0,
"containers": [
"mtusi2026lab5-worker-1 b9de1e78db3d exited Exited (137) Less than a second ago"
]
},
"variants": [
{
"pipeline_version": 1,
"name": "crop",
"sha256": "97bf1400b30a28c19420a30161c944f57b5e7d613533b76afe6ab2531cba0143",
"size_bytes": 1820,
"object_key": "variants/01a1b2be-6f6f-7200-a261-63dd237e9ec8/1/crop-97bf1400b30a28c1.jpg"
},
{
"pipeline_version": 1,
"name": "optimized",
"sha256": "1090d84ed8411226010ae498b08e1b9e6d81c8eee02ee77143a0dc327b894beb",
"size_bytes": 2462,
"object_key": "variants/01a1b2be-6f6f-7200-a261-63dd237e9ec8/1/optimized-1090d84ed8411226.webp"
},
{
"pipeline_version": 1,
"name": "thumbnail",
"sha256": "7bc40bf315c8e18e907889b23514d978be213a44223d64b737290188ee808594",
"size_bytes": 4679,
"object_key": "variants/01a1b2be-6f6f-7200-a261-63dd237e9ec8/1/thumbnail-7bc40bf315c8e18e.jpg"
}
]
}
},
{
"name": "crash_after_commit_before_ack",
"level": 4,
"window": "after COMMIT, before ack",
"seconds": 10.3,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2be-a1dc-76f3-9861-667de097c2af",
"exit_code": 137,
"after_crash": {
"status": "ready",
"variants": [
{
"pipeline_version": 1,
"name": "crop",
"sha256": "97bf1400b30a28c19420a30161c944f57b5e7d613533b76afe6ab2531cba0143",
"size_bytes": 1820,
"object_key": "variants/01a1b2be-a1dc-76f3-9861-667de097c2af/1/crop-97bf1400b30a28c1.jpg"
},
{
"pipeline_version": 1,
"name": "optimized",
"sha256": "1090d84ed8411226010ae498b08e1b9e6d81c8eee02ee77143a0dc327b894beb",
"size_bytes": 2462,
"object_key": "variants/01a1b2be-a1dc-76f3-9861-667de097c2af/1/optimized-1090d84ed8411226.webp"
},
{
"pipeline_version": 1,
"name": "thumbnail",
"sha256": "7bc40bf315c8e18e907889b23514d978be213a44223d64b737290188ee808594",
"size_bytes": 4679,
"object_key": "variants/01a1b2be-a1dc-76f3-9861-667de097c2af/1/thumbnail-7bc40bf315c8e18e.jpg"
}
],
"queues": {
"attachments.process": [
0,
0
],
"attachments.process.dlq": [
15,
0
]
},
"containers": [
"mtusi2026lab5-worker-1 b78cddfd65c9 exited Exited (137) 1 second ago"
]
},
"variants": [
{
"pipeline_version": 1,
"name": "crop",
"sha256": "97bf1400b30a28c19420a30161c944f57b5e7d613533b76afe6ab2531cba0143",
"size_bytes": 1820,
"object_key": "variants/01a1b2be-a1dc-76f3-9861-667de097c2af/1/crop-97bf1400b30a28c1.jpg"
},
{
"pipeline_version": 1,
"name": "optimized",
"sha256": "1090d84ed8411226010ae498b08e1b9e6d81c8eee02ee77143a0dc327b894beb",
"size_bytes": 2462,
"object_key": "variants/01a1b2be-a1dc-76f3-9861-667de097c2af/1/optimized-1090d84ed8411226.webp"
},
{
"pipeline_version": 1,
"name": "thumbnail",
"sha256": "7bc40bf315c8e18e907889b23514d978be213a44223d64b737290188ee808594",
"size_bytes": 4679,
"object_key": "variants/01a1b2be-a1dc-76f3-9861-667de097c2af/1/thumbnail-7bc40bf315c8e18e.jpg"
}
]
}
},
{
"name": "lease_expiry_fencing",
"level": 4,
"window": "stalled worker, lease expiry",
"seconds": 32.7,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2be-c7f7-7326-b272-a341993c5bf9",
"jobs": [
{
"job_id": "01a1b2be-c805-75f5-95ab-9aabfea704fb",
"pipeline_version": 1,
"status": "done",
"attempt": 2
}
],
"events": [
{
"kind": "enqueued",
"attempt": 1
},
{
"kind": "claimed",
"attempt": 1
},
{
"kind": "lease_expired",
"attempt": 2
},
{
"kind": "claimed",
"attempt": 2
},
{
"kind": "done",
"attempt": 2
},
{
"kind": "fenced",
"attempt": 1
}
]
}
},
{
"name": "replay_failed",
"level": 4,
"window": "operator replay",
"seconds": 24.6,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2bf-47a0-77e8-97ed-907199a6caa7",
"replay": {
"result": "replayed",
"attachment_id": "01a1b2bf-47a0-77e8-97ed-907199a6caa7",
"operator": "cli"
},
"replay_of_ready": {
"result": "noop",
"attachment_id": "01a1b2bf-47a0-77e8-97ed-907199a6caa7",
"operator": "cli"
},
"events": [
{
"kind": "enqueued",
"attempt": 1
},
{
"kind": "claimed",
"attempt": 1
},
{
"kind": "retry_scheduled",
"attempt": 2
},
{
"kind": "claimed",
"attempt": 2
},
{
"kind": "retry_scheduled",
"attempt": 3
},
{
"kind": "claimed",
"attempt": 3
},
{
"kind": "retry_scheduled",
"attempt": 4
},
{
"kind": "claimed",
"attempt": 4
},
{
"kind": "retry_scheduled",
"attempt": 5
},
{
"kind": "claimed",
"attempt": 5
},
{
"kind": "failed",
"attempt": 5
},
{
"kind": "replayed",
"attempt": 1
},
{
"kind": "claimed",
"attempt": 1
},
{
"kind": "done",
"attempt": 1
},
{
"kind": "replay_noop",
"attempt": 1
}
]
}
},
{
"name": "malformed_message_dead_lettered",
"level": 4,
"window": "message that is not a job goes to the DLQ",
"seconds": 6.5,
"result": "PASS",
"observed": {
"dead_letters": 1
}
},
{
"name": "duplicate_in_flight",
"level": 5,
"window": "two copies of one job in flight",
"seconds": 14.7,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2bf-b3a8-7754-af89-7d174f4540d1",
"variants": [
{
"pipeline_version": 1,
"name": "crop",
"sha256": "97bf1400b30a28c19420a30161c944f57b5e7d613533b76afe6ab2531cba0143",
"size_bytes": 1820,
"object_key": "variants/01a1b2bf-b3a8-7754-af89-7d174f4540d1/1/crop-97bf1400b30a28c1.jpg"
},
{
"pipeline_version": 1,
"name": "optimized",
"sha256": "1090d84ed8411226010ae498b08e1b9e6d81c8eee02ee77143a0dc327b894beb",
"size_bytes": 2462,
"object_key": "variants/01a1b2bf-b3a8-7754-af89-7d174f4540d1/1/optimized-1090d84ed8411226.webp"
},
{
"pipeline_version": 1,
"name": "thumbnail",
"sha256": "7bc40bf315c8e18e907889b23514d978be213a44223d64b737290188ee808594",
"size_bytes": 4679,
"object_key": "variants/01a1b2bf-b3a8-7754-af89-7d174f4540d1/1/thumbnail-7bc40bf315c8e18e.jpg"
}
],
"events": [
{
"kind": "enqueued",
"attempt": 1
},
{
"kind": "claimed",
"attempt": 1
},
{
"kind": "duplicate_noop",
"attempt": 1
},
{
"kind": "done",
"attempt": 1
}
]
}
},
{
"name": "reorder_attempts",
"level": 5,
"window": "attempt 2 delivered before attempt 1",
"seconds": 15.1,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2bf-ed3f-721d-ae2a-dd55e7ab970d",
"jobs": [
{
"job_id": "01a1b2bf-ed46-71ef-85b7-54e89e3b1eec",
"pipeline_version": 1,
"status": "done",
"attempt": 1
}
],
"events": [
{
"kind": "enqueued",
"attempt": 1
},
{
"kind": "claimed",
"attempt": 1
},
{
"kind": "duplicate_noop",
"attempt": 2
},
{
"kind": "done",
"attempt": 1
}
]
}
},
{
"name": "reorder_versions",
"level": 5,
"window": "v2 delivered before v1",
"seconds": 11.6,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2c0-286d-77c5-8019-58526f2e09c5",
"jobs": [
{
"job_id": "01a1b2c0-2874-74f6-b880-6970766e70ee",
"pipeline_version": 1,
"status": "superseded",
"attempt": 1
},
{
"job_id": "01a1b2c0-2bd0-748f-9b84-334656652efc",
"pipeline_version": 2,
"status": "done",
"attempt": 1
}
],
"v2_before_v1": {
"status": "ready",
"public": [
{
"name": "crop",
"content_type": "image/jpeg",
"size_bytes": 2142,
"width": 128,
"height": 128,
"sha256": "5b6fb2a66216f8ca038542acdd8482fca9d1ad79193d60ae74de3989048ec0a4"
},
{
"name": "optimized",
"content_type": "image/webp",
"size_bytes": 2790,
"width": 320,
"height": 200,
"sha256": "fe520c978bd45fc8f1b85863dc9dc6fc98954b45d7fe803e8e4c6b681ddc1957"
},
{
"name": "thumbnail",
"content_type": "image/jpeg",
"size_bytes": 5628,
"width": 256,
"height": 160,
"sha256": "fa0db661078d4da91b241edc8b416de7755db9c9c79ae704a620ca7ad534e308"
}
],
"rows": [
{
"pipeline_version": 2,
"name": "crop",
"sha256": "5b6fb2a66216f8ca038542acdd8482fca9d1ad79193d60ae74de3989048ec0a4",
"size_bytes": 2142,
"object_key": "variants/01a1b2c0-286d-77c5-8019-58526f2e09c5/2/crop-5b6fb2a66216f8ca.jpg"
},
{
"pipeline_version": 2,
"name": "optimized",
"sha256": "fe520c978bd45fc8f1b85863dc9dc6fc98954b45d7fe803e8e4c6b681ddc1957",
"size_bytes": 2790,
"object_key": "variants/01a1b2c0-286d-77c5-8019-58526f2e09c5/2/optimized-fe520c978bd45fc8.webp"
},
{
"pipeline_version": 2,
"name": "thumbnail",
"sha256": "fa0db661078d4da91b241edc8b416de7755db9c9c79ae704a620ca7ad534e308",
"size_bytes": 5628,
"object_key": "variants/01a1b2c0-286d-77c5-8019-58526f2e09c5/2/thumbnail-fa0db661078d4da9.jpg"
}
],
"published": 2
},
"after_v1": {
"status": "ready",
"public": [
{
"name": "crop",
"content_type": "image/jpeg",
"size_bytes": 2142,
"width": 128,
"height": 128,
"sha256": "5b6fb2a66216f8ca038542acdd8482fca9d1ad79193d60ae74de3989048ec0a4"
},
{
"name": "optimized",
"content_type": "image/webp",
"size_bytes": 2790,
"width": 320,
"height": 200,
"sha256": "fe520c978bd45fc8f1b85863dc9dc6fc98954b45d7fe803e8e4c6b681ddc1957"
},
{
"name": "thumbnail",
"content_type": "image/jpeg",
"size_bytes": 5628,
"width": 256,
"height": 160,
"sha256": "fa0db661078d4da91b241edc8b416de7755db9c9c79ae704a620ca7ad534e308"
}
],
"rows": [
{
"pipeline_version": 1,
"name": "crop",
"sha256": "97bf1400b30a28c19420a30161c944f57b5e7d613533b76afe6ab2531cba0143",
"size_bytes": 1820,
"object_key": "variants/01a1b2c0-286d-77c5-8019-58526f2e09c5/1/crop-97bf1400b30a28c1.jpg"
},
{
"pipeline_version": 1,
"name": "optimized",
"sha256": "1090d84ed8411226010ae498b08e1b9e6d81c8eee02ee77143a0dc327b894beb",
"size_bytes": 2462,
"object_key": "variants/01a1b2c0-286d-77c5-8019-58526f2e09c5/1/optimized-1090d84ed8411226.webp"
},
{
"pipeline_version": 1,
"name": "thumbnail",
"sha256": "7bc40bf315c8e18e907889b23514d978be213a44223d64b737290188ee808594",
"size_bytes": 4679,
"object_key": "variants/01a1b2c0-286d-77c5-8019-58526f2e09c5/1/thumbnail-7bc40bf315c8e18e.jpg"
},
{
"pipeline_version": 2,
"name": "crop",
"sha256": "5b6fb2a66216f8ca038542acdd8482fca9d1ad79193d60ae74de3989048ec0a4",
"size_bytes": 2142,
"object_key": "variants/01a1b2c0-286d-77c5-8019-58526f2e09c5/2/crop-5b6fb2a66216f8ca.jpg"
},
{
"pipeline_version": 2,
"name": "optimized",
"sha256": "fe520c978bd45fc8f1b85863dc9dc6fc98954b45d7fe803e8e4c6b681ddc1957",
"size_bytes": 2790,
"object_key": "variants/01a1b2c0-286d-77c5-8019-58526f2e09c5/2/optimized-fe520c978bd45fc8.webp"
},
{
"pipeline_version": 2,
"name": "thumbnail",
"sha256": "fa0db661078d4da91b241edc8b416de7755db9c9c79ae704a620ca7ad534e308",
"size_bytes": 5628,
"object_key": "variants/01a1b2c0-286d-77c5-8019-58526f2e09c5/2/thumbnail-fa0db661078d4da9.jpg"
}
],
"published": 2
}
}
},
{
"name": "stale_after_new_version",
"level": 5,
"window": "v1 job after v2 is published",
"seconds": 4.7,
"result": "PASS",
"observed": {
"attachment_id": "01a1b2c0-5422-77cd-88f8-cd2c123fe78d",
"published_version": 2,
"v1": {
"status": "ready",
"public": [
{
"name": "crop",
"content_type": "image/jpeg",
"size_bytes": 1820,
"width": 128,
"height": 128,
"sha256": "97bf1400b30a28c19420a30161c944f57b5e7d613533b76afe6ab2531cba0143"
},
{
"name": "optimized",
"content_type": "image/webp",
"size_bytes": 2462,
"width": 320,
"height": 200,
"sha256": "1090d84ed8411226010ae498b08e1b9e6d81c8eee02ee77143a0dc327b894beb"
},
{
"name": "thumbnail",
"content_type": "image/jpeg",
"size_bytes": 4679,
"width": 256,
"height": 160,
"sha256": "7bc40bf315c8e18e907889b23514d978be213a44223d64b737290188ee808594"
}
],
"rows": [
{
"pipeline_version": 1,
"name": "crop",
"sha256": "97bf1400b30a28c19420a30161c944f57b5e7d613533b76afe6ab2531cba0143",
"size_bytes": 1820,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/1/crop-97bf1400b30a28c1.jpg"
},
{
"pipeline_version": 1,
"name": "optimized",
"sha256": "1090d84ed8411226010ae498b08e1b9e6d81c8eee02ee77143a0dc327b894beb",
"size_bytes": 2462,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/1/optimized-1090d84ed8411226.webp"
},
{
"pipeline_version": 1,
"name": "thumbnail",
"sha256": "7bc40bf315c8e18e907889b23514d978be213a44223d64b737290188ee808594",
"size_bytes": 4679,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/1/thumbnail-7bc40bf315c8e18e.jpg"
}
],
"published": 1
},
"v2_before_stale": {
"status": "ready",
"public": [
{
"name": "crop",
"content_type": "image/jpeg",
"size_bytes": 2142,
"width": 128,
"height": 128,
"sha256": "5b6fb2a66216f8ca038542acdd8482fca9d1ad79193d60ae74de3989048ec0a4"
},
{
"name": "optimized",
"content_type": "image/webp",
"size_bytes": 2790,
"width": 320,
"height": 200,
"sha256": "fe520c978bd45fc8f1b85863dc9dc6fc98954b45d7fe803e8e4c6b681ddc1957"
},
{
"name": "thumbnail",
"content_type": "image/jpeg",
"size_bytes": 5628,
"width": 256,
"height": 160,
"sha256": "fa0db661078d4da91b241edc8b416de7755db9c9c79ae704a620ca7ad534e308"
}
],
"rows": [
{
"pipeline_version": 1,
"name": "crop",
"sha256": "97bf1400b30a28c19420a30161c944f57b5e7d613533b76afe6ab2531cba0143",
"size_bytes": 1820,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/1/crop-97bf1400b30a28c1.jpg"
},
{
"pipeline_version": 1,
"name": "optimized",
"sha256": "1090d84ed8411226010ae498b08e1b9e6d81c8eee02ee77143a0dc327b894beb",
"size_bytes": 2462,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/1/optimized-1090d84ed8411226.webp"
},
{
"pipeline_version": 1,
"name": "thumbnail",
"sha256": "7bc40bf315c8e18e907889b23514d978be213a44223d64b737290188ee808594",
"size_bytes": 4679,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/1/thumbnail-7bc40bf315c8e18e.jpg"
},
{
"pipeline_version": 2,
"name": "crop",
"sha256": "5b6fb2a66216f8ca038542acdd8482fca9d1ad79193d60ae74de3989048ec0a4",
"size_bytes": 2142,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/2/crop-5b6fb2a66216f8ca.jpg"
},
{
"pipeline_version": 2,
"name": "optimized",
"sha256": "fe520c978bd45fc8f1b85863dc9dc6fc98954b45d7fe803e8e4c6b681ddc1957",
"size_bytes": 2790,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/2/optimized-fe520c978bd45fc8.webp"
},
{
"pipeline_version": 2,
"name": "thumbnail",
"sha256": "fa0db661078d4da91b241edc8b416de7755db9c9c79ae704a620ca7ad534e308",
"size_bytes": 5628,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/2/thumbnail-fa0db661078d4da9.jpg"
}
],
"published": 2
},
"v2_after_stale": {
"status": "ready",
"public": [
{
"name": "crop",
"content_type": "image/jpeg",
"size_bytes": 2142,
"width": 128,
"height": 128,
"sha256": "5b6fb2a66216f8ca038542acdd8482fca9d1ad79193d60ae74de3989048ec0a4"
},
{
"name": "optimized",
"content_type": "image/webp",
"size_bytes": 2790,
"width": 320,
"height": 200,
"sha256": "fe520c978bd45fc8f1b85863dc9dc6fc98954b45d7fe803e8e4c6b681ddc1957"
},
{
"name": "thumbnail",
"content_type": "image/jpeg",
"size_bytes": 5628,
"width": 256,
"height": 160,
"sha256": "fa0db661078d4da91b241edc8b416de7755db9c9c79ae704a620ca7ad534e308"
}
],
"rows": [
{
"pipeline_version": 1,
"name": "crop",
"sha256": "97bf1400b30a28c19420a30161c944f57b5e7d613533b76afe6ab2531cba0143",
"size_bytes": 1820,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/1/crop-97bf1400b30a28c1.jpg"
},
{
"pipeline_version": 1,
"name": "optimized",
"sha256": "1090d84ed8411226010ae498b08e1b9e6d81c8eee02ee77143a0dc327b894beb",
"size_bytes": 2462,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/1/optimized-1090d84ed8411226.webp"
},
{
"pipeline_version": 1,
"name": "thumbnail",
"sha256": "7bc40bf315c8e18e907889b23514d978be213a44223d64b737290188ee808594",
"size_bytes": 4679,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/1/thumbnail-7bc40bf315c8e18e.jpg"
},
{
"pipeline_version": 2,
"name": "crop",
"sha256": "5b6fb2a66216f8ca038542acdd8482fca9d1ad79193d60ae74de3989048ec0a4",
"size_bytes": 2142,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/2/crop-5b6fb2a66216f8ca.jpg"
},
{
"pipeline_version": 2,
"name": "optimized",
"sha256": "fe520c978bd45fc8f1b85863dc9dc6fc98954b45d7fe803e8e4c6b681ddc1957",
"size_bytes": 2790,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/2/optimized-fe520c978bd45fc8.webp"
},
{
"pipeline_version": 2,
"name": "thumbnail",
"sha256": "fa0db661078d4da91b241edc8b416de7755db9c9c79ae704a620ca7ad534e308",
"size_bytes": 5628,
"object_key": "variants/01a1b2c0-5422-77cd-88f8-cd2c123fe78d/2/thumbnail-fa0db661078d4da9.jpg"
}
],
"published": 2
}
}
}
],
"result": "PASS",
"finished_at": "2026-11-06T21:25:34.062079Z"
}
@@ -0,0 +1,29 @@
date: 2026-11-06T21:22:22Z commit: b30e2f6a84419d1ca64525ffb40df92183cccaef
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-validation"}
$ python3 scripts/pipeline_suite.py --only duplicate_after_ready,retry_exhausted,crash_commit_publish,crash_after_s3_before_commit,crash_after_commit_before_ack,lease_expiry_fencing,replay_failed,malformed_message_dead_lettered,duplicate_in_flight,reorder_attempts,reorder_versions,stale_after_new_version --output evidence/final-validation-2026-11-07/delivery-targeted.json
RUN duplicate_after_ready
PASS duplicate_after_ready
RUN retry_exhausted
PASS retry_exhausted
RUN crash_commit_publish
PASS crash_commit_publish
RUN crash_after_s3_before_commit
PASS crash_after_s3_before_commit
RUN crash_after_commit_before_ack
PASS crash_after_commit_before_ack
RUN lease_expiry_fencing
PASS lease_expiry_fencing
RUN replay_failed
PASS replay_failed
RUN malformed_message_dead_lettered
PASS malformed_message_dead_lettered
RUN duplicate_in_flight
PASS duplicate_in_flight
RUN reorder_attempts
PASS reorder_attempts
RUN reorder_versions
PASS reorder_versions
RUN stale_after_new_version
PASS stale_after_new_version
PASS: lab5 pipeline suite, report evidence/final-validation-2026-11-07/delivery-targeted.json
exit_code: 0 elapsed_seconds: 191.693
@@ -0,0 +1,53 @@
date: 2026-11-06T21:26:59Z commit: b30e2f6a84419d1ca64525ffb40df92183cccaef
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-validation"}
$ make down
docker compose --profile bench --profile tools --profile reconcile down
Container mtusi2026lab5-api-2 Stopping
Container mtusi2026lab5-worker-1 Stopping
Container mtusi2026lab5-lb-1 Stopping
Container mtusi2026lab5-relay-1 Stopping
Container mtusi2026lab5-api-1 Stopping
Container mtusi2026lab5-worker-1 Stopped
Container mtusi2026lab5-worker-1 Removing
Container mtusi2026lab5-worker-1 Removed
Container mtusi2026lab5-relay-1 Stopped
Container mtusi2026lab5-relay-1 Removing
Container mtusi2026lab5-lb-1 Stopped
Container mtusi2026lab5-lb-1 Removing
Container mtusi2026lab5-relay-1 Removed
Container mtusi2026lab5-broker-1 Stopping
Container mtusi2026lab5-lb-1 Removed
Container mtusi2026lab5-broker-1 Stopped
Container mtusi2026lab5-broker-1 Removing
Container mtusi2026lab5-broker-1 Removed
Container mtusi2026lab5-api-2 Stopped
Container mtusi2026lab5-api-2 Removing
Container mtusi2026lab5-api-1 Stopped
Container mtusi2026lab5-api-1 Removing
Container mtusi2026lab5-api-2 Removed
Container mtusi2026lab5-api-1 Removed
Container mtusi2026lab5-migrate-1 Stopping
Container mtusi2026lab5-s3-init-1 Stopping
Container mtusi2026lab5-valkey-1 Stopping
Container mtusi2026lab5-migrate-1 Stopped
Container mtusi2026lab5-migrate-1 Removing
Container mtusi2026lab5-s3-init-1 Stopped
Container mtusi2026lab5-s3-init-1 Removing
Container mtusi2026lab5-migrate-1 Removed
Container mtusi2026lab5-postgres-1 Stopping
Container mtusi2026lab5-s3-init-1 Removed
Container mtusi2026lab5-s3-1 Stopping
Container mtusi2026lab5-postgres-1 Stopped
Container mtusi2026lab5-postgres-1 Removing
Container mtusi2026lab5-postgres-1 Removed
Container mtusi2026lab5-valkey-1 Stopped
Container mtusi2026lab5-valkey-1 Removing
Container mtusi2026lab5-s3-1 Stopped
Container mtusi2026lab5-s3-1 Removing
Container mtusi2026lab5-valkey-1 Removed
Container mtusi2026lab5-s3-1 Removed
Network mtusi2026lab5_backend Removing
Network mtusi2026lab5_edge Removing
Network mtusi2026lab5_backend Removed
Network mtusi2026lab5_edge Removed
exit_code: 0 elapsed_seconds: 3.346
@@ -0,0 +1,8 @@
export COMPOSE_PROJECT_NAME=mtusi2026lab5
export COMPOSE_FILE=compose.yaml
export API_IMAGE=mtusi-messenger:lab5-validation
export LB_HTTP_PORT=18085
export LB_STATS_PORT=25085
export BROKER_MANAGEMENT_PORT=25086
export BASE_URL=http://127.0.0.1:18085
export NO_PROXY=localhost,127.0.0.1,::1
@@ -0,0 +1,15 @@
date: 2026-11-06T21:26:59Z commit: b30e2f6a84419d1ca64525ffb40df92183cccaef
environment: {"COMPOSE_PROJECT_NAME": "mtusi2026lab5", "COMPOSE_FILE": "compose.yaml", "LB_HTTP_PORT": "18085", "LB_STATS_PORT": "25085", "BASE_URL": "http://127.0.0.1:18085", "NO_PROXY": "localhost,127.0.0.1,::1", "API_IMAGE": "mtusi-messenger:lab5-validation"}
$ docker compose ps -a --format '{{.Name}} {{.ID}} {{.State}} {{.Status}} {{.Ports}}'
mtusi2026lab5-api-1 fc7d65385119 running Up 10 minutes (healthy)
mtusi2026lab5-api-2 a5411e55f06d running Up 10 minutes (healthy)
mtusi2026lab5-broker-1 a38bbcf03870 running Up 10 minutes (healthy) 127.0.0.1:25086->15672/tcp
mtusi2026lab5-lb-1 f0d01200b1f8 running Up 10 minutes (healthy) 127.0.0.1:18085->8080/tcp, 127.0.0.1:25085->8404/tcp
mtusi2026lab5-migrate-1 feca425ac0ae exited Exited (0) 8 minutes ago
mtusi2026lab5-postgres-1 9f62ea9d176b running Up 6 minutes (healthy)
mtusi2026lab5-relay-1 297a45d2724b running Up About a minute (healthy)
mtusi2026lab5-s3-1 9a7684ef147a running Up 10 minutes (healthy)
mtusi2026lab5-s3-init-1 e5825f3eeafb exited Exited (0) 8 minutes ago
mtusi2026lab5-valkey-1 e37f783f9d50 running Up 10 minutes (healthy)
mtusi2026lab5-worker-1 c708d0d22a5e running Up About a minute (healthy)
exit_code: 0 elapsed_seconds: 0.136
@@ -0,0 +1,702 @@
{
"runtime_review_equal": true,
"normative_files_equal_skeleton": true,
"new_python_syntax": "PASS",
"allowed_changed_files": 58,
"local_markdown_links": 173,
"links": [
{
"from": "REPORT.md",
"target": "evidence/README.md"
},
{
"from": "REPORT.md",
"target": "evidence/forward-port.md"
},
{
"from": "REPORT.md",
"target": "uv.lock"
},
{
"from": "REPORT.md",
"target": "evidence/sqlalchemy-2026-11-06/track2/qualified/runtime.txt"
},
{
"from": "REPORT.md",
"target": "compose.yaml"
},
{
"from": "REPORT.md",
"target": "src/messenger/shared/infrastructure/postgres.py"
},
{
"from": "REPORT.md",
"target": "alembic/env.py"
},
{
"from": "REPORT.md",
"target": "alembic/versions"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/postgres-outage-retry.json"
},
{
"from": "REPORT.md",
"target": "evidence/report-audit-2026-11-07.md"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/student-test.txt"
},
{
"from": "REPORT.md",
"target": "evidence/review-trns-depth-2026-11-06/RESULTS.md"
},
{
"from": "REPORT.md",
"target": "evidence/report-audit-2026-11-07.md"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/final-smoke.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/persistence.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/persistence-containers.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/failover.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/failover-containers.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/restore.txt"
},
{
"from": "REPORT.md",
"target": "evidence/sqlalchemy-2026-11-06/grade3/queues.txt"
},
{
"from": "REPORT.md",
"target": "evidence/sqlalchemy-2026-11-06/grade3/consumers.txt"
},
{
"from": "REPORT.md",
"target": "evidence/sqlalchemy-2026-11-06/grade3/permissions.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/level4.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/level4.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/level4.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/level4.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/level4.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/level4.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/level4.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/level4-command.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/level4.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/track-run1.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/track-run2.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/track-run3.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/network-regressions.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/upload-negative.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/cache-outage.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/haproxy-errors.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/level4.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/down.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/stopped-containers.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/retained-volumes.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/down.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/stopped-containers.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/retained-volumes.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/track-run1.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/track-run1.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/track-run2.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/track-run2.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/track-run3.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/track-run3.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/summary.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/conditions-before.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/conditions-track-start.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/clock-observation.json"
},
{
"from": "REPORT.md",
"target": "evidence/sqlalchemy-2026-11-06/track2/qualified/RESULTS.md"
},
{
"from": "REPORT.md",
"target": "evidence/review-trns-depth-2026-11-06/findings.json"
},
{
"from": "REPORT.md",
"target": "evidence/sqlalchemy-2026-11-06/grade3/limits.txt"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/findings.json"
},
{
"from": "REPORT.md",
"target": "evidence/forward-final-2026-11-06/student-test.txt"
},
{
"from": "REPORT.md",
"target": "evidence/load-validation.md"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/checks.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/openspec.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/build.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/image-runtime.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/smoke.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/postgres-outage-retry.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/postgres-outage-retry.json"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/png-http.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/png-http.json"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/delivery-targeted.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/delivery-targeted.json"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/png-limits.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/png-limits.json"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/fixtures"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/png-limits.json"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/cleanup-recheck.json"
},
{
"from": "REPORT.md",
"target": "openspec/specs/lab5-image-variants/spec.md"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/resource-probe-worker.txt"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/findings.json"
},
{
"from": "REPORT.md",
"target": "evidence/final-validation-2026-11-07/RESULTS.md"
},
{
"from": "AGENTS.md",
"target": "evidence/README.md"
},
{
"from": "AGENTS.md",
"target": "REPORT.md"
},
{
"from": "AGENTS.md",
"target": "evidence/load-validation.md"
},
{
"from": "AGENTS.md",
"target": "evidence/final-validation-2026-11-07/RESULTS.md"
},
{
"from": "evidence/README.md",
"target": "../REPORT.md"
},
{
"from": "evidence/README.md",
"target": "load-validation.md"
},
{
"from": "evidence/README.md",
"target": "final-validation-2026-11-07/RESULTS.md"
},
{
"from": "evidence/README.md",
"target": "final-validation-2026-11-07/RESULTS.md"
},
{
"from": "evidence/README.md",
"target": "load-validation.md"
},
{
"from": "evidence/README.md",
"target": "report-audit-2026-11-07.md"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/RESULTS.md"
},
{
"from": "evidence/README.md",
"target": "review-trns-depth-2026-11-06/RESULTS.md"
},
{
"from": "evidence/README.md",
"target": "review-fixes-2026-11-06/RESULTS.md"
},
{
"from": "evidence/README.md",
"target": "forward-port.md"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/source-inventory.json"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/forward-audit.json"
},
{
"from": "evidence/README.md",
"target": "sqlalchemy-2026-11-06/grade3/NOTES.md"
},
{
"from": "evidence/README.md",
"target": "sqlalchemy-2026-11-06/grade4/NOTES.md"
},
{
"from": "evidence/README.md",
"target": "sqlalchemy-2026-11-06/track2/NOTES.md"
},
{
"from": "evidence/README.md",
"target": "sqlalchemy-2026-11-06/track2/qualified/RESULTS.md"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/level4-command.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/level4.json"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/track-run1.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/track-run1.json"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/track-run2.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/track-run2.json"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/track-run3.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/track-run3.json"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/summary.json"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/final-smoke.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/persistence.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/failover.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/persistence-containers.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/failover-containers.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/restore.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/student-test.txt"
},
{
"from": "evidence/README.md",
"target": "review-trns-depth-2026-11-06/offline-tests.txt"
},
{
"from": "evidence/README.md",
"target": "review-trns-depth-2026-11-06/boundaries.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/conditions-before.json"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/conditions-track-start.json"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/down.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/stopped-containers.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/retained-volumes.txt"
},
{
"from": "evidence/README.md",
"target": "sqlalchemy-2026-11-06/grade3/limits.txt"
},
{
"from": "evidence/README.md",
"target": "forward-final-2026-11-06/clock-observation.json"
},
{
"from": "evidence/README.md",
"target": "review-trns-depth-2026-11-06/findings.json"
},
{
"from": "evidence/README.md",
"target": "review-trns-depth-2026-11-06/RESULTS.md"
},
{
"from": "evidence/README.md",
"target": "review-fixes-2026-11-06/RESULTS.md"
},
{
"from": "evidence/load-validation.md",
"target": "forward-final-2026-11-06/RESULTS.md"
},
{
"from": "evidence/load-validation.md",
"target": "final-validation-2026-11-07/RESULTS.md"
},
{
"from": "evidence/load-validation.md",
"target": "final-validation-2026-11-07/findings.json"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "../load-validation.md"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "audit.json"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "historical-hashes.json"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "runtime-containers.json"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "image-runtime.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "env.sh"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "checks.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "student-test.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "openspec.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "active-changes.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "build.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "up.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "smoke.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "policy.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "queues.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "postgres-outage-retry.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "postgres-outage-retry.json"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "postgres-outage-worker.log"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "png-http.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "png-http.json"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "delivery-targeted.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "delivery-targeted.json"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "png-limits.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "png-limits.json"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "fixtures"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "targeted.py"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "postgres-outage.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "targeted-initial.py"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "cleanup-recheck.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "../../openspec/specs/lab5-image-variants/spec.md"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "resource-probe-worker.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "resource-probe-retry.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "invoke-probe.py"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "findings.json"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "down.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "stopped-containers.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "retained-volumes.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "running-containers-after.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "checks-final.txt"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "final-doc-audit.json"
},
{
"from": "evidence/final-validation-2026-11-07/RESULTS.md",
"target": "secret-scan.json"
}
],
"all_link_targets_tracked": true
}
@@ -0,0 +1,37 @@
[
{
"severity": "major",
"file": "src/messenger/attachments/infrastructure/images.py:95",
"problem": "Не проходит объявленный обязательный сценарий openspec/specs/lab5-image-variants/spec.md:48: PNG 8000×5000 со штатными пределами должен стать ready. Через LB четыре валидных tRNS PNG (grayscale 2/4/16 и RGB16, 35 759–385 445 байт) получают 202, затем failed/processing_failed на attempt=1 при RENDER_MEMORY_MB=448 и timeout=30. Linux-пробник с импортами worker воспроизводит MemoryError в rgb_mask/apply_png_transparency и flatten; без tRNS gray2/gray4/RGB16 проходят, gray16 требует памяти и без tRNS. Worker остаётся жив; потери данных/падение сервиса не заявляются. Доказательства: evidence/final-validation-2026-11-07/png-limits.json, resource-probe-worker.txt, fixtures/*.png. Нужен отдельный fix, review и повтор только затронутых PNG/ресурсных проверок."
},
{
"severity": "minor",
"file": "src/messenger/attachments/application/pipeline.py:230",
"problem": "Сохранено из ревью 544b9c78d39d0e9dd07f841894c390895896605a: after_publish_before_confirm вызывается после publish(), уже проверившего Basic.Ack. crash_publish_confirm доказывает сбой после confirm до COMMIT outbox, а не потерю подтверждения."
},
{
"severity": "minor",
"file": "scripts/limits.py:10",
"problem": "Сохранено из первого ревью: S3_CLIENT_SECRETS не отсортирован, сравнение с sorted(secrets) даёт ложные FAIL. evidence/sqlalchemy-2026-11-06/grade3/limits.txt содержит exit_code=1; этот запуск нельзя обозначать PASS."
},
{
"severity": "minor",
"file": "scripts/reconcile_track.py:396",
"problem": "Сохранено из первого ревью: демонстратор ожидает upload 201 и attachments/, поэтому непригоден для квалификации ЛР5 с 202 queued. Текущие pipeline evidence его не используют."
},
{
"severity": "minor",
"file": "src/messenger/attachments/application/pipeline.py:333",
"problem": "Сохранено из первого ревью: failed upgrade v2 при опубликованной ready v1 нельзя отдельно повторить через replay/reprocess. V1 остаётся доступной; подтверждение исходного ревью — test_failed_new_version_keeps_ready_original."
},
{
"severity": "minor",
"file": "evidence/forward-final-2026-11-06/clock-observation.json",
"problem": "Сохранено из первого ревью: в повторах 2/3 UTC-интервалы расходятся с elapsed (1161.195/186.458 с и 571.513/180.259 с). Причина не установлена; длительности исключены из выводов о производительности."
},
{
"severity": "minor",
"file": "openspec/config.yaml:130",
"problem": "Сохранена документационная неточность: design требует upload 201 вместо нормативного 202 ЛР5; конфиг вне scope validation."
}
]
Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Some files were not shown because too many files have changed in this diff Show More