arch-v1
arch-v2-aws
arch-v2-self
1a · Uploadarch-v1
A client hands LexSelect a document to process in one multipart request: this is how it enters the platform. The upload by link (sequence 1b) takes the document in two requests.
- multipart: streams the file through the gateway straight into S3 (1a.14)
- multipart: records the upload job and creates the document in DocumentDB (1a.9, 1a.20)
- 1a.1The client resolves
api.lexselect.io; Route 53 answers with the load balancer's A/AAAA alias. iac/aws-ecs.tf:59
- 1a.2HTTPS
POST /api/documents/upload as multipart/form-data, with a Bearer API key. The WAF exempts this path from three blocks: the 8 KB body-size rule, the common set's body-text rules (XSS, file inclusion, SSRF) and the SQL-injection body rule. The ALB terminates TLS on HTTPS :443. iac/waf.tf:18; iac/waf.tf:231; iac/waf.tf:316; iac/waf.tf:492; iac/aws-ecs.tf:544–545
- 1a.3The
/api* listener rule forwards to web-hooks-service. iac/aws-ecs.tf:503
- 1a.4The gateway spends one token of the client IP's budget (300 per 60 s,
lexselect:extapi:ip:{ip}; a Valkey failure also answers 429), then checks the API key in the Valkey cache (lexselect:extapi:key:{sha256}, 60 s). A verified key refunds the IP token; an unknown or expired key gets 401. On a cache miss it validates the key over the same RPC path and worker-api reads extapi_keys. The per-key and per-user rate limits and the concurrency leases follow (the limiters answer 429 when a budget is spent). The upload-link route (1b.5) hands a multipart body on; then the idempotency replay and the upload handler, which turns away a key whose page quota is spent (403). services/web-hooks-service/src/extapi/router.ts:119; services/web-hooks-service/src/extapi/middleware/ipRateLimit.ts:134–145; services/web-hooks-service/src/extapi/middleware/ipRateLimit.ts:171–183; services/web-hooks-service/src/extapi/middleware/ipRateLimit.ts:198–209; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:71; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:107; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:131; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:188–200; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:328–332; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:346; services/web-hooks-service/src/extapi/router.ts:129–133; services/web-hooks-service/src/extapi/router.ts:137–140; services/web-hooks-service/src/extapi/uploadHandler.ts:257–273
- 1a.5Create: after checking the name's extension (pdf, doc, docx, rtf, msg, eml or odt; 415 otherwise) and a declared size over 500 MiB (413), the gateway sends
POST /documents over RabbitMQ extapi-orchestrator-v1 (default exchange; routing key in the body; reply to an exclusive reply queue). It tags the call x-internal-upload, which worker-api's gate for POST and PUT /documents requires, and forwards the client's Idempotency-Key. services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:142; services/web-hooks-service/src/extapi/uploadHandler.ts:381–389; services/web-hooks-service/src/extapi/uploadHandler.ts:415; services/web-hooks-service/src/extapi/uploadHandler.ts:158–163; services/engine/microservices/worker_api/tasks_v2/extapi/request.py:127–140
- 1a.6The orchestrator consumes the RPC queue. services/engine/microservices/orchestrator/core/orchestrator_extapi_v1.py:92
- 1a.7The orchestrator kicks
task_extapi_request_v1 onto the taskiq stream worker_api in Valkey and waits for its result. services/engine/microservices/orchestrator/controllers/extapi/request.py:46
- 1a.8worker-api reads the stream and runs
handle_document_create. services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:829
- 1a.9worker-api validates the upload fields (
parse_upload_fields): the name (up to 255 characters), its extension, parent_id and strip_file_name (400); with ocr_format it also requires a PDF and an account with OCR import enabled (400, 403). It reads the key's user from users. With an Idempotency-Key the job id is a uuid5 of the user and the key, and a repeat finds the earlier job: a document that already exists is answered with 200 (status: completed; an unfinished one is first re-checked against the byte ceiling and its processing triggered), a pending upload with 409 upload_in_progress while the first signed URL is live (a link expired for over 15 minutes with no document is discarded, and the key starts a fresh upload), and different metadata with 409 upload_conflict. admit_new_upload then checks the declared size against the byte ceiling (the global document limit, or a smaller trial entitlement cap; 413, and 503 when the policy cannot be read), turns the upload away while intake drains (503 DOCUMENT_QUEUE_DRAINING) and, with the queue enabled, when the user's or workspace's waiting queue is full (429 queue_full). It checks the page quota's headroom: a trial entitlement's pages in api_usage_ledger plus those booked in Valkey (403 at the limit), or a personal wallet in DocumentDB (402, 403, 409). It resolves the parent through FS: the named folder or project (400 when absent, deleted or of another type; 404 when another user owns it), or the user's Default Project, created when none is named. FS mints the storage key {uuid4}.{ext} (with strip_file_name true, the default, the document's name is a fresh {uuid4}.{ext} too), records the upload job in fs_jobs under the job id, which the gateway carries to the complete call, and signs a presigned S3 PUT URL, limited to the declared size or to the ceiling when none is declared (and a second one for a client OCR file). services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:829–992; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:681–723; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:731–826; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:577–663; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:146–171; services/engine/microservices/worker_api/tasks_v2/extapi/upload_replay.py:28; services/engine/microservices/worker_api/tasks_v2/extapi/upload_replay.py:51; services/engine/shared/helpers/document_upload_size.py:49; services/engine/shared/services/document_queue_policy_reads.py:53; services/engine/microservices/worker_api/tasks_v2/extapi/_helpers.py:36–64; services/engine/shared/entities/fs/job.py:96
- 1a.10worker-api returns the upload URL; taskiq stores it in the Valkey result backend. services/engine/shared/connectors/taskiq.py:383
- 1a.11The orchestrator's
wait_result reads it, waiting at most ENGINE_GENERAL_ACTION_TIMEOUT (80 s by default); on expiry it replies 504. services/engine/microservices/orchestrator/controllers/extapi/request.py:61; services/engine/microservices/orchestrator/controllers/extapi/request.py:79–94; services/engine/shared/config.py:426
- 1a.12The orchestrator publishes the reply to the gateway's reply queue, with the same correlation id. services/engine/microservices/orchestrator/core/event_extapi_base.py:51
- 1a.13The gateway's reply consumer receives the presigned URL. services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:44
- 1a.14The gateway enforces the upload policy (at most 500 MiB) and streams the body to the FS bucket
…-documents-upload as it arrives: with the presigned PUT when the body has a size or ends inside one 8 MiB part, else as an S3 multipart upload, one part in flight. For that, it sends POST /documents/{job_id}/multipart over the same RPC path, and worker-api opens the upload on the job's key, signs part URLs in batches and completes it from the part ETags (or aborts it). The client's OCR file goes the same way to {storage_key}.ocr-upload. Only a part that outgrows 8 MiB before name arrives is spooled to bounded temporary disk first. A gateway process takes 64 uploads at once (API_UPLOAD_MAX_ACTIVE) and its spool holds 2 GiB; beyond either, or when the disk is short, it answers 503. services/web-hooks-service/src/extapi/uploadHandler.ts:552; services/web-hooks-service/src/extapi/uploadHandler.ts:510; services/web-hooks-service/src/extapi/uploadMultipart.ts:187; services/web-hooks-service/src/extapi/uploadStorage.ts:13; services/engine/microservices/worker_api/tasks_v2/extapi/upload_multipart.py:123; services/engine/shared/entities/document_storage.py:641; services/engine/shared/ocr_import/store.py:40; services/web-hooks-service/src/extapi/uploadSpool.ts:39; services/web-hooks-service/src/config.ts:171; services/web-hooks-service/src/config.ts:177–180
- 1a.15Complete: the gateway sends
PUT /documents/{job_id} with status=uploaded and the SHA-256 over RabbitMQ extapi-orchestrator-v1 (default exchange; routing key in the body; reply to an exclusive reply queue). It tags the call x-internal-upload, which worker-api's gate for POST and PUT /documents requires. services/web-hooks-service/src/extapi/uploadHandler.ts:863; services/web-hooks-service/src/extapi/uploadHandler.ts:158–163; services/engine/microservices/worker_api/tasks_v2/extapi/request.py:127–140
- 1a.16The orchestrator consumes it. services/engine/microservices/orchestrator/core/orchestrator_extapi_v1.py:92
- 1a.17The orchestrator kicks
task_extapi_request_v1 on the taskiq stream worker_api. services/engine/microservices/orchestrator/controllers/extapi/request.py:46
- 1a.18worker-api runs
handle_document_update, the upload-complete task. It checks status and the SHA-256 field (400), reads the user from users, finds the upload_file job (404 for another user's or another kind) and answers 200 with the document at once when the job is complete or its document already holds a queue claim. Otherwise it holds the upload while the queue drains (503 DOCUMENT_QUEUE_DRAINING), reads the API keys and the workspace policy from DocumentDB, and turns the upload away when the account's workspace changed (409 WORKSPACE_CONTEXT_CHANGED) or, until the managed queue is on, when the effective concurrency limit is 0 (429 PROCESSING_PAUSED). services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1236; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1274; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1298–1336; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1337–1342; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1874–1916; services/engine/shared/services/api_limit_context.py:173–199; services/engine/microservices/worker_api/tasks_v2/extapi/_helpers.py:87–89
- 1a.19FS storage, in
accept_uploaded_document, checks the object with S3 HEAD, rejects one over the account's byte ceiling (413), and compares its SHA-256 with the one the gateway sent. S3 stores no checksum for these uploads (the presigned URL carries none), so it downloads and hashes the object. A client OCR file is imported to {storage_key}.ocr.v1.json.gz. services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1058; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1092; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1107; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:265–290; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:929–935; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1153–1159
- 1a.20
accept_uploaded_document goes on: FS creates the document in fs_items under a new document id (the job id stays on the row; create_item_auto_rename resolves name clashes; create_item counts files_created on the user). worker-api inserts the document's one open retention row into document_deletion_queue, due 24 h after upload; the earlier of this deadline and the 1 h deadline after processing ends (S.31) holds. It then triggers processing (2.1): a document that already holds a queue claim is only republished, and a draining queue answers 503. With the queue enabled, accept_document records the waiting claim in document_queue_claims (capacity rechecked in a transaction, enterprise billing admission claimed there; 403 when closed) and publish_document_claim publishes the trigger from the claim; before the queue is activated, the legacy path claims billing admission and publishes the trigger itself. Back in handle_document_update, worker-api marks the fs_jobs row complete and queues the document.processing.queued webhook (2.2). services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1181; services/engine/shared/entities/fs/item.py:436; services/engine/shared/entities/fs/item.py:354; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1206; services/engine/microservices/worker_api/tasks_v2/document_deletion/producers.py:249–274; services/engine/microservices/worker_api/tasks_v2/document_deletion/producers.py:304–367; services/engine/microservices/worker_api/tasks_v2/document_deletion/constants.py:42; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1222; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1372; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:491–501; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:556–569; services/engine/microservices/worker_api/tasks_v2/extapi/legacy_upload_trigger.py:7; services/engine/shared/services/document_queue_admission.py:23; services/engine/shared/services/document_queue_recovery.py:13; services/engine/shared/services/document_queue_store.py:10; services/engine/shared/services/document_queue_activation.py:42
- 1a.21worker-api returns the document; taskiq stores it in the Valkey result backend. services/engine/shared/connectors/taskiq.py:383
- 1a.22The orchestrator's
wait_result reads it, waiting at most ENGINE_GENERAL_ACTION_TIMEOUT (80 s by default); on expiry it replies 504. services/engine/microservices/orchestrator/controllers/extapi/request.py:61; services/engine/microservices/orchestrator/controllers/extapi/request.py:79–94; services/engine/shared/config.py:426
- 1a.23The orchestrator publishes the reply to the gateway's reply queue. services/engine/microservices/orchestrator/core/event_extapi_base.py:51
- 1a.24The gateway's reply consumer receives it. services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:44
- 1a.25The gateway relays the reply,
200 with the document; processing is queued. services/web-hooks-service/src/extapi/uploadHandler.ts:883–887
1b · Upload by linkarch-v1
The client sends the document's details as JSON and gets presigned S3 links; the file landing in the bucket starts processing.
- answers with the document and presigned PUT links once the create step's checks pass (1b.4–1b.14)
- records the upload job and signs one link for the original and one for the OCR file (1b.9)
- takes the client's PUTs straight into S3, whose event reaches worker-api through an SQS queue (1b.15–1b.16)
- lands the upload, creates the document and sends the processing request (1b.17, 2.1); a sweep lands an upload whose event was lost and expires an unused link (1b.18)
- 1b.1The client resolves
api.lexselect.io as in 1a.1. iac/aws-ecs.tf:59
- 1b.2HTTPS
POST /api/documents/upload with Content-Type: application/json: the document's name and exact byte size, optionally parent_id, strip_file_name, ocr_format with ocr_size, a Bearer API key and X-API-Version: 2026-12-01 (the version of a request without the header too). The WAF exempts this path from the three blocks named in 1a.2. The ALB terminates TLS on HTTPS :443. services/web-hooks-service/openapi.yaml:985; services/web-hooks-service/openapi.yaml:3910; iac/waf.tf:18; iac/waf.tf:231; iac/waf.tf:316; iac/waf.tf:492; iac/aws-ecs.tf:544–545
- 1b.3The
/api* listener rule forwards to web-hooks-service. iac/aws-ecs.tf:503
- 1b.4The gateway spends one token of the client IP's budget (300 per 60 s,
lexselect:extapi:ip:{ip}; a Valkey failure also answers 429), then checks the API key in the Valkey cache (lexselect:extapi:key:{sha256}, 60 s). A verified key refunds the IP token; an unknown or expired key gets 401. On a cache miss it validates the key over the same RPC path and worker-api reads extapi_keys. The per-key and per-user rate limits and the concurrency leases follow (the limiters answer 429 when a budget is spent). The upload-link route follows, above the idempotency cache (1b.5). services/web-hooks-service/src/extapi/router.ts:119; services/web-hooks-service/src/extapi/middleware/ipRateLimit.ts:134–145; services/web-hooks-service/src/extapi/middleware/ipRateLimit.ts:171–183; services/web-hooks-service/src/extapi/middleware/ipRateLimit.ts:198–209; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:71; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:107; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:131; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:188–200; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:328–332; services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:346; services/web-hooks-service/src/extapi/router.ts:129–133; services/web-hooks-service/src/extapi/router.ts:137–140; services/web-hooks-service/src/extapi/uploadLinkHandler.ts:91–92
- 1b.5For a JSON body the upload-link route, mounted above the idempotency cache, sends
POST /documents/upload over RabbitMQ extapi-orchestrator-v1 (default exchange; routing key in the body; reply to an exclusive reply queue) with the body as received. It tags the call x-internal-upload and forwards the client's Idempotency-Key and X-API-Version. A key whose page quota is spent (403) and a body that is not JSON go to the multipart handler (1a.5). services/web-hooks-service/src/extapi/router.ts:137–140; services/web-hooks-service/src/extapi/uploadLinkHandler.ts:91–92; services/web-hooks-service/src/extapi/uploadLinkHandler.ts:98–108; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:142; services/web-hooks-service/src/extapi/uploadHandler.ts:158–163
- 1b.6The orchestrator consumes the RPC queue. services/engine/microservices/orchestrator/core/orchestrator_extapi_v1.py:92
- 1b.7The orchestrator kicks
task_extapi_request_v1 onto the taskiq stream worker_api in Valkey and waits for its result. services/engine/microservices/orchestrator/controllers/extapi/request.py:46
- 1b.8worker-api reads the stream, and
task_extapi_request_v1 sends POST /documents/upload with x-internal-upload to handle_document_upload_link. A version older than 2026-12-01, or a deployment without the events queue, answers multipart_only. Otherwise it checks the JSON fields (400, 415; size is required, and ocr_size, up to 128 MiB, goes with ocr_format) and runs the create step's checks in their order (1a.9): the shared field parsing, the OCR rules (400, 403), the Idempotency-Key (the same uuid5 job id; a repeat replays the earlier upload and different metadata answers 409) and admit_new_upload. services/engine/microservices/worker_api/tasks_v2/extapi/request.py:287–300; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_link.py:193; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_link.py:208; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_link.py:99; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_link.py:139; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:681; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:155; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_link.py:241; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_replay.py:69; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:731
- 1b.9FS records the upload in
fs_jobs (operation: api_direct_upload): the document id reserved now, the object key api-uploads/{document_id}.{ext}, the key context the landing needs later, the declared size, SHA-256 and OCR size, the link's expiry and the landing state (api_upload). worker-api signs two 15-minute PUT links, one for the original and, with ocr_format, one for the OCR file ({key}.ocr-upload). They bind Content-Type, Content-Length and If-None-Match: *, so S3 refuses a body of another size or type and a second write; a signature that misses one of the three is never handed out. services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_link.py:294–335; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_replay.py:21; services/engine/shared/entities/document_storage.py:537; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_store.py:58; services/engine/shared/entities/fs/job.py:96; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload.py:95; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload.py:131
- 1b.10worker-api returns the answer; taskiq stores it in the Valkey result backend. services/engine/shared/connectors/taskiq.py:383
- 1b.11The orchestrator's
wait_result reads it, waiting at most ENGINE_GENERAL_ACTION_TIMEOUT (80 s by default); on expiry it replies 504. services/engine/microservices/orchestrator/controllers/extapi/request.py:61; services/engine/microservices/orchestrator/controllers/extapi/request.py:79–94; services/engine/shared/config.py:426
- 1b.12The orchestrator publishes the reply to the gateway's reply queue, with the same correlation id. services/engine/microservices/orchestrator/core/event_extapi_base.py:51
- 1b.13The gateway's reply consumer receives the answer. services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:44
- 1b.14The gateway relays the answer with
Cache-Control: no-store: 201 with the document (upload_status: uploading), upload (the URL, the method, the headers to send and the expiry) and, when ocr_format was sent, ocr_upload. On multipart_only, and on a 404 from an engine without the JSON route, it hands the request to the multipart handler, which answers its 400. services/web-hooks-service/src/extapi/uploadLinkHandler.ts:54–75; services/web-hooks-service/src/extapi/uploadLinkHandler.ts:109–116; services/web-hooks-service/openapi.yaml:3926
- 1b.15The client PUTs the OCR file first, when it declared one, and the original second, to the links, with the headers the answer lists. The original lands in the FS bucket
…-documents-upload at api-uploads/{document_id}.{ext}, the OCR file at {key}.ocr-upload; a second write to a key is refused. services/engine/shared/entities/document_storage.py:537; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload.py:95; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload.py:131; services/web-hooks-service/openapi.yaml:3926
- 1b.16The bucket notification sends an
s3:ObjectCreated:Put message to the upload events queue for each object created under api-uploads/; a message that fails five receives moves to the queue's dead-letter queue. iac/api_upload_events.tf:121–133; iac/api_upload_events.tf:71; iac/api_upload_events.tf:60
- 1b.17worker-api's
run_direct_upload_events long-polls the queue (20 s) and maps each key to its job by the document id. land_direct_upload takes one claim on the job and lands the upload: it probes the object, then accept_uploaded_document (1a.19, 1a.20) compares its size with the declared one, hashes it (against the declared SHA-256 when one was sent), imports the OCR file (absent: the document goes through our own OCR), creates the document under the reserved id, records its 24 h retention row and triggers processing (2.1). worker-api then queues document.processing.queued (2.2), marks the job accepted and deletes the message. services/engine/microservices/worker_api/entrypoint.py:558–563; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_events.py:149; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_events.py:95; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_events.py:69; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_landing.py:324; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_store.py:134; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_landing.py:226; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_landing.py:247; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_landing.py:266; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1058
- 1b.18worker-api's upload sweep,
run_direct_upload_sweep (started with the worker, whether or not the events queue is set), reads the due rows of fs_jobs every 30 s. It lands an upload whose event was lost, probing the bucket from 120 s after the link, and expires one whose link and 15-minute grace passed with no file, deleting its objects; no webhook follows. It deletes a failed or expired upload's objects once more, removes its row after 24 h and takes over a claim whose worker died. services/engine/microservices/worker_api/entrypoint.py:551–556; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_sweep.py:94; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_sweep.py:56; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_sweep.py:31; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_landing.py:311; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_landing.py:197; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload.py:65; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload.py:70
1b · Upload by linkarch-v2-aws
On AWS, arch-v2-aws takes a file only through a link: arch-v1's ALB sends the JSON upload of the pilot's X-API-Version to its function 1b-upload-by-link, and the client puts the file straight into its Bucket (N1b.9–N1b.19). The same upload by link on API gateway v2 self-hosted: the link points at its own RustFS bucket, the file's put event reaches API gateway v2's own route, and the document record and the upload job stay in its own MongoDB.
- N1b.9The v1 link, in the legacy account, copies what v2's identity and admission ports read (API keys, users, policies and workspaces) from arch-v1's DocumentDB into arch-v2-aws's Database, one way, so nothing in arch-v2-aws calls arch-v1. It carries no usage and no billing data: the accounting block of v2 bills the runs (ADR 075). What it copies, how, how fast a change arrives and how it reaches
lexselect-prod are still open (item 16). M1 docs/lex-arch-v2/16-standalone-v2.md:28–36; docs/lex-arch-v2/16-standalone-v2.md:38–48; docs/lex-arch-v2/16-standalone-v2.md:51–56; docs/research/2026-11-05-aws-platform-v2.md:213–220
- N1b.10arch-v1's ALB sends a request that carries the pilot's
X-API-Version, a date after 2026-12-01 still to set, a JSON Content-Type, POST and /api/documents/upload to arch-v2-aws's function 1b-upload-by-link in lexselect-prod: one listener rule matches all four; how the request crosses the accounts is still open (item 17). Every other version or none goes on to the gateway, as today: a multipart upload (1a.3–1a.25), a JSON upload under 2026-12-01 (1b.3–1b.18) and every other route. v2 knows nothing of the rule. M1 docs/lex-arch-v2/17-alb-version-rule.md:6–10; docs/lex-arch-v2/17-alb-version-rule.md:15–20; docs/lex-arch-v2/17-alb-version-rule.md:24–25; docs/lex-arch-v2/17-alb-version-rule.md:34–35; docs/lex-arch-v2/17-alb-version-rule.md:38–41; docs/research/2026-11-05-aws-platform-v2.md:239–251; services/engine--go/gateway/internal/targets/targets.go:63
- N1b.11The function
1b-upload-by-link reads the API key's tenant from arch-v2-aws's Database, where the v1 link keeps it (N1b.9), and reads the answer of the key there. It records the job in the table upload-jobs and creates the document in the table documents, waiting for its file, under the user's one project (E1). It answers one-to-one with the document a multipart upload returns, every field, plus a presigned PUT link for the file and, when the request sends ocr_format, a second link for the OCR file: AWS Textract JSON or LexSelectOcrV1, up to 128 MiB. M1 docs/lex-arch-v2/14-upload-on-v2.md:23–29; docs/lex-arch-v2/14-upload-on-v2.md:40–44; docs/lex-arch-v2/15-fs-and-opensearch.md:8–9; docs/lex-arch-v2/15-fs-and-opensearch.md:17; docs/lex-arch-v2/17-alb-version-rule.md:27–32; services/web-hooks-service/openapi.yaml:3895; docs/lex-arch-v2/16-standalone-v2.md:8–17; docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/lex-arch-v2/16-standalone-v2.md:28–36; docs/research/2026-11-05-aws-platform-v2.md:239–251; docs/research/2026-11-05-aws-platform-v2.md:213–220
- N1b.12The client PUTs the file to its link and, when it asked for one, its OCR file to the second link, straight into arch-v2-aws's bucket in lexselect-prod. Processing starts once they have landed. M1 docs/lex-arch-v2/14-upload-on-v2.md:40–44; docs/lex-arch-v2/17-alb-version-rule.md:27–32; docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/research/2026-11-05-aws-platform-v2.md:239–251; docs/research/2026-11-05-aws-platform-v2.md:206–211
- N1b.13The bucket sends its Object Created event to the SQS queue
object-events in the same account (ADR 092 D7). The queue holds the event until the function reads it. The bucket holds only v2 uploads, so no filter has to tell them from arch-v1's. M1 services/engine--go/gateway/internal/stackgen/store.go:139; services/engine--go/gateway/internal/connector/own/awss3/files.go:26; docs/lex-arch-v2/14-upload-on-v2.md:30–32; docs/lex-arch-v2/14-upload-on-v2.md:96–99; docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/research/2026-11-05-aws-platform-v2.md:239–251; docs/adr/ADR_092_aws_connector_set_of_api_gateway_v2.md:72–73
- N1b.14The function
1b-upload-by-link-complete reads the queue object-events as its event source and gets the Object Created event of the bucket. The trigger of the function is an object event (ADR 090 D4, ADR 092 D7). M1 services/engine--go/gateway/internal/targets/targets.go:68; services/engine--go/gateway/internal/stackgen/plan.go:113; services/engine--go/gateway/internal/stackgen/trigger.go:99; services/engine--go/gateway/internal/connector/own/awss3/events.go:15; docs/lex-arch-v2/14-upload-on-v2.md:30–32
- N1b.15The function checks the file and, when the upload declared one, the OCR file, and completes the document the JSON upload left waiting in the table
documents of arch-v2-aws's database. It writes the processing trigger, the scheduler's message, to the table outbox there. M1 docs/lex-arch-v2/14-upload-on-v2.md:30–32; docs/lex-arch-v2/14-upload-on-v2.md:55–56; docs/lex-arch-v2/14-upload-on-v2.md:100–104; docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/research/2026-11-05-aws-platform-v2.md:233–238; docs/research/2026-11-05-aws-platform-v2.md:239–251
- N1b.16The function
1b-upload-by-link-relay reads the DynamoDB Stream of the table outbox and sends each trigger to arch-v2-aws's trigger queue (D10). The function of N1b.15 also stores the webhook job of document.processing.queued for each endpoint. The job store sends a wake to the queue webhook-send, and the send function reads it. M1 services/engine--go/gateway/internal/connector/processingtrigger/awsdynamo/outbox.go:72; services/engine--go/gateway/internal/targets/targets.go:76; services/engine--go/gateway/internal/stackgen/trigger.go:115; services/engine--go/kit/serve/lambdaevents/stream.go:35; services/engine--go/gateway/internal/webhooks/emit.go:28; services/engine--go/gateway/internal/connector/own/awsdynamo/webhook_jobs.go:153; docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/research/2026-11-05-aws-platform-v2.md:239–251; docs/research/2026-11-05-aws-platform-v2.md:530
- N1b.17arch-v2-aws's own scheduler v2 reads the trigger queue and drives the processing in lexselect-prod with its own workers and the ML providers, reading a page from the client's OCR file where it covers it, writing processings, pages and results to arch-v2-aws's Database, and records there the pages it counts. It puts
document.processing.completed or failed on the SQS queue processing-events (sequence 2). M1 docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/research/2026-11-05-aws-platform-v2.md:206–211; docs/research/2026-11-05-aws-platform-v2.md:239–251
- N1b.18The function
2-processing-webhook reads the SQS queue processing-events as its event source and gets each completed or failed event of the scheduler (ADR 090 D4, ADR 092 D2). The queued event takes no queue: the function of N1b.15 stores its job. M1 services/engine--go/gateway/internal/stackgen/model.go:120; services/engine--go/gateway/internal/stackgen/trigger.go:99; services/engine--go/gateway/internal/connector/processingevents/awssqs/consumer.go:25; services/engine--go/gateway/internal/app/aws.go:135; services/engine--go/gateway/internal/targets/targets.go:84; docs/lex-arch-v2/14-upload-on-v2.md:105–108; docs/research/2026-11-05-aws-platform-v2.md:239–251
- N1b.19The function
2-processing-webhook makes one delivery job for each endpoint that takes the event, and the function 2-processing-webhook-send signs the event with the tenant's secret, read from arch-v2-aws's Database, as arch-v1 does (X-Webhook-Signature, HMAC-SHA256), and posts it to the client's webhook endpoint. When a job is due, the job store sends a wake to the SQS queue webhook-send, and the send function reads it (ADR 092 D7). A job that is due in more than 15 minutes waits in EventBridge Scheduler, which then puts the wake on the queue. A timer of one minute is the floor. M1 services/engine--go/gateway/internal/connector/own/awsdynamo/webhook_wake.go:49; services/engine--go/gateway/internal/connector/own/awsdynamo/webhook_wake.go:98; services/engine--go/gateway/internal/stackgen/model.go:146; services/engine--go/gateway/internal/webhooks/module.go:100; docs/lex-arch-v2/14-upload-on-v2.md:105–108; docs/lex-arch-v2/16-standalone-v2.md:8–17; docs/research/2026-11-05-aws-platform-v2.md:239–251; services/engine--go/gateway/internal/targets/targets.go:89; services/engine--go/gateway/internal/targets/targets.go:89
1b · Upload by linkarch-v2-self
On AWS, arch-v2-aws takes a file only through a link: arch-v1's ALB sends the JSON upload of the pilot's X-API-Version to its function 1b-upload-by-link, and the client puts the file straight into its Bucket (N1b.9–N1b.19). The same upload by link on API gateway v2 self-hosted: the link points at its own RustFS bucket, the file's put event reaches API gateway v2's own route, and the document record and the upload job stay in its own MongoDB.
- reads the key record and answers the JSON upload with the waiting document and a RustFS link (N1b.1–N1b.3)
- hears the put event, writes the document record and puts the trigger on the stream (N1b.4–N1b.7)
- sends the queued webhook (N1b.8)
- N1b.1A client sends the JSON upload under
2026-12-01 to API gateway v2; the answer is the waiting document and a presigned PUT link to API gateway v2's own RustFS bucket, field for field as today. M1 services/engine--go/gateway/internal/routes/upload/link.go:25; services/engine--go/gateway/internal/routes/upload/link.go:48; services/engine--go/gateway/internal/routes/upload/link_answer.go:43; services/engine--go/gateway/internal/connector/own/objects/objects.go:96; docs/adr/ADR_067_api_v2_self_serve_go.md:49–62; docs/adr/ADR_071_gateway_owns_its_data.md:36–49; contracts/public-api/v1/versions.go:5; contracts/public-api/v1/versions.go:21
- N1b.2API gateway v2 reads the key record through the
access contract. The record says yes or no, and it gives the size limit of a file. API gateway v2 reads no user data. M1 services/engine--go/gateway/internal/gateway/auth.go:48; services/engine--go/gateway/internal/keys/cache.go:101; services/engine--go/gateway/internal/connector/access/valkeycopy/reader.go:42; services/engine--go/gateway/internal/routes/upload/admit.go:18; docs/adr/ADR_071_gateway_owns_its_data.md:51–56; docs/adr/ADR_071_gateway_owns_its_data.md:104–107; contracts/access/v2/interface.go:16–84; contracts/access/v2/interface.go:89–122
- N1b.3It checks the size and the parent, then keeps the upload job and the id of the new document in its own MongoDB. M1 services/engine--go/gateway/internal/routes/upload/link.go:121; services/engine--go/gateway/internal/routes/upload/link.go:149; services/engine--go/gateway/internal/connector/own/mongo/store.go:89; docs/adr/ADR_071_gateway_owns_its_data.md:58–61
- N1b.4The client PUTs the file to the link, into the
api-uploads/ prefix of its own RustFS bucket. M1 services/engine--go/gateway/internal/routes/upload/link_answer.go:19; services/engine--go/gateway/internal/connector/own/objects/objects.go:96; docs/adr/ADR_071_gateway_owns_its_data.md:36–49
- N1b.5RustFS posts the put event to API gateway v2's object-event route, with its token. M1 services/engine--go/gateway/internal/connector/own/objects/objects.go:78; services/engine--go/gateway/internal/routes/upload/events.go:148; docs/adr/ADR_071_gateway_owns_its_data.md:36–49; contracts/object-events/v1/interface.go:7–24
- N1b.6API gateway v2 checks the file and writes one document record for it in its own MongoDB. The record names the file in its bucket and the time after which a worker can delete it. The landing then reads the record again, and a record that a delete removed ends the upload as canceled, with no trigger. M1 services/engine--go/gateway/internal/routes/upload/events.go:79; services/engine--go/gateway/internal/routes/upload/landing.go:172; services/engine--go/gateway/internal/routes/upload/accept.go:122; services/engine--go/gateway/internal/connector/documents/mongo/create.go:29; docs/adr/ADR_071_gateway_owns_its_data.md:58–61
- N1b.7If the record still stands, it writes the trigger to its outbox in its own MongoDB, and a relay puts it on the stream
lexselect:v2:processing:triggers, through the processing-trigger contract. M1 services/engine--go/gateway/internal/routes/upload/accept.go:128; services/engine--go/gateway/internal/routes/upload/landing.go:176; services/engine--go/gateway/internal/routes/upload/accept.go:133; services/engine--go/gateway/internal/routes/upload/trigger.go:65; services/engine--go/gateway/internal/connector/processingtrigger/outbox/outbox.go:56; services/engine--go/gateway/internal/connector/processingtrigger/outbox/relay.go:139; docs/adr/ADR_071_gateway_owns_its_data.md:63–67; contracts/processing-trigger/v2/interface.go:7–17; contracts/processing-trigger/v2/interface.go:31–40; contracts/processing-trigger/v2/contract.go:20–21
- N1b.8It sends
document.processing.queued to the client's endpoints, through the webhooks contract. M1 services/engine--go/gateway/internal/routes/upload/landing_exit.go:90; services/engine--go/gateway/internal/webhooks/emit.go:28; docs/adr/ADR_071_gateway_owns_its_data.md:36–49; contracts/webhooks/v1/interface.go:55–91
2 · Processingarch-v1
Turns an uploaded document into what the API returns: pages, text, layout, fields and vectors.
- runs the workflow task by task under scheduler v2 (2.3–2.13)
- calls the OCR, layout and LLM models and stores pages, images, fields and vectors (2.9–2.10)
- sets the final status and notifies the client by webhook (2.13–2.16)
- keeps the document index in OpenSearch current (2.17–2.18)
- frees the processing's payloads once it has succeeded (2.20)
- 2.1worker-api publishes the trigger to RabbitMQ queue
scheduler_v2:triggers (default exchange). An API upload names its user's own workflow, else api (the default graph without embedding). A flagged API or portal DOCX uses docx_structured or, for an eligible paid enterprise account, docx_text. Structured mode takes precedence when both flags are enabled. With the document queue on, an API upload publishes the trigger from the accepted claim's replay payload, so a lost publication is replayed. services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:524; services/engine/shared/scheduler_routing.py:207; services/engine/shared/providers/publisher.py:317; services/engine/shared/scheduler_routing.py:69; services/engine/shared/services/document_queue_recovery.py:35
- 2.2worker-api queues the
document.processing.queued webhook as taskiq task task_webhook_dispatch_v1 on the Valkey stream worker_api. The landing of an upload by link (1b.17) queues it with a task id fixed per job, so a repeated landing adds no second event. services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1379–1382; services/engine/microservices/worker_api/tasks_v2/extapi/_helpers.py:153; services/engine/microservices/worker_api/tasks_v2/extapi/direct_upload_landing.py:205
- 2.3scheduler v2 (Go,
worker-go-scheduler) consumes the trigger. services/engine-go/internal/consumer/consumer.go:44
- 2.4The scheduler looks the document up in
fs_items (its storage_key goes into every task payload) and creates the processings row. services/engine-go/internal/persistence/lookups.go:34; services/engine-go/internal/scheduler/engine_trigger_processing.go:143
- 2.5The scheduler keeps its state in Valkey (24 h TTL), registers the processing in the Valkey admission queue and, once it is admitted (S.6, S.7), seeds the root tasks and dispatches each task with
XADD to lexselect:scheduler_v2:tasks:{v2q}:<function_vN>. services/engine-go/internal/scheduler/engine_trigger.go:91; services/engine-go/internal/scheduler/engine_processing_lifecycle.go:72; services/engine-go/internal/scheduler/engine_trigger.go:106; services/engine-go/internal/dispatch/dispatch.go:55
- 2.6worker-main (about 40 task types) and worker-preview (
unarchive, generate_preview) read their streams with XREADGROUP. When worker-main's native Go child is ready, it reads the task_tree_builder and task_persist_page_field(s) streams instead, and hands a task it declines to the stream's __python twin, which the Python consumer reads. services/engine/shared/providers/scheduler_v2_consumer.py:80; services/engine/shared/connectors/scheduler_v2_queue_redis.py:159; services/engine/native/tree_worker/worker/worker.go:315
- 2.7worker-main streams the original (or its preview) through FS storage into a private temporary file, opens it by path and splits pages in bounded chunks. Text mode reads the original DOCX XML. Structured mode matches its paragraphs and table cells to words in the converted PDF and reads each page’s layout object. services/engine/microservices/worker_main/scheduler_v2_tasks/task_get_pages.py:287; services/engine/microservices/worker_main/modules/processing_v4/extract_objects_from_pages.py:63; services/engine/microservices/worker_main/scheduler_v2_tasks/_docx_source.py:86; services/engine/microservices/worker_main/scheduler_v2_tasks/task_docx_layout.py:88; services/engine/microservices/worker_main/scheduler_v2_tasks/task_docx_page.py:332
- 2.8worker-preview checks only the PDF prefix when no conversion is needed; for converted formats it writes the preview PDF next to the original (
{storage_key minus ext}.pdf); unarchive creates child fs_items for the body and attachments of .msg and .eml emails. services/engine/microservices/worker_preview/scheduler_v2_tasks/task_generate_preview.py:77; services/engine/microservices/worker_preview/scheduler_v2_tasks/task_generate_preview.py:162; services/engine/microservices/worker_preview/scheduler_v2_tasks/task_unarchive.py:159
- 2.9worker-main calls ML: ml_vision_pp for layout and tables (Cloud Run,
ML_VISION_HTTP_ENDPOINT_URL) and, one URL per route, for token styling, key-value pairs and handwriting, waiting up to 7 minutes for a busy instance (wait_while_busy); Google Vision OCR (OCR_PROVIDER=google_vision, Textract as fallback) and Gemini on Vertex AI for LLM features. Both native DOCX workflows run OCR only on distinct embedded pictures through the configured OCR provider. services/engine/microservices/worker_main/entrypoint.py:257; services/engine/shared/connectors/ml_pp_wait.py:128; services/engine/microservices/worker_main/scheduler_v2_tasks/task_token_styling.py:107; services/engine/microservices/worker_main/scheduler_v2_tasks/task_docx_image_ocr.py:84
- 2.10worker-main writes page rows to DocumentDB, page images to S3 vision-images, page fields to S3 page-metadata (30-day expiry; one
task_persist_page_fields per page writes all of its field objects, in the Go child when it owns the task), vectors to OpenSearch (RAG_VECTOR_BACKEND=opensearch) and the document's sub_documents registry rows to DocumentDB, replacing its earlier rows (delete, then insert). Once every page is written, the document task running_chrome rewrites the tree_outputs of the pages whose running headers or footers it found, from the per-page running_chrome_map results. Text mode stores one page row and its tree after verifying billing eligibility. Structured mode writes one temporary layout object per page in the image bucket, persists the page’s OCR and tree together, and maps repeated margins before finalizing the document. The two workflows stage pictures under the document’s render prefix for OCR. iac/ml.tf:24; iac/storage.tf:58; iac/storage.tf:14; services/engine/microservices/worker_main/scheduler_v2_tasks/task_persist_page.py:234; services/engine/microservices/worker_main/scheduler_v2_tasks/task_persist_page_field.py:257; services/engine/native/tree_worker/worker/persist.go:111; services/engine/microservices/worker_main/scheduler_v2_tasks/task_vectorize.py:104; services/engine/microservices/worker_main/scheduler_v2_tasks/task_persist_document.py:458–466; services/engine/shared/entities/sub_documents_registry.py:75–97; services/engine/microservices/worker_main/scheduler_v2_tasks/task_running_chrome.py:502; services/engine/microservices/worker_main/scheduler_v2_tasks/task_docx_text.py:129; services/engine/microservices/worker_main/scheduler_v2_tasks/task_docx_text.py:145; services/engine/microservices/worker_main/scheduler_v2_tasks/task_docx_text.py:161; services/engine/microservices/worker_main/scheduler_v2_tasks/task_docx_images.py:102; services/engine/microservices/worker_main/scheduler_v2_tasks/task_docx_pictures.py:77; services/engine/microservices/worker_main/scheduler_v2_tasks/task_docx_layout.py:99; services/engine-go/internal/workflow/seeds/docx_structured.go:138
- 2.11worker-main stores each task's result under
lexselect:processing:results:* and appends to lexselect:scheduler_v2:results. The native Go child does the same for the tasks it owns. services/engine/shared/providers/scheduler_v2_executor.py:358; services/engine/shared/providers/scheduler_v2_result_reporter.py:96; services/engine/native/tree_worker/worker/worker.go:502; services/engine/native/tree_worker/worker/worker.go:399
- 2.12The scheduler reads the results stream and dispatches the next tasks (back to 2.5). services/engine-go/internal/dispatch/results.go:89
- 2.13When the graph ends, the scheduler sets the processing status,
SUCCESS or FAILED, in DocumentDB. services/engine-go/internal/resulthandler/completion.go:204; services/engine-go/internal/resulthandler/completion.go:54
- 2.14worker-main's
notify_finished or notify_failed task queues the document.processing.completed or document.processing.failed webhook on the taskiq stream worker_api, for every processing of the user, Studio runs included. A run whose processing row holds event_route: processing_events, an upload of API gateway v2, publishes the event to the queue api_gateway_v2:processing_events instead (N2.4). A failed emit is logged, and the task completes. services/engine/microservices/worker_main/scheduler_v2_tasks/task_notify_finished.py:56–60; services/engine/microservices/worker_main/scheduler_v2_tasks/task_notify_failed.py:92–96; services/engine/microservices/worker_api/tasks_v2/extapi/_helpers.py:145; services/engine/shared/providers/processing_events.py:19
- 2.15worker-api runs
task_webhook_dispatch_v1 for both events. It reads the endpoints in extapi_webhooks whose created_by is the event's user, with status active, verification verified (or absent on legacy endpoints) and a subscription to the event type or *. It records one job per endpoint in extapi_webhook_jobs: state pending, due now, attempt 1, the immutable body (8 MiB limit), a deadline 24 h after the event and a 30-day expiry. The job id hashes owner, endpoint and event origin, so a redelivered dispatch adds no second job. services/engine/microservices/worker_api/tasks_v2/extapi/webhook_dispatch.py:40; services/engine/microservices/worker_api/tasks_v2/extapi/webhook_dispatch.py:52–62; services/engine/shared/entities/extapi_webhooks.py:315–336; services/engine/shared/entities/extapi_webhook_jobs.py:85–152; services/engine/shared/services/webhook_retry.py:19–21; services/engine/shared/services/webhook_retry.py:55–60
- 2.16worker-api's delivery loop resolves the endpoint's host (https) within 5 s and refuses the send when any resolved address is not public (the job fails at once), re-reads the endpoint in
extapi_webhooks (owner, active, verified, still subscribed), and POSTs the body to the customer's endpoint with X-Webhook-Id, X-Webhook-Timestamp and X-Webhook-Signature (sha256= HMAC of timestamp.body), a 10 s limit, the resolved addresses pinned and redirects refused. A non-2xx answer or a network error retries after 30 s, 2 min, 15 min and 1 h (5 attempts, within 24 h of the event). Each attempt lands in extapi_webhook_deliveries; a job that ends in failure adds 1 to the endpoint's failure_count, a 2xx resets it, and at 10 the endpoint is disabled. services/engine/shared/services/webhook_delivery.py:99–109; services/engine/shared/services/webhook_delivery.py:123–136; services/engine/shared/services/webhook_delivery.py:155–179; services/engine/shared/services/webhook_destination.py:21–60; services/engine/microservices/worker_api/tasks_v2/extapi_webhooks/probe_http.py:29–56; services/engine/shared/services/webhook_retry.py:14–21; services/engine/shared/entities/extapi_webhook_jobs.py:357–451
- 2.17A DocumentDB change stream on
fs_items (batch 10, 1 s window) invokes the fs_sync Lambda. iac/file_service_sync.tf:381
- 2.18The Lambda indexes the item with its materialized path into OpenSearch
fs-items-v1, and re-indexes descendants when a folder is renamed or moved. services/engine/microservices/worker_sync_fs/lambda_handler.py:116; services/engine/microservices/worker_sync_fs/consumer.py:171; services/engine/microservices/worker_sync_fs/consumer.py:281; services/engine/microservices/worker_sync_fs/consumer.py:420; services/engine/microservices/worker_sync_fs/consumer.py:500
- 2.19A batch with a failed item makes the Lambda raise; the function's
dead_letter_config points at the SQS dead-letter queue fs-sync-dlq (14-day retention, message-age alarm), but the event source mapping has no on-failure destination. iac/file_service_sync.tf:32; iac/file_service_sync.tf:314; services/engine/microservices/worker_sync_fs/lambda_handler.py:134
- 2.20After a SUCCESS whose payload cleanup the scheduler certified (S.37), worker-api's payload cleanup loop, every 5 s, deletes the processing's task payloads from Valkey, the
lexselect:processing:results:* and lexselect:processing:inputs:* keys, tracked as a job in processing_cleanup_jobs (S.38). services/engine/microservices/worker_api/entrypoint.py:545–550; services/engine/shared/services/processing_cleanup_runner.py:13; services/engine/shared/services/processing_cleanup.py:83; services/engine/shared/services/processing_cleanup.py:118; services/engine/shared/services/processing_cleanup.py:169
3 · Status and resultsarch-v1
Lets the client follow a processing and read what it produced.
- reports a document and its processing's status, progress and errors (3.9)
- returns pages and the parse and render results (3.9–3.10)
- 3.1The client resolves
api.lexselect.io as in 1a.1. iac/aws-ecs.tf:59
- 3.2HTTPS
GET /api/documents/{id} for the document; …/processing/latest for its processing (include_provenance adds the workflow); …/processing/latest/pages for its page rows, paged by limit (50 by default, at most 100) and cursor (a row offset); …/parse for the tree and its slices, chosen by include, pages, exclude_node_types, strip_geometry and tokens; …/render (experimental) for one Markdown or HTML string, chosen by the required format, style, pages and exclude_node_types. services/web-hooks-service/openapi.yaml:4072; services/web-hooks-service/openapi.yaml:4475; services/web-hooks-service/openapi.yaml:4540; services/web-hooks-service/openapi.yaml:4162; services/web-hooks-service/openapi.yaml:4329; services/engine/microservices/worker_api/tasks_v2/extapi/request.py:416–417; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:588–593; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:762–788; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:1193–1228
- 3.3The
/api* rule forwards to web-hooks-service. iac/aws-ecs.tf:503
- 3.4API key and limits, as in 1a.4; the page-quota check belongs to the upload handler alone. services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:71
- 3.5The gateway relays the request over RabbitMQ
extapi-orchestrator-v1 (default exchange; routing key extapi.request.v1.request in the body; reply to an exclusive reply queue). The message carries method, path (relative to /api), body, query_params, the two headers x-api-version and idempotency-key, client_ip, user_agent, request_id and the key's context (key, owner, workspace, actor, entitlement, workflow, scope). After API_TIMEOUT (30 s) the gateway drops the call and answers 504 Gateway Timeout. services/web-hooks-service/src/extapi/controller.ts:26–50; services/web-hooks-service/src/extapi/controller.ts:53–57; services/web-hooks-service/src/extapi/controller.ts:83–90; services/web-hooks-service/src/config.ts:114; services/web-hooks-service/src/config.ts:277–278; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:37; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:129–138; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:142–156
- 3.6The orchestrator consumes it. services/engine/microservices/orchestrator/core/orchestrator_extapi_v1.py:92
- 3.7The orchestrator kicks
task_extapi_request_v1 on the taskiq stream worker_api. services/engine/microservices/orchestrator/controllers/extapi/request.py:46
- 3.8worker-api routes the request to its handler:
handle_document_get, handle_processing_latest, handle_processing_pages, handle_document_parse or handle_document_render. services/engine/microservices/worker_api/tasks_v2/extapi/request.py:320–332; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1616; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:317; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:558; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:716; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:1167
- 3.9FS checks ownership in
fs_items; the handler reads users, processings (status, errors) and pages. A document extracted from an email has no processing of its own: the handler reads its container's latest processings record through parent_id, and pages by the child's own id. The status counts the run's pages rows for its progress (version 2026-03-06 reads the stored progress and every page row), and reads the preview flag in processing_persistent_results and, for provenance, workflow_definitions. While the run is unfinished, /pages, /parse and /render read only completed pages; /pages reads one page of rows at a time, /parse and /render every matching row in one query and then its trees (for /parse also its kvps) 100 pages at a time. /parse with pages on 2026-08-01 and later reads table chains from document_artifacts, and with kvps on 2026-11-05 and later the run's workflow for kvps_status. For a client-OCR document, GET /documents/{id} counts the latest processing's pages by OCR provider. services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:175–246; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:361–373; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:409–461; services/engine/microservices/worker_api/tasks_v2/extapi/provenance.py:17; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:527–529; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:595–628; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:812–846; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:50; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:1084; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:1309; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:869–877; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:1124–1129; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:1253–1257; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:360–409; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1667–1683
- 3.10
/parse and /render also read tree_outputs.json from S3 page-metadata, keyed by the processing id, the requested document's own id and the page index, for a page whose DocumentDB row holds no tree. A missing object or failed read leaves that page without a tree, and /render skips it. Status and /pages read no S3. services/engine/shared/helpers/page_result_store.py:62–89; services/engine/shared/helpers/page_result_store.py:141–144; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:670; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:700–708; services/engine/microservices/worker_api/tasks_v2/extapi/processing.py:1294–1295
- 3.11worker-api returns the answer; taskiq stores it in the Valkey result backend. services/engine/shared/connectors/taskiq.py:383
- 3.12The orchestrator's
wait_result reads it, waiting at most ENGINE_GENERAL_ACTION_TIMEOUT (80 s by default); on expiry it replies 504. services/engine/microservices/orchestrator/controllers/extapi/request.py:61; services/engine/microservices/orchestrator/controllers/extapi/request.py:79–94; services/engine/shared/config.py:426
- 3.13The orchestrator publishes the reply to the gateway's reply queue. services/engine/microservices/orchestrator/core/event_extapi_base.py:51
- 3.14The gateway's reply consumer receives it. services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:44
- 3.15The gateway answers the client. services/web-hooks-service/src/extapi/controller.ts:72
4 · Deletionarch-v1
Removes a document and everything derived from it, on request or when its retention ends.
- soft-deletes the document at once and stops its processing (4.9–4.13)
- answers as soon as the deletion is accepted (4.20)
- purges S3, DocumentDB and OpenSearch in the background, as it does for retention (4.21–4.24)
- 4.1The client resolves
api.lexselect.io as in 1a.1. iac/aws-ecs.tf:59
- 4.2HTTPS
DELETE /api/documents/{id}. services/web-hooks-service/openapi.yaml:4120
- 4.3The
/api* rule forwards to web-hooks-service. iac/aws-ecs.tf:503
- 4.4API key and limits, as in 1a.4; the page-quota check belongs to the upload handler alone. services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:71
- 4.5The gateway relays the request over RabbitMQ
extapi-orchestrator-v1 (default exchange; routing key extapi.request.v1.request in the body; reply to an exclusive reply queue). The message carries method, path (relative to /api), body, query_params, the two headers x-api-version and idempotency-key, client_ip, user_agent, request_id and the key's context (key, owner, workspace, actor, entitlement, workflow, scope). After API_TIMEOUT (30 s) the gateway drops the call and answers 504 Gateway Timeout. services/web-hooks-service/src/extapi/controller.ts:26–50; services/web-hooks-service/src/extapi/controller.ts:53–57; services/web-hooks-service/src/extapi/controller.ts:83–90; services/web-hooks-service/src/config.ts:114; services/web-hooks-service/src/config.ts:277–278; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:37; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:129–138; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:142–156
- 4.6The orchestrator consumes it. services/engine/microservices/orchestrator/core/orchestrator_extapi_v1.py:92
- 4.7The orchestrator kicks
task_extapi_request_v1 on the taskiq stream worker_api. services/engine/microservices/orchestrator/controllers/extapi/request.py:46
- 4.8worker-api runs
handle_document_delete; FS checks the owner. services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1710
- 4.9FS soft-deletes the document and its whole subtree in
fs_items (removed_at, removed_by). services/engine/shared/entities/fs/utils.py:261; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1772
- 4.10worker-api sets the kill switch
lexselect:scheduler:doc_removed:{id} and appends to the removed-documents stream; the scheduler's gate then refuses new triggers, fan-outs and retry re-evaluations for the document (S.3). services/engine/shared/providers/publisher.py:368; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1794; services/engine-go/internal/scheduler/removed_documents_gate.go:60; services/engine-go/internal/scheduler/engine_trigger.go:161
- 4.11For each v2 processing of those files that is created, queued or in progress, worker-api publishes
cancel_processing to RabbitMQ scheduler_v2:admin. The reaper's tombstone (4.21) cancels the remaining active ones. services/engine/shared/providers/publisher.py:322; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1801–1809; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1819; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/tombstone.py:141
- 4.12The scheduler's admin consumer takes the command (S.33–S.34). services/engine-go/internal/admin/consumer.go:44
- 4.13The scheduler cancels the tasks and sets the processing to
CANCELED in DocumentDB. services/engine-go/internal/scheduler/engine_admin.go:16
- 4.14worker-api inserts the purge row into
document_deletion_queue (1 h SLA), replacing any retention row. When the insert fails, worker-api answers 500 with the soft delete already written; a repeated DELETE inserts the row, and a backfill loop in every worker-api process (every 30 s, 30 documents) enqueues each soft-deleted fs_items item that has no purge marker, paced by the deletion_backfill capacity bucket. services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1772; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1841; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1841–1843; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1846; services/engine/microservices/worker_api/tasks_v2/document_deletion/producers.py:124; services/engine/microservices/worker_api/tasks_v2/document_deletion/backfill.py:85; services/engine/microservices/worker_api/tasks_v2/document_deletion/backfill.py:161; services/engine/microservices/worker_api/entrypoint.py:801–810; services/engine/shared/config.py:511
- 4.15worker-api wakes the reaper on the Valkey stream
lexselect:deletion_queue:wake. services/engine/microservices/worker_api/tasks_v2/document_deletion/wakes.py:47; services/engine/microservices/worker_api/tasks_v2/document_deletion/producers.py:155
- 4.16worker-api returns
{id, deleted: true}; taskiq stores it in the Valkey result backend. services/engine/shared/connectors/taskiq.py:383
- 4.17The orchestrator's
wait_result reads it, waiting at most ENGINE_GENERAL_ACTION_TIMEOUT (80 s by default); on expiry it replies 504. services/engine/microservices/orchestrator/controllers/extapi/request.py:61; services/engine/microservices/orchestrator/controllers/extapi/request.py:79–94; services/engine/shared/config.py:426
- 4.18The orchestrator publishes the reply to the gateway's reply queue. services/engine/microservices/orchestrator/core/event_extapi_base.py:51
- 4.19The gateway's reply consumer receives it. services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:44
- 4.20The gateway answers
200 once deletion is accepted; afterwards the document returns 404. services/web-hooks-service/openapi.yaml:4121
- 4.21The deletion reaper, a background task in every worker-api process, wakes from the stream (or from the scheduler's terminal events, S.31, or its
run_after alarm) and claims the row with a DocumentDB lease. It runs the row's steps in order, recording each outcome; a step that keeps failing marks the row failed after 5 attempts, and the row stays in document_deletion_queue. The first step, tombstone, parks a retention row until its policy is due and no processing or accepted queue claim of the document is open (the document stays readable), then soft-deletes the item or subtree, writes the purge marker and cancels active processings. services/engine/microservices/worker_api/entrypoint.py:733; services/engine/microservices/worker_api/tasks_v2/document_deletion/reaper.py:317; services/engine/microservices/worker_api/tasks_v2/document_deletion/reaper.py:645; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/tombstone.py:63; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/tombstone.py:91; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/tombstone.py:132; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/tombstone.py:141; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/tombstone.py:229
- 4.22It first ends the document's waiting queue claims that have no processing (
document_queue_claims, reason document_deleted). Once its processings are canceled and quiet (up to 15 minutes while a failed, canceled or just-canceled one may still write; a succeeded one needs no wait), no queue claim of the document is live and the payload cleanup of its processings has finished or was recorded as retained (S.37), it purges S3: page fields in page-metadata, page images in vision-images, then from the FS bucket the preview and the original with its client OCR file (guarded against shared keys). services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/cancel_processings.py:79; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/cancel_processings.py:116; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/cancel_processings.py:151; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/cancel_processings.py:177; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/cancel_processings.py:181; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/cancel_processings.py:229; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/s3_processed_data.py:30; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/s3_rendered_images.py:50; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/s3_preview.py:25; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/s3_original.py:32; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/_guard.py:89
- 4.23It purges DocumentDB: vectors, pages and related collections, processings (after copying their usage history, once billing has settled and no queue claim or payload cleanup of theirs is open) together with their terminal queue claims in
document_queue_claims, then the fs_items row once it has no children. A folder, project or file with children, such as an email, goes through its children: expand_children inserts each direct child as its own document_deletion_queue row, and the parent waits until none is open. services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/expand_children.py:67; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/expand_children.py:86–88; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/expand_children.py:113; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/vector_store.py:52; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/docdb_pages.py:142; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/docdb_processings.py:64; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/docdb_processings.py:86; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/docdb_processings.py:94; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/docdb_processings.py:104; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/docdb_document.py:32
- 4.24It deletes the FS index entry in OpenSearch
fs-items-v1 itself and verifies it is gone, purges the k-NN vectors, writes an fs.purge event to fs-audit-v1, and archives the finished queue row to deletion-archive (ADR-037). services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/opensearch_path.py:27; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/vector_store.py:60; services/engine/microservices/worker_api/tasks_v2/document_deletion/steps/audit.py:46; services/engine/microservices/worker_api/tasks_v2/document_deletion/archiver.py:180
5 · Listingarch-v1
Lets the client browse what it stored: its documents and folders, and the sub-documents found in a folder's files.
- lists documents and folders from the FS read model, a page at a time (5.9–5.10)
- lists the sub-documents found in a folder's files, with their kind and pages (5.11)
- 5.1The client resolves
api.lexselect.io as in 1a.1. iac/aws-ecs.tf:59
- 5.2HTTPS
GET /api/documents, the items under parent_id (a project, a folder or an email file, whose body and attachments are its children) or at the root, filtered by type, with soft-deleted items only when include_deleted is true or 1, sorted by sort_by and sort_direction, limit 25 by default (1 to 100, else 400) and paged by cursor; or GET /api/folders/{folder_id}/sub-documents, filtered by kind and type, paged by limit (50 by default, 1 to 200) and offset. services/web-hooks-service/openapi.yaml:3757; services/web-hooks-service/openapi.yaml:3625; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:126; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1458; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1487–1503; services/engine/microservices/worker_api/tasks_v2/extapi/sub_documents.py:72–80
- 5.3The
/api* rule forwards to web-hooks-service. iac/aws-ecs.tf:503
- 5.4API key and limits, as in 1a.4; the page-quota check belongs to the upload handler alone. services/web-hooks-service/src/extapi/router.ts:114–133
- 5.5The gateway relays the request over RabbitMQ
extapi-orchestrator-v1 (default exchange; routing key extapi.request.v1.request in the body; reply to an exclusive reply queue). The message carries method, path (relative to /api), body, query_params, the two headers x-api-version and idempotency-key, client_ip, user_agent, request_id and the key's context (key, owner, workspace, actor, entitlement, workflow, scope). After API_TIMEOUT (30 s) the gateway drops the call and answers 504 Gateway Timeout. services/web-hooks-service/src/extapi/controller.ts:26–50; services/web-hooks-service/src/extapi/controller.ts:53–57; services/web-hooks-service/src/extapi/controller.ts:83–90; services/web-hooks-service/src/config.ts:114; services/web-hooks-service/src/config.ts:277–278; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:37; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:129–138; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:142–156
- 5.6The orchestrator consumes it. services/engine/microservices/orchestrator/core/orchestrator_extapi_v1.py:92
- 5.7The orchestrator kicks
task_extapi_request_v1 on the taskiq stream worker_api. services/engine/microservices/orchestrator/controllers/extapi/request.py:46
- 5.8worker-api routes the request to
handle_document_list or handle_folder_sub_documents; FS checks the owner of the folder it lists. services/engine/microservices/worker_api/tasks_v2/extapi/request.py:311–318; services/engine/microservices/worker_api/tasks_v2/extapi/request.py:442–447; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1433; services/engine/microservices/worker_api/tasks_v2/extapi/sub_documents.py:57
- 5.9
GET /documents queries the FS read model, OpenSearch fs-items-v1, a page at a time with search_after, excluding items that carry removed_at unless include_deleted is set; a cursor whose item is gone, or belongs to another user, restarts the listing at the first page. The list is as fresh as the 2.18 sync. services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1512; services/engine/microservices/worker_api/tasks_v2/fs/list.py:472; services/engine/microservices/worker_api/tasks_v2/fs/list.py:515–517; services/engine/microservices/worker_api/tasks_v2/fs/list.py:542–552; services/engine/microservices/worker_api/tasks_v2/fs/list.py:579
- 5.10A root listing of the first page, unfiltered or with
type=project, that shows no project finds or creates the Default Project in fs_items and touches its modified_at, so the fs-sync Lambda (2.18) indexes it into fs-items-v1 and the project is always visible. Each listed file gets its latest status from processings and its preview flag from processing_persistent_results; when that lookup fails the items return without them. services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1530–1539; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1543–1545; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:1548–1554; services/engine/microservices/worker_api/tasks_v2/extapi/documents.py:420; services/engine/microservices/worker_api/tasks_v2/fs/list.py:39; services/engine/microservices/worker_api/tasks_v2/fs/list.py:199–201
- 5.11The sub-documents route reads the folder and its files' ids from
fs_items, up to 5,000 files, then lists and counts their rows in the sub_documents registry, with each one's kind, label, type and pages. services/engine/microservices/worker_api/tasks_v2/extapi/sub_documents.py:36; services/engine/microservices/worker_api/tasks_v2/extapi/sub_documents.py:95–97; services/engine/microservices/worker_api/tasks_v2/extapi/sub_documents.py:118–121; services/engine/microservices/worker_api/tasks_v2/extapi/sub_documents.py:135–141; services/engine/shared/entities/sub_documents_registry.py:28
- 5.12worker-api returns the answer; taskiq stores it in the Valkey result backend. services/engine/shared/connectors/taskiq.py:383
- 5.13The orchestrator's
wait_result reads it, waiting at most ENGINE_GENERAL_ACTION_TIMEOUT (80 s by default); on expiry it replies 504. services/engine/microservices/orchestrator/controllers/extapi/request.py:61; services/engine/microservices/orchestrator/controllers/extapi/request.py:79–94; services/engine/shared/config.py:426
- 5.14The orchestrator publishes the reply to the gateway's reply queue. services/engine/microservices/orchestrator/core/event_extapi_base.py:51
- 5.15The gateway's reply consumer receives it. services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:44
- 5.16The gateway answers the client. services/web-hooks-service/src/extapi/controller.ts:72
6 · Usagearch-v1
Lets the client see what its account has used and has left.
- summarizes the billing period: plan, pages processed and remaining, spend and documents stored (6.9)
- counts pages and documents day by day, for up to a year (6.10)
- 6.1The client resolves
api.lexselect.io as in 1a.1. iac/aws-ecs.tf:59
- 6.2HTTPS
GET /api/usage, the account's billing period, or GET /api/usage/daily with start and end as YYYY-MM-DD UTC days: end defaults to today and start to 29 days before it, at most 366 days. services/web-hooks-service/openapi.yaml:4613; services/web-hooks-service/openapi.yaml:4665; services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:47; services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:89–95; services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:100–102; services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:117–119; services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:143
- 6.3The
/api* rule forwards to web-hooks-service. iac/aws-ecs.tf:503
- 6.4API key and limits, as in 1a.4; the page-quota check belongs to the upload handler alone. services/web-hooks-service/src/extapi/router.ts:114–133
- 6.5The gateway relays the request over RabbitMQ
extapi-orchestrator-v1 (default exchange; routing key extapi.request.v1.request in the body; reply to an exclusive reply queue). The message carries method, path (relative to /api), body, query_params, the two headers x-api-version and idempotency-key, client_ip, user_agent, request_id and the key's context (key, owner, workspace, actor, entitlement, workflow, scope). After API_TIMEOUT (30 s) the gateway drops the call and answers 504 Gateway Timeout. services/web-hooks-service/src/extapi/controller.ts:26–50; services/web-hooks-service/src/extapi/controller.ts:53–57; services/web-hooks-service/src/extapi/controller.ts:83–90; services/web-hooks-service/src/config.ts:114; services/web-hooks-service/src/config.ts:277–278; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:37; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:129–138; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:142–156
- 6.6The orchestrator consumes it. services/engine/microservices/orchestrator/core/orchestrator_extapi_v1.py:92
- 6.7The orchestrator kicks
task_extapi_request_v1 on the taskiq stream worker_api. services/engine/microservices/orchestrator/controllers/extapi/request.py:46
- 6.8worker-api refuses a key whose scope is not
ProcessingAPI with 403, then routes GET /usage to handle_usage_summary and GET /usage/daily to handle_usage_daily; any other verb on either answers 405. services/engine/microservices/worker_api/tasks_v2/extapi/request.py:73; services/engine/microservices/worker_api/tasks_v2/extapi/request.py:470; services/engine/microservices/worker_api/tasks_v2/extapi/request.py:472–477; services/engine/microservices/worker_api/tasks_v2/extapi/request.py:493; services/engine/microservices/worker_api/tasks_v2/extapi/request.py:498–501; services/engine/microservices/worker_api/tasks_v2/extapi/request.py:507; services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:325; services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:361
- 6.9The summary resolves the key owner's billing account from
users, workspaces and billing_entitlements and reads its period: the usage ledger for an entitled workspace, the wallet for a personal account, or processings otherwise; it counts the documents stored in fs_items. Org-wide billing reads are the workspace owner's only. services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:289–292; services/engine/shared/services/billing_account.py:63; services/engine/microservices/worker_api/tasks_v2/usage/read.py:422; services/engine/microservices/worker_api/tasks_v2/usage/read.py:269–273; services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:311–313
- 6.10The daily route reads pages and documents per day from
api_usage_ledger for an entitled workspace, a member only their own runs, and otherwise from processings merged with the retained extapi_usage_history, counting only successful API-source runs with at least one page, by finish day (UTC). services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:378–381; services/engine/microservices/worker_api/tasks_v2/extapi/usage.py:390–392; services/engine/shared/entities/api_usage_ledger.py:409; services/engine/shared/entities/processing.py:438; services/engine/shared/services/extapi_usage_history.py:92; services/engine/shared/services/extapi_usage_history.py:147
- 6.11worker-api returns the answer; taskiq stores it in the Valkey result backend. services/engine/shared/connectors/taskiq.py:383
- 6.12The orchestrator's
wait_result reads it, waiting at most ENGINE_GENERAL_ACTION_TIMEOUT (80 s by default); on expiry it replies 504. services/engine/microservices/orchestrator/controllers/extapi/request.py:61; services/engine/microservices/orchestrator/controllers/extapi/request.py:79–94; services/engine/shared/config.py:426
- 6.13The orchestrator publishes the reply to the gateway's reply queue. services/engine/microservices/orchestrator/core/event_extapi_base.py:51
- 6.14The gateway's reply consumer receives it. services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:44
- 6.15The gateway answers the client. services/web-hooks-service/src/extapi/controller.ts:72
7 · Docs and healtharch-v1
Lets anyone read the API's reference and check the gateway is up, without a key.
- answers in the gateway itself, before the IP limiter and the key (7.3–7.4)
- 7.1The client resolves
api.lexselect.io as in 1a.1. iac/aws-ecs.tf:59
- 7.2HTTPS
GET /api/health, /api/openapi.yaml, /api/docs or a file of the docs build (docs.html, openapi.json, llms.txt, usage.schema.json, scalar.standalone.js, docs-navigation.css, verify-webhook.mjs, and the webhooks guide and the four integration guides getting-started, understanding-output, operations and versioning, each as .html, .md and .openapi.json), with no key. services/web-hooks-service/src/extapi/router.ts:76; services/web-hooks-service/src/extapi/router.ts:79; services/web-hooks-service/src/extapi/router.ts:89; services/web-hooks-service/src/extapi/router.ts:97; services/web-hooks-service/scripts/build-docs.js:83; services/web-hooks-service/scripts/build-docs.js:103; services/web-hooks-service/scripts/build-docs.js:129; services/web-hooks-service/scripts/build-docs.js:133; services/web-hooks-service/scripts/build-docs.js:201; services/web-hooks-service/scripts/api-guide-docs.js:51–57; services/web-hooks-service/scripts/api-guide-docs.js:81; services/web-hooks-service/scripts/webhook-docs.js:105–118
- 7.3The
/api* rule forwards to web-hooks-service. iac/aws-ecs.tf:503
- 7.4The gateway answers itself, above the IP limiter and the key:
/health reports its RabbitMQ and Valkey connections (200 or 503), /openapi.yaml the spec, /docs the reference page (a 503 while the docs are unbuilt), and the static handler the docs build's files from public/ for GET and HEAD. A path matching no file continues to the IP limiter and the key check, which answers 401 without a key. services/web-hooks-service/src/extapi/router.ts:70–73; services/web-hooks-service/src/extapi/health.ts:11–19; services/web-hooks-service/src/extapi/router.ts:79–82; services/web-hooks-service/src/extapi/router.ts:89; services/web-hooks-service/src/extapi/router.ts:97–110; services/web-hooks-service/src/extapi/router.ts:119
S · Inside scheduler v2arch-v1
One process owns each processing, so every state change has a single writer.
- admits a trigger within the customer's and the platform's limits (S.1–S.7)
- dispatches each task once its inputs are ready and capacity allows, reusing cached results (S.9–S.26)
- closes the processing, takes cancel and retry, recovers stalled work, wakes queued admissions and frees finished payloads (S.27–S.38)
- keeps the analytics index level with DocumentDB, off the execution path (S.39)
- S.1RabbitMQ
scheduler_v2:triggers delivers the trigger to the trigger consumer (durable queue, QoS 1). services/engine-go/internal/consumer/consumer.go:44
- S.2The consumer calls
Engine.HandleTrigger, which first requires the admission queue to be ready; a trigger that finds it unready is redelivered. services/engine-go/internal/scheduler/engine_trigger.go:23; services/engine-go/internal/scheduler/engine_trigger.go:38
- S.3The removed-document gate checks
lexselect:scheduler:doc_removed:{id} (in-process cache, Valkey fallback, fails open); a removed document's trigger is dropped. services/engine-go/internal/scheduler/removed_documents_gate.go:112; services/engine-go/internal/scheduler/engine_trigger.go:161
- S.4The engine deduplicates against the active processing, looks the document up in
fs_items and creates the processings row as PENDING, chaining attempt to the previous run. services/engine-go/internal/scheduler/engine_trigger_processing.go:23; services/engine-go/internal/persistence/lookups.go:34
- S.5It writes the processing meta, stamped with the scheduler's cache namespace, to
lexselect:scheduler_v2:proc:<id>:meta and the document meta to proc:<id>:document (24 h TTL). A trigger that adopts a QUEUED processing restores only the missing state, without overwriting a racing winner. services/engine-go/internal/scheduler/engine_trigger_state.go:46; services/engine-go/internal/scheduler/engine_trigger_state.go:53; services/engine-go/internal/scheduler/engine_trigger_state.go:69; services/engine-go/internal/scheduler/engine_trigger_state.go:79
- S.6Admission is ordered in Valkey. The trigger registers the row in the admission queue (
lexselect:processing:capacity:{capv2}:admission:v1:*) in the same step that moves it PENDING → QUEUED. An attempt claims the turn only for the oldest candidate, runs the customer policy, then acquires the platform leases admission_global (100 concurrent) and admission_user (10) in one atomic grant. A denial leaves the row QUEUED, records what blocked it and wakes the next candidate. services/engine-go/internal/scheduler/engine_processing_lifecycle.go:72; services/engine-go/internal/scheduler/capacityadapter/processing_admission_attempt.go:15; services/engine-go/internal/scheduler/capacityadapter/processing_admission_attempt.go:82; services/engine-go/internal/scheduler/capacityadapter/processing_admission_attempt.go:112; services/engine-go/internal/capacity/seeds/admission.go:43; services/engine-go/internal/capacity/seeds/admission.go:57
- S.7With the leases granted, a CAS moves the row QUEUED → IN_PROGRESS in DocumentDB, and the queue entry is marked admitted. services/engine-go/internal/scheduler/engine_admission.go:199; services/engine-go/internal/scheduler/capacityadapter/processing_admission_attempt.go:139; services/engine-go/internal/scheduler/capacityadapter/processing_admission_attempt.go:143
- S.8The workflow loader resolves the workflow from
workflow_definitions (default v134), and the engine seeds the root tasks as PENDING. services/engine-go/internal/workflow/loader.go:170; services/engine-go/internal/scheduler/engine_lifecycle.go:45
- S.9Evaluate: tasks whose dependencies are met move to QUEUED, and each is checked against the result cache. A hit skips dispatch and posts a synthetic completion. services/engine-go/internal/scheduler/engine_dispatch.go:14; services/engine-go/internal/scheduler/engine_cache.go:12
- S.10Each task acquires its capacity pools (for example
google_vision_ocr, ml_vision, vlm, tasks_limit) with a Lua multi-acquire; a denial schedules a wake. services/engine-go/internal/scheduler/engine_dispatch.go:100; services/engine-go/internal/capacity
- S.11A CAS moves the task QUEUED → DISPATCHED and hands it to the dispatcher. services/engine-go/internal/scheduler/engine_dispatch.go:186
- S.12The dispatcher
XADDs the task to lexselect:scheduler_v2:tasks:{v2q}:<function_vN> and mirrors its inputs to inputs:*. The progress observer (S.26) and the handlers (S.28) are queued the same way. services/engine-go/internal/dispatch/dispatch.go:74; services/engine-go/internal/scheduler/dispatchadapter/adapter.go:113
- S.13worker-main or worker-preview reads it with
XREADGROUP (group lexselect:scheduler_v2:workers) and runs it under its timeout. services/engine/shared/providers/scheduler_v2_consumer.py:121; services/engine/shared/connectors/scheduler_v2_queue_redis.py:159; services/engine/shared/providers/scheduler_v2_executor.py:295
- S.14The worker stores the result under
lexselect:processing:results:<sig> and XADDs a completion to lexselect:scheduler_v2:results. services/engine/shared/providers/scheduler_v2_executor.py:358; services/engine/shared/providers/scheduler_v2_executor.py:383
- S.15The result consumer reads completions as
go-scheduler-results and reclaims entries idle over 10 min with XAUTOCLAIM. services/engine-go/internal/dispatch/results.go:89; services/engine-go/internal/dispatch/results_reclaim.go:17
- S.16It passes each completion to the result handler, then
XACKs it; a transient error leaves it pending for redelivery. services/engine-go/internal/dispatch/results.go:209
- S.17The handler reads the processing meta, the task's state and attempt count, and fetches the task's result from
results:<sig>. A completion for a stale attempt, or for a task no longer DISPATCHED, is dropped; a success that arrives after a watchdog re-queue is accepted. services/engine-go/internal/resulthandler/handler.go:33; services/engine-go/internal/resulthandler/handler.go:129; services/engine-go/internal/resulthandler/tasks.go:39
- S.18It hands the completion to the engine:
HandleCompletion on success, HandleRetry on failure (re-queue while attempts remain, 3 in total; a permanent error fails at once). services/engine-go/internal/scheduler/engine_completion.go:21; services/engine-go/internal/scheduler/engine_completion.go:108
- S.19The engine copies eligible results into the content-addressed cache
cache:<key> (40 min TTL); tasks that bypass cache reads retain the cache key without copying the blob. A finished processing's cached results are deleted (S.28). services/engine-go/internal/resulthandler/tasks.go:39; services/engine-go/internal/scheduler/engine_cache.go:180; services/engine-go/internal/scheduler/engine_cache_drop.go:22; services/engine-go/internal/config/config.go:179
- S.20It releases the task's capacity lease, which wakes the next task parked on that pool. services/engine-go/internal/scheduler/engine_completion.go:38; services/engine-go/internal/scheduler/engine_completion.go:91
- S.21It sets the task to SUCCESS, counts fan-in, seeds fan-out scopes (one per email child, one per page) and re-evaluates: back to S.9. services/engine-go/internal/scheduler/engine_completion.go:81; services/engine-go/internal/scheduler/engine_completion.go:95; services/engine-go/internal/scheduler/engine_fanout.go:29
- S.22Tasks marked
persist: true write their result to processing_task_results. services/engine-go/internal/resulthandler/persist_result.go:34
- S.23The handler records progress with the progress tracker. services/engine-go/internal/resulthandler/handler.go:103; services/engine-go/internal/scheduler/progresstracker/tracker.go:83
- S.24The tracker writes
processing_progress and per-scope progress into proc:<id>:meta. services/engine-go/internal/scheduler/store/progress_cas.go:173
- S.25On each throttle pass (at least 1 % progress and 0.5 s since the last) it persists
processing_progress to processings. services/engine-go/internal/scheduler/progresstracker/tracker_io.go:41
- S.26It dispatches the
notify_progress observer task through the dispatcher. services/engine-go/internal/scheduler/progresstracker/dispatch.go:61
- S.27When every scope is complete, the terminal check CAS-sets the processing to SUCCESS with
processing_progress=1.0, finished_at and is_active=false. A terminal task failure sets FAILED the same way, with processing_progress=0. services/engine-go/internal/resulthandler/completion.go:144; services/engine-go/internal/resulthandler/completion.go:204; services/engine-go/internal/resulthandler/completion.go:54
- S.28The terminal status write runs inside the admission queue's turn: once its CAS lands, the queue returns the processing's admission leases, closes its entry and, for API processings, re-opens the customer-slot denials it caused. The engine's
ReleaseAdmission then deletes the processing's cached results and wakes the next queue candidate, and the handler dispatches the success handlers (notify_finished, finalize_page_quota) or failure handlers (notify_failed, release_page_quota). services/engine-go/internal/persistence/processing_cas.go:36; services/engine-go/internal/scheduler/capacityadapter/processing_admission_terminal.go:99; services/engine-go/internal/scheduler/capacityadapter/processing_admission_release.go:33; services/engine-go/internal/scheduler/capacityadapter/processing_admission_release.go:44; services/engine-go/internal/scheduler/engine_admission_release.go:29; services/engine-go/internal/scheduler/engine_admission_release.go:32; services/engine-go/internal/scheduler/engine_cache_drop.go:22; services/engine-go/internal/resulthandler/dispatch_handlers.go:37
- S.29Every task and processing transition goes to the state-event emitter. services/engine-go/internal/analytics/scheduler_emitter/emitter.go:64
- S.30It publishes on Valkey pub/sub
lexselect:analytics:scheduler_v2:state_events. services/engine-go/internal/analytics/scheduler_emitter/emitter.go:85
- S.31worker-api's deletion reaper (processing-terminal wakes) and the admin analytics subscriber consume them. For each processing-lane event with a terminal status (SUCCESS, FAILED or CANCELED) the reaper reads the processing's document id from
lexselect:scheduler_v2:proc:{pid}:meta; when that document holds an open retention row, it replaces the row with one due 1 h after the processing's stored finished_at when that is earlier than the row's 24 h upload deadline (1a.20). A later re-processing only pushes that 1 h deadline later. services/engine/microservices/worker_api/tasks_v2/document_deletion/wakes.py:133; services/engine/microservices/worker_api/tasks_v2/document_deletion/wakes.py:94–115; services/engine/microservices/worker_api/tasks_v2/document_deletion/reaper.py:201–229; services/engine/microservices/worker_api/tasks_v2/document_deletion/producers.py:277–301; services/engine/microservices/worker_api/tasks_v2/document_deletion/producers.py:328–367; services/engine/microservices/worker_api/tasks_v2/document_deletion/constants.py:43; services/engine/microservices/worker_api/tasks_v2/admin_analytics/subscriber.py:380
- S.32Processing events are batched into OpenSearch
processing-events-v1. In the same bulk, each processing of the batch gets one state document in processings-v1: its row read from DocumentDB plus the run's pages, plan and billing, versioned by the event's time; a row whose created_at is unreadable is left to the catch-up. worker-api's admin Processing and Overview dashboards read it. services/engine-go/internal/runtime/processing_events.go:32; services/engine-go/internal/analytics/processing_events/writer.go:194; services/engine-go/internal/analytics/processing_events/projection.go:42; services/engine/microservices/worker_api/tasks_v2/admin_processing/in_flight.py:117; services/engine/microservices/worker_api/tasks_v2/admin_dashboard/business_stats.py:56
- S.33RabbitMQ
scheduler_v2:admin delivers admin commands: cancel_processing, retry_task, retry_processing, with or without cache. services/engine-go/internal/admin/consumer.go:44; services/engine-go/internal/admin/types.go:16
- S.34The admin consumer runs them on the engine; a cancel tears down the tasks, CAS-sets CANCELED and dispatches the failure handlers. services/engine-go/internal/scheduler/engine_admin.go:16
- S.35The watchdog retries or fails tasks DISPATCHED over 15 min and re-queues tasks QUEUED over 90 s; wake timers re-run Evaluate after capacity denials. services/engine-go/internal/runtime/watchdog.go:23; services/engine-go/internal/scheduler/wakequeue.go:126
- S.36A committed capacity-policy change publishes
lexselect:processing:admission:wake. On each message, and every second, the scheduler's drain loop resumes a turn an attempt has held over 30 s and, while the global admission pool has a free slot, asks the admission queue for the next candidate and schedules its wake, which re-attempts admission (S.6). services/engine-go/internal/admissionqueue/capacity_snapshot.go:97–99; services/engine-go/internal/runtime/ordered_admission_drain.go:24; services/engine-go/internal/runtime/ordered_admission_drain.go:30; services/engine-go/internal/runtime/ordered_admission_drain.go:46–60; services/engine-go/internal/scheduler/capacityadapter/processing_orphan_recovery.go:38; services/engine-go/internal/scheduler/capacityadapter/processing_admission_ops.go:143–154
- S.37For a SUCCESS processing whose success handlers have finished or passed their 5 min grace, the reconcile sweep certifies payload cleanup: once the required tasks' outputs are proven written and no reader of its payloads is active, it seals the payload readers, writes the manifest of the processing's
results: and inputs: keys to lexselect:scheduler_v2:proc:<id>:payload_readers and marks the processings row payload_cleanup.state=ready. A reader that a failed or canceled task attempt keeps never drains: 15 minutes after the processing finished, the sweep records its cleanup as retained (payload_reader_not_released), so a deletion of its document stops waiting. services/engine-go/internal/scheduler/engine_reconcile.go:88; services/engine-go/internal/scheduler/engine_reconcile_handlers.go:13; services/engine-go/internal/scheduler/success_handlers.go:10; services/engine-go/internal/scheduler/engine_reconcile.go:97; services/engine-go/internal/scheduler/processing_cleanup.go:40; services/engine-go/internal/scheduler/processing_cleanup_certify.go:103–105; services/engine-go/internal/scheduler/processing_cleanup_certify.go:118–145; services/engine-go/internal/scheduler/store/store_payload_manifest.go:30; services/engine-go/internal/persistence/processing_cleanup_ready.go:53; services/engine-go/internal/scheduler/processing_cleanup_certify.go:62
- S.38worker-api's payload cleanup loop, every 5 s, takes the ready processing as a job in
processing_cleanup_jobs, moves its payload_cleanup.state to deleting, reads the manifest in payload_readers and removes each lexselect:processing:results:* and lexselect:processing:inputs:* key with UNLINK, batch by batch; then it marks the row done. services/engine/microservices/worker_api/entrypoint.py:545–550; services/engine/shared/services/processing_cleanup_runner.py:13; services/engine/shared/services/processing_cleanup.py:83; services/engine/shared/services/processing_cleanup.py:118; services/engine/shared/services/processing_cleanup.py:169; services/engine/shared/entities/processing_cleanup_jobs.py:83; services/engine/shared/entities/processing_cleanup_jobs.py:136; services/engine/shared/entities/processing_cleanup_jobs.py:197
- S.39The state-event emitter keeps
processings-v1 level with DocumentDB, off the execution path. A one-off backfill replays processings, api_usage_ledger and extapi_usage_history. Every 5 min a sweep re-projects the documents still active, closing a run whose row is gone from the usage its purge retained, and a catch-up reads the processings that finished since its cursor and writes each one the index lacks or holds behind its row, then walks the receipts and the history rows of purged runs: a run's document still active is closed with its facts, and a success document without pages gets them. A document the index refuses for what it holds is logged and counted, and its page moves on. One replica at a time holds each claim in analytics_backfills. services/engine-go/internal/analytics/processing_events/backfill.go:114; services/engine-go/internal/analytics/processing_events/reconcile.go:54; services/engine-go/internal/analytics/processing_events/reconcile_vanished.go:22; services/engine-go/internal/analytics/processing_events/catchup.go:129; services/engine-go/internal/analytics/processing_events/catchup_passes.go:20; services/engine-go/internal/analytics/processing_events/catchup_passes.go:83; services/engine-go/internal/persistence/analytics_catchup.go:20; services/engine-go/internal/persistence/analytics_backfill_claims.go:39
K · Credentialsarch-v1
Keeps every credential of a v2 app out of its environment (ADR 082). An app gets a credential in its own process, by identity, from one provider that its profile names.
- prepares the local stores, their users and their keys before an app starts (K.1–K.4)
- builds the clean environment of an app, scans it, starts the app and records its process family (K.5–K.8)
- lets the app ask the broker, which checks the caller and the reference and answers from the store (K.9–K.13)
- gives the password to the driver at each connection, and lets a command join the family of an app (K.14, K.15)
- reads a remote development key with the developer's session in the profile local (K.16–K.18)
- routes the providers to Lex Lab Mirage in the profile sim, with no session (K.19)
- fetches each credential by ARN with the task role in the profile cloud (K.20–K.22)
- reads the customer's own secrets with the customer's task role in the profile mkt (K.23)
- K.1A developer runs
make start. Before the apps start, ensureInfra calls ensureV2Stores. The call does nothing when no selected app uses a v2 store. tools/lexsup/internal/cli/ensure.go:20; tools/lexsup/internal/cli/ensure.go:42; tools/lexsup/internal/cli/ensure_v2.go:27; tools/lexsup/internal/cli/ensure_v2.go:37–39
- K.2lexsup reads the admin credentials of the v2 stores from the machine's store (
stores-v2.json, or the section stores/v2 of the keychain item) and generates each missing one: mongo_root, mongo_keyfile, valkey_admin and opensearch_admin. It saves them at once. A generated value is 32 random letters and digits, so it never equals a vendor default. tools/lexsup/internal/cli/ensure_v2.go:46; tools/lexsup/internal/cli/ensure_v2.go:84–107; tools/lexsup/internal/creds/store_keychain_darwin.go:125; tools/lexsup/internal/creds/store.go:128–131; tools/lexsup/internal/creds/store.go:135; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:144–159
- K.3lexsup starts the compose project
lexselect-v2 with Mongo, Valkey, OpenSearch and the artifact bucket of the web front ends on RustFS. Each service listens on 127.0.0.1 only. The admin credentials reach Docker as compose secrets or in the environment of docker compose, never in a file. Then lexsup deletes the demo users of OpenSearch and checks that each vendor login and each anonymous login fails, the vendor keys of RustFS included. A store that accepts one stops the start. lexsup web starts the artifact bucket alone. tools/lexsup/internal/infra/v2stores.go:57–66; tools/lexsup/internal/infra/v2stores.go:81–94; tools/lexsup/internal/infra/v2stores.go:99–109; tools/lexsup/internal/infra/v2checks.go:23; tools/lexsup/internal/infra/v2checks.go:42–70; tools/lexsup/internal/infra/v2checks.go:75–95; compose.v2.yaml:5; compose.v2.yaml:33; compose.v2.yaml:115
- K.4For each selected v2 app, lexsup generates a password, saves it in the env's store and creates the app's user on each store: Mongo
readWrite on the app's databases only, a Valkey user on the key prefix of the env, and an OpenSearch role on the index prefix of the env. Each password reaches its store without a command line. tools/lexsup/internal/cli/ensure_v2.go:37; tools/lexsup/internal/cli/ensure_v2.go:35; tools/lexsup/internal/cli/ensure_v2.go:58–75; tools/lexsup/internal/infra/v2users.go:37; tools/lexsup/internal/infra/v2users.go:62; tools/lexsup/internal/infra/v2users.go:79; tools/lexsup/internal/creds/store_keychain_darwin.go:115; tools/lexsup/internal/creds/sections.go:104; tools/lexsup/internal/creds/store.go:33; tools/lexsup/internal/creds/store.go:81
- K.5lexsup builds the clean environment of an enforced app (
Clean): the base variables of the operating system and the toolchain, the [config] entries of the app's runtime.toml, LEXSELECT_PROFILE and LEXSUP_CREDS_SOCKET. Every other variable of lexsup stays out. The profile is local. tools/lexsup/internal/envx/clean.go:21–28; tools/lexsup/internal/envx/clean.go:32–37; tools/lexsup/internal/envx/clean.go:82–99; tools/lexsup/internal/envx/clean.go:103–119
- K.6Before the start, lexsup scans the environment with the guard (
CheckEnviron). The guard refuses a variable that has a credential word in its name, a known key format or high entropy, unless the [allow] table of the contract lists it. On macOS, the entropy check accepts TMPDIR when the system confirms it is the current user's temporary directory. It also refuses a required [config] entry with no value. The error names the variable, never its value. tools/lexsup/internal/envx/clean.go:177; tools/lexsup/internal/envx/clean.go:185; tools/lexsup/internal/envx/clean.go:198–201; contracts/credentials/v1/guard.go:15–18; contracts/credentials/v1/guard.go:95–99; contracts/credentials/v1/guard.go:107–112; contracts/credentials/v1/guard.go:130–133; tools/lexsup/internal/supervisor/app_launch.go:36–40
- K.7The supervisor starts the app with
sh -c, in a process group of its own, with the clean environment as cmd.Env. The environment of the app holds no credential. tools/lexsup/internal/supervisor/app_launch.go:29; tools/lexsup/internal/supervisor/app_launch.go:35; tools/lexsup/internal/supervisor/app_launch.go:41; tools/lexsup/internal/supervisor/app_launch.go:62
- K.8At once, the supervisor records the pid of the app as the root of a process family (
Families.SetApp). The registry keeps the start time of the process, so a pid that the system reuses does not count. tools/lexsup/internal/supervisor/app_launch.go:71–74; tools/lexsup/internal/creds/family.go:34–35; tools/lexsup/internal/creds/family.go:38–49
- K.9The app starts its resolver (
credentials.Start): the guard scans the environment, the resolver reads the profile, checks each required config entry and fetches each required credential. An entry with required_when (credentials 1.2) is required only when its selector, a config entry such as API_GATEWAY_V2_CONNECTORS, has one of the listed values. In local and sim the only provider is the broker. The broker client connects to the Unix socket LEXSUP_CREDS_SOCKET, sends one line with the reference and waits at most 5 seconds. A failure stops the start and names the credential. A lab app (Lab Lens, Lab Mirage) starts the same resolver in Rust with Resolver::start. contracts/credentials/v1/runtime.go:54–92; contracts/credentials/v1/runtime.go:117–137; contracts/credentials/v1/broker.go:12; contracts/credentials/v1/broker.go:26–54; services/engine-rust/crates/lab-connect/src/resolver.rs:54; services/engine-rust/crates/lab-lens/src/main.rs:79; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:69–98
- K.10The broker accepts the connection and asks the kernel for the peer:
LOCAL_PEERPID on macOS, SO_PEERCRED on Linux. It refuses a peer of another user. It walks the parent chain of the peer, 64 steps at most, to the root of a family and gets the name of the app. A caller outside every family gets denied. tools/lexsup/internal/creds/broker.go:110–137; tools/lexsup/internal/creds/peer_darwin.go:13–34; tools/lexsup/internal/creds/peer_linux.go:13–30; tools/lexsup/internal/creds/family.go:14–15; tools/lexsup/internal/creds/family.go:51–71
- K.11The broker loads the runtime contract of the app and serves only a reference that this contract lists for the active profile. Any other reference gets
denied, so app B cannot read the credentials of app A. tools/lexsup/internal/creds/serve.go:45–61; tools/lexsup/internal/cli/daemon_broker.go:32–39
- K.12For a
lexsup: reference the broker answers from the env's store, with an age limit of 300 seconds. A generated path (gen/ or genkey/) gets a new value at its first request. A path with no value gets unknown and the next step: make start or lexsup creds rotate. tools/lexsup/internal/creds/serve.go:10–28; tools/lexsup/internal/creds/serve.go:62–64; tools/lexsup/internal/creds/serve.go:88–110; tools/lexsup/internal/creds/broker.go:20–22; tools/lexsup/internal/creds/sections.go:80–105; tools/lexsup/internal/creds/store.go:36–49
- K.13The broker writes one answer line, and one line to
creds.log with the time, the pid, the app, the reference and the result, never the value. The resolver keeps the value as a Secret that prints ***, writes an audit event without the value and fetches the value again before its age limit. A Valkey client asks the resolver at each new connection; a Mongo client reads its password at start, so lexsup creds rotate restarts the running apps whose users changed. In AWS, a rotation of a Mongo secret needs a new deployment of the tasks. tools/lexsup/internal/creds/broker.go:182–196; contracts/credentials/v1/broker.go:47–54; contracts/credentials/v1/secret.go:6–11; contracts/credentials/v1/runtime_get.go:26–62
- K.14The connector gives the password to the driver at each new connection. Identity v2 builds the options of its Valkey client with
storeconn.ValkeyOptions of the kit. The options hold CredentialsProviderContext, and that function asks the resolver for the current value. After a rotation, the next connection uses the new password with no restart. The URL holds no user and no password. services/engine--go/identity/internal/connector/valkey/valkey.go:30–31; services/engine--go/kit/storeconn/storeconn.go:71–87; services/engine--go/kit/creds/creds.go:88–98; services/engine--go/identity/cmd/identity-v2/main.go:40; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:161–166
- K.15
lexsup run --app <app> -- <command> and lexsup creds check join the family of the app. The command sends family.register with its own pid to the session, which records the pid as a root of the family. Then the command runs in the clean environment of the app, so the broker serves it what it serves the app. tools/lexsup/internal/cli/credscmd.go:39–68; tools/lexsup/internal/cli/credscmd.go:91–117; tools/lexsup/internal/cli/credscheck.go:44; tools/lexsup/internal/supervisor/family.go:32–63
- K.16A developer who needs a remote key signs in through IAM Identity Center with
aws sso login --profile lexselect-dev-secrets. The session is short-lived, and no long-lived access key stays on the laptop. lexsup loads the profile, proves the session with sts:GetCallerIdentity and takes the slug of the developer from the session name. Without a valid session it answers signin with the sign-in command. The narrow permission set DevSecrets reads /lexselect/dev/<user>/* and /lexselect/dev/shared/*, writes only the developer's own path and does nothing else. It lives in lexselect-devops (stage S11), outside this repository. tools/lexsup/internal/creds/remote.go:19–27; tools/lexsup/internal/creds/remote.go:45–66; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:135–142; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:191–196; docs/implementation-plans/2026-11-17-v2-credentials.md:49; docs/implementation-plans/2026-11-17-v2-credentials.md:161; docs/credentials/requirements.md:139
- K.17For a reference
aws-ssm:/lexselect/dev/{user}/…, the broker reads the SecureString parameter with the session of the developer (SSMRemote.Fetch): it replaces {user} with the slug, asks SSM with decryption and returns only the value. The app holds no AWS credential. A missing parameter gets unknown and the command lexsup creds set. Before the launch of an app that needs a remote key, the session daemon calls Check and refuses to start the app without a session (CR-BRK-5). lexsup creds set <name> reads the value from a prompt with no echo and writes it to the developer's own path as a SecureString under the key alias/lexselect-dev-secrets. tools/lexsup/internal/creds/remote.go:91–114; tools/lexsup/internal/creds/remote.go:116–132; tools/lexsup/internal/creds/serve.go:65–77; tools/lexsup/internal/creds/broker.go:25–27; tools/lexsup/internal/cli/daemon_broker.go:41; tools/lexsup/internal/cli/daemon.go:86–90; tools/lexsup/internal/cli/credsset.go:24–52; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:135–142; docs/credentials/requirements.md:127–131
- K.18A KMS key encrypts the development parameters. Its key policy lets the permission set
DevSecrets decrypt only under the developer's own path and the shared path, through the encryption context PARAMETER_ARN. docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:191–196; docs/implementation-plans/2026-11-17-v2-credentials.md:49; docs/implementation-plans/2026-11-17-v2-credentials.md:161
- K.19In the profile
sim, the app gets the same broker and the same references as in local, and lexsup routes the providers to Lex Lab Mirage. The developer needs no IAM Identity Center session. Today lexsup always sets LEXSELECT_PROFILE to local; the broker and the resolver already accept sim, and the routes already send a provider to Mirage. tools/lexsup/internal/envx/clean.go:84; tools/lexsup/internal/cli/daemon_broker.go:39; contracts/credentials/v1/runtime.go:127–135; tools/lexsup/internal/envx/envx.go:121–125; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:54–67; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:230–231
- K.20In the profile
cloud, the task role of the app fetches each credential by ARN, in the process. The template sets LEXSELECT_PROFILE to cloud and passes each ARN as plain config, for example aws-sm:{config:IDENTITY_V2_MONGODB_SECRET_ARN}#password, and the task environment holds no credential. The resolver asks the provider that the scheme names. The Go blocks pass no AWS provider yet, so a cloud start fails with unavailable. The templates exist; the connectors are still to come. contracts/credentials/v1/runtime.go:16–18; contracts/credentials/v1/runtime_get.go:36–45; services/engine--go/identity/cmd/identity-v2/main.go:110; services/engine--go/identity/runtime.toml:212; services/engine--go/gateway/deploy/cloudformation/api-gateway-v2.yaml:910–912; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:181–189; docs/implementation-plans/2026-11-17-v2-credentials.md:159
- K.21The template of API gateway v2 puts each secret in Secrets Manager and encrypts it with one KMS key of the stack (
SecretsKey). The key policy lets the task role decrypt through Secrets Manager (TaskRoleReadsSecrets), and the execution role and the rotation function each get their own statement. The task role may call secretsmanager:GetSecretValue on these secrets only. The DocumentDB password rotates every 30 days. The templates of identity v2 and API management v2 follow the same plan (stage S9). services/engine--go/gateway/deploy/cloudformation/api-gateway-v2.yaml:174–178; services/engine--go/gateway/deploy/cloudformation/api-gateway-v2.yaml:213–221; services/engine--go/gateway/deploy/cloudformation/api-gateway-v2.yaml:289–295; services/engine--go/gateway/deploy/cloudformation/api-gateway-v2.yaml:324–325; services/engine--go/gateway/deploy/cloudformation/api-gateway-v2.yaml:693–703; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:184–188; docs/credentials/requirements.md:150–152
- K.22A CloudTrail rule (
SecretReadAlarmRule) raises an alarm when an identity other than the task role, the execution role and the rotation function reads a secret of the stack. ECS Exec is off on the services: EnableExecuteCommand: false. services/engine--go/gateway/deploy/cloudformation/api-gateway-v2.yaml:863; services/engine--go/gateway/deploy/cloudformation/api-gateway-v2.yaml:947; services/engine--go/gateway/deploy/cloudformation/api-gateway-v2.yaml:970–982; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:186–188; docs/credentials/requirements.md:156
- K.23In the profile
mkt, the customer gives the ARNs at install. The task role in the customer's account reads the customer's secrets by ARN. The account of the customer holds no secret of LexSelect. docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:188–189; docs/implementation-plans/2026-11-17-v2-credentials.md:52; docs/credentials/requirements.md:161; docs/credentials/requirements.md:164–165; services/engine--go/identity/runtime.toml:213
R · Deployingarch-v1
Shows how a change reaches what runs: the application deploys through the branches of lexselect-deployment, and the infrastructure deploys itself from the main of lexselect-devops.
- builds each image on a push and publishes the web and function artifacts (R.1, R.2, R.8)
- moves dev-main after a green build, and deploys an environment from its branch to arch-v1 and server1 (R.3–R.7)
- deploys the infrastructure from lexselect-devops' main, one part after another (R.9–R.13)
- R.1A push to any branch of lexselect runs the workflow
All, which builds each image after its checks. .github/workflows/build-all.yml:1–12; docs/guides/deploying.md:10–12
- R.2
All pushes each image to ECR in the arch-v1 account as lexselect-ci-build, tagged by its folder and commit. .github/workflows/build-all.yml:228–232; .github/workflows/build.yml:223–245
- R.3After a green
All on main, Bump dev-main takes that build, at most once every 30 minutes. .github/workflows/bump-dev-main.yml:1–11; .github/workflows/bump-dev-main.yml:31–37
- R.4It pushes the build's commit to
deploy/dev-main of lexselect-deployment. A person edits deploy/daily, deploy/weekly and deploy/main by hand. .github/workflows/bump-dev-main.yml:1–11; docs/guides/deploying.md:13–18
- R.5The push runs the branch's
deploy.yml: it claims a slot, then applies iac/ with Terraform (make tf-apply-hard) and the branch's tfvars. scripts/dev-env-deploy.yml:1–9; scripts/dev-env-deploy.yml:32–34; scripts/dev-env-deploy.yml:75–76; scripts/dev-env-deploy.yml:153; scripts/deploy.sh:755–767
- R.6ECS takes each service's image from ECR by the tag that the deploy names. scripts/deploy.sh:755–767; docs/guides/deploying.md:19–21
- R.7For a dev environment, the job
server1 on the runner server1-deploy delivers the bundle, and bin/lexsup-deploy of lexselect-devops starts the environment as lexdev. scripts/dev-env-deploy.yml:165–181; scripts/dev-env-deploy.yml:188–219; scripts/server1.sh:2–11; scripts/server1.sh:24
- R.8A push also writes each web app's files to
v2/web/ of the artifact bucket (board F), and builds and tests the functions' zips in Docker: the release zips go to v2/functions/, the gate zips and images to the gate base of lexselect-sandbox. .github/workflows/function-artifacts.yml:1–13; .github/workflows/function-artifacts.yml:26–29; docs/guides/deploying.md:26–28
- R.9A merge to
main of lexselect-devops, a daily run at 10:17 UTC and a dispatch run deploy-main. A push deploys each part whose folder changed since the last run that passed. docs/guides/deploying.md:32–37
- R.10After its checks and its Environment,
landing-zone deploys first: bin/converge applies exactly the planned change sets of every live stack, then bin/verify runs the live checks. docs/guides/deploying.md:38–43
- R.11Then
arch-v1-aws: as lexselect-ci-iac-admin through GitHub OIDC, a refresh-only plan reports the drift, then Terraform applies exactly the plan. docs/guides/deploying.md:44–46
- R.12Then
arch-v1-gcp: as arch-v1-gcp-deployer through the workload identity pool, the same plan and apply. docs/guides/deploying.md:47–48
- R.13Last
server1: on the box's runner lexselect-s-1-apply, bin/server1-apply reports the drift and runs only the steps that the change or the drift needs. docs/guides/deploying.md:49–52
H · Lex Gatearch-v1
Decides whether a version of LexSelect may be released (ADR 076). Partial runs on any environment feed one version, the version computes the verdict, and a person publishes a frozen selection that Slack and the deploy check read.
- starts a run of chosen suites at a commit and measures it with the producers (H.1–H.4)
- shows live logs from the local session during module and throughput rows (H.21)
- keeps the run record and one standard result for each suite (H.5, H.6)
- computes the version's verdict at its current commit, brings offline runs to the shared store and shows them in Lab Lens (H.7–H.10)
- publishes a frozen selection and posts it to Slack (H.11, H.12)
- creates the release version at the merge of its version command and moves its current commit at each later merge (H.13)
- lets a deploy go only with a ready publication and an approval, then marks the version Released (H.14, H.15)
- keeps each suite's expectations, which anyone changes from Lab Lens with a reason (H.16)
- links each feature of the quality catalog to its ClickUp task and copies the task into the index (H.17)
- shows the run store's size and its cost for the month on the Dashboard of Lab Lens (H.18)
- exports a version, a publication or a comparison as a PDF through a preset, written once (H.19)
- carries passing quality checks to a newer commit where no changed path maps to their feature (H.20)
- H.1A person or a schedule starts a run of one or more suites at one commit with
lex-lab run --suites or make lex-gate. Suite 1, output quality, runs outside the v2 gate file with --gate quality: its result joins the version, whose verdict judges against lex-gate alone. A run that measures against a target goes alone on a machine, under the Executor's lock file. A run of feature-scale cases, which checks a feature under light load, takes no lock and does not wait for a quiet machine. Before the run starts, the Executor names its version from the index: on main the release of the VERSION file, on a branch the version of the branch's first run, or a new branch version <year>.<week>-dev.<slug> in the ISO week of this run. services/engine-rust/crates/lab-executor/src/main.rs:412; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:1440; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:1460; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:1764; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:1701; services/engine-rust/crates/lab-executor/src/machine.rs:78; services/engine-rust/crates/lab-exporter/src/lexgate.rs:716; services/engine-rust/crates/lab-version/src/lib.rs:65; services/engine-rust/crates/lab-version/src/lib.rs:214; docs/lex-gate/requirements.md:60; docs/lex-gate/requirements.md:83; docs/lex-gate/requirements.md:230
- H.2From Lab Lens, a person starts the same run: Lens queues a job of its own environment in the index, the chosen suites or the mandatory ones with no valid result, and asks the name of who confirms the cost of a suite on the real providers, which the suite results of its run keep. A job may hold one lab job in place of suites: a case repeated, an A/B of two refs or the replay of a stored run, which the Lens checks again before it runs. Its worker takes the oldest job under a lease, one at a time, and starts
lex-lab --align-session run --suites, which prepares the session, or the lab job's command. The queue survives a restart of Lens. services/engine-rust/crates/lab-lens/src/queue.rs:63; services/engine-rust/crates/lab-lens/src/queue.rs:102; services/engine-rust/crates/lab-lens/src/queue.rs:179; services/engine-rust/crates/lab-lens/src/queue.rs:209; services/engine-rust/crates/lab-lens/src/queue.rs:247; services/engine-rust/crates/lab-lens/src/queue.rs:356; services/engine-rust/crates/lab-lens/src/queue.rs:515; services/engine-rust/crates/lab-lens/src/main.rs:208; services/engine-rust/crates/lab-lens/src/jobs.rs:308; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:1678; docs/lex-gate/requirements.md:91; docs/lex-gate/requirements.md:226; docs/lex-gate/requirements.md:230; docs/lex-gate/requirements.md:231; docs/lex-gate/requirements.md:232; docs/lex-gate/requirements.md:233; docs/lex-gate/requirements.md:234; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:82–84
- H.3For a local gate run,
make lex-gate ROWS=… starts the apps of the first selected row. The Executor then checks each row's apps, settings and provider routes. With --align-session, it sets the build of each block through the session daemon. It waits for the target apps and any apps that lexsup restarts. A required app that is missing or stopped stays on the wait list. A stopped app outside that list cannot delay the run. The Executor restores the settings at the end. For another commit, it makes a temporary worktree and starts its environment there. Makefile:547–555; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:1375–1392; services/engine-rust/crates/lab-executor/src/session.rs:190; services/engine-rust/crates/lab-executor/src/session.rs:219; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:383; services/engine-rust/crates/lab-executor/src/align.rs:47; services/engine-rust/crates/lab-executor/src/align.rs:219; services/engine-rust/crates/lab-executor/src/align.rs:242–245; services/engine-rust/crates/lab-executor/src/align.rs:313; services/engine-rust/crates/lab-executor/src/align.rs:356; services/engine-rust/crates/lab-executor/src/session.rs:45–54; services/engine-rust/crates/lab-executor/src/session.rs:452–455; services/engine-rust/crates/lab-executor/src/git.rs:315; docs/lex-gate/requirements.md:90; docs/lex-gate/requirements.md:232
- H.4Each producer writes its raw results unchanged, in its own format, to the run store beside the run record. services/engine-rust/crates/lab-executor/src/lexgate/record.rs:337; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:349; docs/lex-gate/requirements.md:106; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:51–57
- H.5The Executor writes the run record once: the settings and their hash, the code, the tools, the machine, the routes and the seed. services/engine-rust/crates/lab-executor/src/lexgate/output.rs:346; docs/lex-gate/requirements.md:83; docs/lex-gate/requirements.md:85; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:65–68
- H.6When the run ends, the adapter of each suite turns the raw results into one standard result, stored in the run store and in the index with the adapter's version and the hash of the raw files.
lex-lab readapt adapts the stored raw results again with a newer adapter, and lex-lab migrate adapts the gate records stored before ADR 076 through the adapter gate-record. A row whose modules wrote no report in this run stores no result, so the verdict keeps the suite's newest valid result or shows that it could not run. A migrated record of a row that could not run gives an invalid result. services/engine-rust/crates/lab-executor/src/lexgate/record.rs:145; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:380; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:383; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:417; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:559; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:820; docs/lex-gate/requirements.md:107; docs/lex-gate/requirements.md:118; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:45–49; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:51–57
- H.7The Executor moves the version's current commit when the run's commit descends from it, and computes the verdict, the score and the coverage from the newest valid result of each suite, through a compare-and-set. A release's state follows: a move sends it back to Gathering, and a valid result for each mandatory built suite makes it Complete. After a rewritten history,
lex-lab reset sets the current commit and writes the audit trail; a gate run does it by itself for the dev version of a branch with no publication, when its commit neither descends from nor precedes the current commit, and says so in one line. services/engine-rust/crates/lab-executor/src/lexgate/record.rs:448; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:467; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:483; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:490; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:546; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:652; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:1130; docs/lex-gate/requirements.md:63; docs/lex-gate/requirements.md:145; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:39–43; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:70–74
- H.8An offline laptop keeps its runs in a local directory and a local index.
lex-lab push copies them to the shared run store and index once: each suite result takes the next number of its version there, and each version it touches computes its verdict again. services/engine-rust/crates/lab-executor/src/lexgate/record.rs:911; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:416; docs/lex-gate/requirements.md:228; docs/lex-gate/requirements.md:232
- H.9Lab Lens reads the versions, their suite results and the heartbeats of every environment from the index, and each standard result from the run store. A confirmed delete on the Runs page removes the selected run’s list entry from the index. The run store and the suite results keep their records. It answers only requests to its own Host from its own origin or from the origin of its page (
LAB_UI_ALLOWED_ORIGINS), and answers its page's reads with CORS headers. It does not start when the index lacks a table. services/engine-rust/crates/lab-lens/src/versions.rs:71; services/engine-rust/crates/lab-lens/src/versions.rs:96; services/engine-rust/crates/lab-lens/src/versions.rs:459; services/engine-rust/crates/lab-lens/src/versions.rs:499; services/engine-rust/crates/lab-lens/src/main.rs:159; services/engine-rust/crates/lab-ui/src/server.rs:231; services/engine-rust/crates/lab-ui/src/server.rs:265; services/engine-rust/crates/lab-ui/src/server.rs:312; docs/lex-gate/requirements.md:227; docs/lex-gate/requirements.md:236; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:76–80; services/engine-rust/crates/lab-lens/src/run_deletion.rs:16; services/engine-rust/crates/lab-exporter/src/db.rs:394
- H.10Each Lens writes its heartbeat to the index each minute: its environment, which lexsup names in
LAB_ENVIRONMENT, the address of its page (LAB_LENS_WEB_URL), else its own address, and its host. An environment shows online for two minutes after its last heartbeat. services/engine-rust/crates/lab-lens/src/heartbeat.rs:45; services/engine-rust/crates/lab-lens/src/heartbeat.rs:71; services/engine-rust/crates/lab-lens/src/heartbeat.rs:84; services/engine-rust/crates/lab-lens/src/main.rs:209; tools/lexsup/internal/envx/envx.go:123; docs/lex-gate/requirements.md:237; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:76–80
- H.11A person publishes a version from Lab Lens, which starts
lex-lab publish, or with that command. A compare-and-set on the version gives the next number, the selected standard results are copied into the publication's evidence package in the run store, and the record is written once to the index. Each suite lists every valid result on the commit, and a result that is not the newest carries the publisher's reason. A release publication holds every mandatory suite, its throughput from the reference runner when the gate file names one, else from each block owner's own machine. A green, complete release publication may carry the ready mark, which makes the release Ready through a compare-and-set. services/engine-rust/crates/lab-executor/src/lexgate/publish.rs:65; services/engine-rust/crates/lab-executor/src/lexgate/publish.rs:146; services/engine-rust/crates/lab-executor/src/lexgate/publish.rs:171; services/engine-rust/crates/lab-executor/src/lexgate/publish.rs:284; services/engine-rust/crates/lab-executor/src/lexgate/publish.rs:298; services/engine-rust/crates/lab-executor/src/lexgate/publish.rs:316; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:672; services/engine-rust/crates/lab-lens/src/versions.rs:340; services/engine-rust/crates/lab-lens/src/jobs.rs:329; docs/lex-gate/requirements.md:159; docs/lex-gate/requirements.md:160; docs/lex-gate/requirements.md:161; docs/lex-gate/requirements.md:162; docs/lex-gate/requirements.md:163; docs/lex-gate/requirements.md:165; docs/lex-gate/requirements.md:166; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:82–84
- H.12The Executor posts the publication to Slack with the bot token of the app Lex Gate, from
LAB_SLACK_TOKEN or else the SSM parameter /lexselect/lex-gate/slack-bot-token: to #lex-gate, the channel of a schedule's environment or the engineer's direct message, unless the publisher names a channel. A post of the same version, commit and channel is edited, with a note in its thread. The post shows the failing suites first, at most 12, and mentions their owners from CODEOWNERS and gates/owners.toml. A post that does not land stays pending until lex-lab post sends it. services/engine-rust/crates/lab-executor/src/lexgate/post.rs:247; services/engine-rust/crates/lab-executor/src/lexgate/post.rs:312; services/engine-rust/crates/lab-executor/src/lexgate/post.rs:386; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:497; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:562; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:587; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:635; services/engine-rust/crates/lab-slack/src/message.rs:171; services/engine-rust/crates/lab-slack/src/channel.rs:42; services/engine-rust/crates/lab-slack/src/client.rs:106; services/engine-rust/crates/lab-slack/src/client.rs:132; services/engine-rust/crates/lab-adapters/src/owners.rs:72; docs/lex-gate/requirements.md:88; docs/lex-gate/requirements.md:174; docs/lex-gate/requirements.md:175; docs/lex-gate/requirements.md:176; docs/lex-gate/requirements.md:177; docs/lex-gate/requirements.md:178; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:86–88
- H.13At each push to
main, or to a branch release/<version>, the release workflow runs lex-lab follow. It reads the pushed commit's VERSION file. The first push that names a release creates it in the state Gathering. Each later push moves its current commit forward with a compare-and-set and sends a Complete or Ready release back to Gathering, and a Released release keeps its commit. Each change writes an audit entry. .github/workflows/lex-gate-release.yml:75; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:1084; services/engine-rust/crates/lab-executor/src/lexgate/follow.rs:71; docs/lex-gate/requirements.md:61; docs/lex-gate/requirements.md:63; docs/lex-gate/requirements.md:64
- H.14The required check of the deployment pull request runs
lex-lab deploy-check. The release is the commit that the pull request's changed pins move to, in its deployments file against the base branch's: a deploy that moves no pin carries no release, and one that moves pins to several commits is refused. The check needs a ready publication of that commit in the index (a ten-character pin finds its full commit), a release reviewer's approval of the pull request's head commit, read from GitHub, with no release reviewer requesting changes, and a green can-i-deploy for each v2 block image; a deploy with no v2 block image asks none. The label lex-gate-override of a release reviewer, with a reason, passes it while the index is down, and the check writes the override to the audit trail. The command exists; arch-v2's deployment pipeline, which does not exist yet, will run it. Lex Gate measures arch-v2 only, so arch-v1's deploy runs no check. services/engine-rust/crates/lab-executor/src/lexgate/deploy_pins.rs:103; services/engine-rust/crates/lab-executor/src/lexgate/deploy_check.rs:119; services/engine-rust/crates/lab-executor/src/lexgate/deploy_check.rs:252; services/engine-rust/crates/lab-executor/src/lexgate/deploy_check.rs:274; services/engine-rust/crates/lab-executor/src/lexgate/deploy_check.rs:325; services/engine-rust/crates/lab-executor/src/lexgate/deploy_check.rs:365; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:190; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:266; docs/lex-gate/requirements.md:188; docs/lex-gate/requirements.md:189; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:90–94
- H.15After a deploy of arch-v2,
lex-lab release marks the version Released, writes the baselines of its release from its ready publication and posts to #releases. arch-v2's deployment pipeline, which does not exist yet, will run it; until then a person runs it. services/engine-rust/crates/lab-executor/src/gate_cmd.rs:965; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:972; services/engine-rust/crates/lab-executor/src/lexgate/release.rs:61; docs/lex-gate/requirements.md:191; docs/lex-gate/requirements.md:136; docs/adr/ADR_076_lex_gate_versions_modules_standard_result.md:90–94
- H.16On the Expectations page of Lab Lens, a person changes a measure's fixed range, baseline or projections, with a declared name and a reason. Lens writes the expectation through a compare-and-set and an audit entry with the old and the new value, and the next judgement of a result reads it. services/engine-rust/crates/lab-lens/src/expectations.rs:382; docs/lex-gate/requirements.md:138; docs/lex-gate/requirements.md:252
- H.17
make features-clickup-sync runs lex-lab features-sync: for each feature of the output-quality catalog that names its ClickUp task, the Executor reads the task's title and status, sets the task's field "Lab Lens" to the feature's page in Lab Lens, fills the fields Area, Client and Score that the list has (Score from the newest quality result), and writes the title and the status to the index for Lens. Every ClickUp call is paced to 90 a minute, under ClickUp's limit. services/engine-rust/crates/lab-executor/src/gate_cmd.rs:834; services/engine-rust/crates/lab-executor/src/lexgate/features.rs:348; services/engine-rust/crates/lab-executor/src/clickup.rs:257; docs/lex-gate/requirements.md:202; docs/lex-gate/requirements.md:205
- H.18The Dashboard of Lab Lens shows the run store's size and its cost for the month. The size is the newest daily
BucketSizeBytes of the bucket from CloudWatch. The cost is the unblended cost of the resources tagged feature = lex-lab from Cost Explorer. Each Cost Explorer request costs $0.01, so a Lens asks again only after six hours. A local store gives the size of its files and no cost. services/engine-rust/crates/lab-lens/src/store_cost.rs:30; services/engine-rust/crates/lab-lens/src/store_cost.rs:168; services/engine-rust/crates/lab-lens/src/store_cost.rs:220; services/engine-rust/crates/lab-lens/src/main.rs:210; docs/lex-gate/requirements.md:284
- H.19A person exports a version, a publication or a comparison of versions from Lab Lens through a preset: CEO, Team, Client or Audit. Lens builds the data, keeps only the sections and fields the preset names, hides the text patterns, and shows the draft, whose labels, order and rounding the author edits. Finishing it prints the same page with headless Chromium, which opens it at the address of the Lens's page (
LAB_LENS_WEB_URL), and writes the data and the PDF once to the run store, with the preset's version and the data's sha256, and the record to the index. services/engine-rust/crates/lab-lens/src/exports.rs:361; services/engine-rust/crates/lab-lens/src/exports.rs:391; services/engine-rust/crates/lab-lens/src/exports.rs:415; services/engine-rust/crates/lab-lens/src/presets.rs:213; services/engine-rust/crates/lab-lens/src/reports.rs:533; services/engine-rust/crates/lab-lens/src/reports.rs:550; services/engine-rust/crates/lab-lens/src/main.rs:194; docs/lex-gate/requirements.md:270–275; docs/lex-gate/requirements.md:320
- H.20
lex-lab carry --version carries the passing quality checks of the version's newest earlier result to its current commit. The Executor runs make feature-impact between the two commits, keeps the passing checks of the features that no changed path maps to, and writes them as a carried result, carry@1.0.0, with the tool's output attached, to the run store and the index. When the tool fails or calls its seed snapshot invalid, nothing carries over. services/engine-rust/crates/lab-executor/src/lexgate/carry.rs:46; services/engine-rust/crates/lab-executor/src/lexgate/carry.rs:153; services/engine-rust/crates/lab-executor/src/lexgate/carry.rs:238; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:296; docs/lex-gate/requirements.md:146
- H.21For a module or throughput row with a local target, the Executor opens the session log stream before it prepares the row. Each service line keeps its time, level and source. The terminal shows Cargo and supervisor setup output as it arrives. The gate terminal uses the log colors from
make attach for the clock, level and source. It labels setup and Executor output lex-gate and module test output with its row ID, such as gate-2b.1. If the target lists no apps, the terminal shows all session sources. The Executor switches sources before the next row. It closes the last stream after it restores the build settings. services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:424; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:439; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:473; services/engine-rust/crates/lab-executor/src/lexgate/live_logs.rs:24; services/engine-rust/crates/lab-executor/src/lexgate/live_logs.rs:30–38; services/engine-rust/crates/lab-executor/src/lexgate/live_logs.rs:74–76; tools/lexsup/internal/cli/attach.go:145–159; Makefile:336; Makefile:545; tools/lexsup/internal/cli/format_logs.go:41
H0 · Data relationarch-v1
Shows how the data of Lex Gate and Lab Lens joins together: each table of the results database, each file of the run store, and the field that names the key of the next one.
- joins a suite result to its version, its run, its standard result and the raw results (H0.1–H0.4)
- joins the checks of a standard result to the features of the quality catalog (H0.5)
- joins a publication to its version and to the results it froze, and a Slack post to its publications (H0.6–H0.8)
- joins a job, an expectation and the audit trail to the versions and the runs they name (H0.9–H0.11)
- joins a run entry to its run record, and the groups and the suite invocations of the lab to their runs (H0.12–H0.14)
- joins labels, notes and noise bands to the runs they describe (H0.15, H0.16)
- joins a report to its subject, its profile and its files (H0.17, H0.18)
- H0.1A suite result belongs to a version and to a commit: its partition is
<version>@<commit>, and its sort key is the suite, a number that orders the results of the version, the run and the adapter version. It carries the number of the tree of rows, tree, and a record of another tree is not read. services/engine-rust/crates/lab-exporter/src/lexgate.rs:185–187; services/engine-rust/crates/lab-exporter/src/lexgate.rs:216–218; services/engine-rust/crates/lab-exporter/src/lexgate.rs:233–241; services/engine-rust/crates/lab-record/src/lexgate.rs:67
- H0.2A suite result names its run in
run_id. The id is the directory of the run record in the run store. services/engine-rust/crates/lab-exporter/src/lexgate.rs:195; services/engine-rust/crates/lab-exporter/src/objects.rs:9; services/engine-rust/crates/lab-exporter/src/objects.rs:13
- H0.3A suite result names its standard result in
result_key: one file for each suite and adapter version inside the run. A suite whose adapter failed has an error and no key. services/engine-rust/crates/lab-exporter/src/lexgate.rs:199–205; services/engine-rust/crates/lab-exporter/src/objects.rs:25–35
- H0.4A standard result names its input in
raw_sha256: the hash of the raw files of the suite that the adapter read. services/engine-rust/crates/lab-result/src/model.rs:19–21; services/engine-rust/crates/lab-exporter/src/objects.rs:19–21
- H0.5A check of a quality result may name a feature in
feature, the id of a row of the features table. services/engine-rust/crates/lab-result/src/model.rs:199–200; services/engine-rust/crates/lab-exporter/src/lexgate.rs:62–68
- H0.6A publication belongs to one version: its partition is the version name and its sort key is its number. services/engine-rust/crates/lab-exporter/src/lexgate.rs:296–301; services/engine-rust/crates/lab-exporter/src/lexgate.rs:348
- H0.7A publication freezes one result for each suite. Each published suite names the standard result it selected in
source_key and the frozen copy in evidence_key, in the evidence package of the publication. services/engine-rust/crates/lab-exporter/src/lexgate.rs:263–278; services/engine-rust/crates/lab-exporter/src/objects.rs:39–41
- H0.8A Slack post is keyed by version, commit and channel, and its
numbers list the publications it shows. services/engine-rust/crates/lab-exporter/src/lexgate.rs:355–370; services/engine-rust/crates/lab-exporter/src/lexgate.rs:388–394
- H0.9A job names its version in
version and the runs it produced in run_ids. Its partition names its environment, and the heartbeat of that environment has the environment as its sort key. services/engine-rust/crates/lab-exporter/src/lexgate.rs:27; services/engine-rust/crates/lab-exporter/src/lexgate.rs:433–443; services/engine-rust/crates/lab-exporter/src/lexgate.rs:469; services/engine-rust/crates/lab-exporter/src/lexgate.rs:486–490; services/engine-rust/crates/lab-exporter/src/lexgate.rs:500; services/engine-rust/crates/lab-exporter/src/lexgate.rs:673
- H0.10An expectation is keyed by suite and conditions (the machine class, the hash of the parameters and the hash of the limits) with the measure as its sort key. Its baseline names the version whose publication gave it. services/engine-rust/crates/lab-exporter/src/lexgate.rs:527–537; services/engine-rust/crates/lab-exporter/src/lexgate.rs:564–566; services/engine-rust/crates/lab-exporter/src/lexgate.rs:572–577; services/engine-rust/crates/lab-result/src/model.rs:145–151
- H0.11An audit entry names its subject: a version name, or
expectation:<suite>. Its sort key is the time, the host, the action and a digest of the new value. services/engine-rust/crates/lab-exporter/src/lexgate.rs:604–607; services/engine-rust/crates/lab-exporter/src/lexgate.rs:631–642; services/engine-rust/crates/lab-executor/src/lexgate/release.rs:174
- H0.12The entry of a run in the index has the run id as its partition, the same id as the directory of the run record. The upload of a run record writes the entry from the manifest. services/engine-rust/crates/lab-exporter/src/entities.rs:173–182; services/engine-rust/crates/lab-exporter/src/index.rs:15–17; services/engine-rust/crates/lab-exporter/src/index.rs:86–94; services/engine-rust/crates/lab-exporter/src/upload.rs:78; services/engine-rust/crates/lab-exporter/src/upload.rs:138
- H0.13A group lists the ids of its runs in
run_ids. The entry of a run names its group in group_id and its suite invocation in suite_id. services/engine-rust/crates/lab-exporter/src/objects.rs:51; services/engine-rust/crates/lab-exporter/src/objects.rs:67; services/engine-rust/crates/lab-exporter/src/index.rs:30–35
- H0.14A suite invocation lists the ids of its groups in
group_ids. services/engine-rust/crates/lab-exporter/src/objects.rs:74; services/engine-rust/crates/lab-exporter/src/objects.rs:88
- H0.15A label and an annotation name their subject, a run, a group or a suite, in
subject. The subject is the partition of an annotation and the end of the sort key of a label. services/engine-rust/crates/lab-exporter/src/objects.rs:95–99; services/engine-rust/crates/lab-exporter/src/objects.rs:112–114; services/engine-rust/crates/lab-exporter/src/entities.rs:200–217
- H0.16A noise band is keyed by the series key. The entry of a run carries the series key of its manifest. services/engine-rust/crates/lab-exporter/src/entities.rs:219–225; services/engine-rust/crates/lab-exporter/src/index.rs:57; services/engine-rust/crates/lab-exporter/src/index.rs:104
- H0.17A report names its subject in
subject: a run, a group, a comparison of two sides, a version, a publication or a comparison of versions. services/engine-rust/crates/lab-exporter/src/entities.rs:226–269; services/engine-rust/crates/lab-exporter/src/entities.rs:298–304
- H0.18A report names its profile in
profile, and the PDF and the data it shows in pdf_key and data_key. services/engine-rust/crates/lab-exporter/src/entities.rs:273–292; services/engine-rust/crates/lab-exporter/src/entities.rs:304–318
H1 · Output qualityarch-v1
Checks each feature of the output-quality catalog on its test documents, through the whole engine and the real providers.
- starts suite 1 with a confirmed cost and runs the command of its module (H1.1, H1.2)
- the test traffic: each document through the engine and the providers, then the status and the results (H1.3–H1.5)
- checks each feature, writes the report and the standard result, which board H keeps beside the verdict (H1.6–H1.8)
- runs the same row on a seeded mock, with no cost (H1.9)
- H1.1A person runs suite 1 with
lex-lab run --suites 1 --gate quality, or from Lab Lens. Suite 1 runs outside the v2 gate file: its result joins the version, and the verdict of the version judges against lex-gate alone. The module quality calls the real providers, so Lab Lens refuses the run until a person confirms the cost with their name, and the suite result keeps that name. services/engine-rust/gates/quality.toml:11–19; services/engine-rust/modules/quality/module.toml:15; services/engine-rust/crates/lab-lens/src/queue.rs:372; services/engine-rust/crates/lab-lens/src/queue.rs:597; services/engine-rust/crates/lab-executor/src/gate_cmd.rs:1678; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:63; docs/lex-gate/scenarios/1-output-quality.md:208–217
- H1.2The quality row runs the command of the module:
make lex-gate-quality. The module quality names the state of each part: the client is mock, and the API, the scheduler, the workers and the providers are real. services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:452; services/engine-rust/crates/lab-executor/src/lexgate/quality_row.rs:177; services/engine-rust/crates/lab-executor/src/lexgate/quality_row.rs:153; services/engine-rust/gates/quality.toml:21–25; services/engine-rust/modules/quality/module.toml:17–20
- H1.3The target
make lex-gate-quality reads the session's lab-customers.json: the URL of API gateway v2 and the key of the first test customer, which lexsup provisions for v2. It runs the suite benchmark-features with that base URL and UPLOAD_MODE=json. The runner submits one job for each test document and uploads it with a link: POST /documents/upload with a JSON body under version 2026-12-01, then a PUT of the file to the link. Thus suite 1 measures arch-v2. Makefile:653; Makefile:657–660; Makefile:663–664; services/evaluation/api_deployment_env_e2e/suite.py:35; services/evaluation/api_deployment_env_e2e/suite.py:68; services/evaluation/api_deployment_env_e2e/runner.py:93; services/evaluation/api_deployment_env_e2e/runner.py:369; services/evaluation/api_deployment_env_e2e/runner.py:377; services/evaluation/api_deployment_env_e2e/config.py:104; services/evaluation/api_deployment_env_e2e/config.py:135
- H1.4The engine processes each document for real: the API triggers the scheduler, the scheduler dispatches the tasks to the workers, and the workers call the real providers. The quality of the output depends on their answers. docs/lex-gate/scenarios/1-output-quality.md:31–34; docs/lex-gate/scenarios/1-output-quality.md:67–71
- H1.5The runner polls the status of each document,
GET /documents/{id}/processing/latest, until the processing ends, then fetches the result bundle. services/evaluation/api_deployment_env_e2e/runner.py:548; services/evaluation/api_deployment_env_e2e/runner.py:565; services/evaluation/api_deployment_env_e2e/runner.py:611
- H1.6The runner checks the expected result and each feature of the document's profile, then writes
report.json with one result for each check, with its feature, its document and its page. services/evaluation/api_deployment_env_e2e/runner.py:232; services/evaluation/api_deployment_env_e2e/runner.py:235; services/evaluation/api_deployment_env_e2e/features/evaluate.py:147; services/evaluation/api_deployment_env_e2e/suite.py:114; services/evaluation/api_deployment_env_e2e/suite.py:117; services/evaluation/api_deployment_env_e2e/report.py:116
- H1.7The quality row takes the newest
report.json that the command wrote, and the run store keeps the report and each preview under the raw files of the suite. services/engine-rust/crates/lab-executor/src/lexgate/quality_row.rs:154; services/engine-rust/crates/lab-executor/src/lexgate/quality_row.rs:155; docs/lex-gate/scenarios/1-output-quality.md:213–215
- H1.8The adapter
quality scores each document of a feature by the share of its required checks that pass, each feature by the average of its documents, and the suite by the average of its features, with the threshold 1.0. Board H keeps the result with the version, beside the verdict (H.6). services/engine-rust/crates/lab-adapters/src/quality.rs:201; services/engine-rust/crates/lab-adapters/src/quality.rs:239; services/engine-rust/crates/lab-adapters/src/quality.rs:295; services/engine-rust/crates/lab-executor/src/lexgate/quality_row.rs:156; services/engine-rust/gates/quality.toml:16
- H1.9The gate file
quality-mock runs the module quality-mock in place of the runner: mock_report.py writes a seeded report with no API, no engine and no provider, each part off, and the adapter quality reads it as a real result. It costs nothing, and its scores measure nothing. services/engine-rust/gates/quality-mock.toml:1–5; services/engine-rust/gates/quality-mock.toml:9–23; services/engine-rust/modules/quality-mock/module.toml:25–30; services/evaluation/api_deployment_env_e2e/mock_report.py:68; services/evaluation/api_deployment_env_e2e/mock_report.py:112
H2a · End-to-end, mocked inputs and outputsarch-v1
Proves the contract of the public API through the whole process at little cost: only the outside providers are mock, so the same input gives the same output.
- starts the session with each provider on Mirage and runs the suite (H2a.1, H2a.2)
- the test traffic: each route of each API version, the trigger, the tasks, Mirage's answers and the webhooks (H2a.3–H2a.6)
- records the passed cases (H2a.7)
- H2a.1A run starts the session of the version with each provider on Mirage,
make start LAB_MIRAGE=all, and sets Mirage to the preset of the gate. The record names the state of each part: the client and the providers are mock, the API, the scheduler, the workers and the stores are real. docs/lex-gate/scenarios/2a-end-to-end.md:60–64; docs/lex-gate/scenarios/2a-end-to-end.md:71–72
- H2a.2The run starts the extapi suite against the public API.
API_E2E_TARGET selects the API of the previous application, the default, or API gateway v2. docs/lex-gate/scenarios/2a-end-to-end.md:73; docs/lex-gate/scenarios/2a-end-to-end.md:91–93
- H2a.3The suite calls each route in each API version. The API keeps the documents in its stores and sends the trigger to the scheduler. docs/lex-gate/scenarios/2a-end-to-end.md:30–42; docs/lex-gate/scenarios/2a-end-to-end.md:58; docs/lex-gate/scenarios/2a-end-to-end.md:62
- H2a.4The scheduler dispatches the tasks to the workers and reads their results. docs/lex-gate/scenarios/2a-end-to-end.md:38
- H2a.5The workers call the providers, and Mirage answers at the network boundary in the wire format of each provider, so the HTTP clients, parsers, retries and timeouts of the workers stay in the test. The content comes from the hash of the page image, so one page always gives one content. docs/lex-gate/scenarios/2a-end-to-end.md:29–33; docs/lex-gate/scenarios/2a-end-to-end.md:64–67; docs/lex-gate/scenarios/2a-end-to-end.md:101–102
- H2a.6The API sends the webhooks to the receivers of the suite. The suite compares each answer and each webhook with its golden, and runs the cases that need a different setting in a second pass. docs/lex-gate/scenarios/2a-end-to-end.md:74–75; docs/lex-gate/scenarios/2a-end-to-end.md:94–97; docs/lex-gate/scenarios/2a-end-to-end.md:108–110
- H2a.7The run writes the result of each case to its record. The scenario scores the passed cases over all the cases. The record needs a payload kind for pass or fail, still to build. docs/lex-gate/scenarios/2a-end-to-end.md:76; docs/lex-gate/scenarios/2a-end-to-end.md:80–82; docs/lex-gate/scenarios/2a-end-to-end.md:115–118
H2b1 · API gateway v2arch-v1
Proves API gateway v2 alone through its own interface: the same inputs give the same calls, the same contracts and the same outputs, and the cases reach the code of the gateway.
- sets the gate build, checks that the session runs the gateway alone and runs its suite (H2b1.1–H2b1.4)
- the test traffic: the cases drive the gateway, and Mirage plays identity v2, API management v2 and processing (H2b1.5–H2b1.10)
- checks each case and the coverage, and the Executor scores the module (H2b1.11, H2b1.12)
- writes the report to the run store and the standard result, which board H judges (H2b1.13, H2b1.14)
- H2b1.1
lex-lab run runs row 2b.1 of the gate file: the module api-gateway-v2, with make lex-gate-2b MODULE=api-gateway-v2. The module module-suite names the state of each part: the client and the scheduler are mock, the API is real, the workers are off and the providers are mock. With --align-session, the Executor first sets gateway.build to gate through the session daemon, and it puts the setting back after the gate. services/engine-rust/gates/lex-gate.toml:24–28; services/engine-rust/gates/lex-gate.toml:37–52; services/engine-rust/modules/module-suite/module.toml:31–36; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:133; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:309; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:447
- H2b1.2For
make lex-gate ROWS=2b.1, a fresh session starts the gateway, Mirage and Collector. With --align-session, the Executor aligns the session to the target module-api-gateway-v2 when that file exists, else it stops the other v2 apps and starts the gateway. The target puts its neighbours on Mirage and the route of the gateway itself on its real service (real_routes), so Mirage does not play the module beside it after a row that routed it to Mirage. Then the gate checks the running apps against the [wiring] block of the module. With neighbours = "mock", only the gateway, its own stores and the lab apps of the target may run, and the gate refuses any other v2 service by its name. services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:607; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:627; services/engine-rust/crates/lab-executor/src/align.rs:90; services/engine-rust/crates/lab-executor/src/align.rs:387; services/engine-rust/targets/module-api-gateway-v2.toml:9; services/engine-rust/targets/module-api-gateway-v2.toml:18; services/engine-rust/crates/lab-executor/src/session_check.rs:41; services/engine-rust/crates/lab-adapters/src/session_check.rs:73; services/engine-rust/crates/lab-adapters/src/session_check.rs:112; services/engine-rust/modules/module-suite/module.toml:37; docs/lex-arch-v2/37-queues-and-module-alone.md:53–56
- H2b1.3Before a whole gateway suite, the plugin asks lexsup to restart the gateway in its gate build. In a gate stack the gateway starts fresh with the stack, so the plugin only waits. It waits for the protected case route before fixture setup. The fresh process opens its own connections and initializes its caches. A focused run uses the current gateway process. The gate build hooks the clients of Valkey, MongoDB, S3 and HTTP to count the calls of each case. On the aws set it also counts the calls of the AWS clients. The gate build serves the case route
POST /internal/lex-gate/case behind a bearer token, which it gets from the resolver of the block (ADR 082). At the end of each case, it empties the caches that reload by the clock, so each case starts from the same state. tests/v2-e2e/lex_gate/plugin.py:332–338; tests/v2-e2e/lex_gate/gateway_process.py:16; tests/v2-e2e/lex_gate/gateway_process.py:19; tests/v2-e2e/lex_gate/gateway_process.py:51; tools/lexsup/internal/cli/apps.go:143; tools/lexsup/internal/catalog/v2.go:16; services/engine--go/mk/server.mk:25; services/engine--go/gateway/internal/boot/gate_on.go:20; services/engine--go/gateway/internal/lexgate/gate.go:111; services/engine--go/gateway/internal/lexgate/gate.go:115–117; services/engine--go/gateway/internal/lexgate/gate.go:122; services/engine--go/gateway/internal/lexgate/routes.go:42–43; services/engine--go/kit/gatehook/gatehook.go:26
- H2b1.4The Executor runs the command of the module in a shell from the root of the repository. A target of kind
stack sets the form of the stack (ADR 091): stack-self gives the form self on Docker, stack-aws-local gives aws-local, the Lambda functions on LocalStack, and stack-aws gives aws, a CloudFormation stack in AWS. The Executor gives the command LEX_GATE_STACK_FORM and a prefix lg-<run>-<row>. The row then runs in a gate stack of its own, with no step on the session: lexsup stack up, the suite in the runner container, the report back, lexsup stack down. The forms aws-local and aws run the Lambda form of the gateway (ADR 093). They call other stores than the server does, so the suite and the Executor read the locks counts.lambda.lock and coverage.lambda.lock in place of counts.lock and coverage.lock. The form aws runs on the base of the account and builds nothing: lexsup stack up looks up the gate zips and the three images that CI published for the pushed commit, and refuses when one is missing. The prerequisite make lex-gate-deps of the command installs the test dependencies, and lex-lab session-check --align gives the module its session again when the target runs alone. The target runs pytest in tests/v2-e2e, a Poetry project of its own, one case at a time with the plugin lex_gate, under lexsup run in the families of the three v2 apps, so the suite reads the bearer tokens through the broker, and WEBHOOK_ALLOW_LOCALHOST lets the webhooks reach the receivers of the cases. The plugin shows each case before setup and its outcome after teardown. The pytest source shows a failed case at the error level. Alongside each case, the terminal shows new logs from the supervisor, API gateway v2, Mirage, Surge and the collector (H.21). tests/v2-e2e/lex_gate/plugin.py:77; tests/v2-e2e/lex_gate/plugin.py:95–97; tests/v2-e2e/lex_gate/plugin.py:117–125; services/engine-rust/targets/module-api-gateway-v2.toml:9; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:575; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:715; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:747; services/engine-rust/crates/lab-executor/src/lexgate/stack.rs:66; services/engine-rust/crates/lab-executor/src/lexgate/stack.rs:111; services/engine-rust/targets/stack-self.toml:5–6; services/engine-rust/targets/stack-aws-local.toml:7–8; services/engine-rust/targets/stack-aws.toml:5–6; tests/v2-e2e/lex_gate/settings.py:21; tests/v2-e2e/lex_gate/settings.py:109; tests/v2-e2e/lex_gate/settings.py:115–117; Makefile:451; scripts/lex-gate/stack-row.sh:75–81; services/engine-rust/crates/lab-executor/src/lexgate/shell.rs:25; Makefile:340; Makefile:385–388; Makefile:420–421; Makefile:438; Makefile:450–453; tests/v2-e2e/lex_gate/plugin.py:229
- H2b1.5A case drives the gateway through its interface: the public API with a test key, the routes of studio-api with a test token, the processing events and the replay request. The plugin checks each answer against the schema of its contract in
contracts/. docs/lex-gate/scenarios/2b-module-end-to-end.md:124–129; tests/v2-e2e/lex_gate/plugin.py:161; tests/v2-e2e/lex_gate/contracts.py:126
- H2b1.6Mirage plays identity v2 when the route
identity goes to lab-mirage: it publishes the key set on the stream lexselect:v2:identity:keys and the identity events, and signs a test token when a Studio case asks /api/identity/tokens. The gateway takes the newest key set from the stream, follows the stream for the next one and checks each token locally, with no HTTP call to identity v2. services/engine-rust/crates/lab-mirage-peers/src/identity.rs:354; services/engine-rust/crates/lab-mirage-peers/src/identity.rs:540; services/engine-rust/crates/lab-mirage/src/peers.rs:209; services/engine--go/kit/connector/identity/keyfeed/keyfeed.go:68; services/engine--go/kit/connector/identity/keyfeed/keyfeed.go:84; services/engine--go/gateway/internal/session/keys.go:14; services/engine--go/gateway/internal/session/keys.go:70; docs/lex-arch-v2/37-queues-and-module-alone.md:35–41
- H2b1.7Mirage plays API management v2. It publishes replay requests and sends access and webhook commands to the gateway on their streams. The cases seed and check the owner, key and endpoint records through the gate routes of the access records and the endpoints. They also check the revisions and the command results. For resync, the case reads the events that the gateway published through the gate route of the command events. Each seeded record must produce one change before its command result. services/engine-rust/crates/lab-mirage-peers/src/mgmt.rs:218; services/engine-rust/crates/lab-mirage-peers/src/mgmt.rs:250; services/engine-rust/crates/lab-mirage-peers/src/mgmt.rs:270; services/engine--go/gateway/internal/app/commands.go:73–74; tests/v2-e2e/test_gateway_commands_e2e.py:174; tests/v2-e2e/test_gateway_commands_e2e.py:219; tests/v2-e2e/test_gateway_commands_e2e.py:236; tests/v2-e2e/test_gateway_commands_e2e.py:244–245; tests/v2-e2e/support/v2/gate_stores.py:246; tests/v2-e2e/support/v2/gate_stores.py:299; services/engine--go/gateway/internal/lexgate/stores_access.go:16; services/engine--go/gateway/internal/lexgate/stores_access.go:19; services/engine--go/gateway/internal/lexgate/stores_webhooks.go:15; services/engine--go/gateway/internal/lexgate/stores_events.go:61; services/engine--go/gateway/internal/lexgate/stores_events.go:68
- H2b1.8A case steers Mirage's processing through its dashboard: it sets the controls
processing.* under a lock of the session, reads the trigger that Mirage took and ends a held run as completed or failed. Mirage writes the results and adds the end event. The gateway suite restores the result controls it changed. A Mirage restart during the run fails the check. tests/v2-e2e/support/v2/mirage.py:66; tests/v2-e2e/support/v2/mirage.py:81; tests/v2-e2e/support/v2/mirage.py:107; tests/v2-e2e/support/v2/mirage.py:113; tests/v2-e2e/lex_gate/plugin.py:298; tests/v2-e2e/lex_gate/plugin.py:327–331; services/engine-rust/crates/lab-mirage-proc/src/run.rs:255; services/engine-rust/crates/lab-mirage-proc/src/stream_events.rs:44
- H2b1.9The gateway keeps each request in its own stores: the documents and the upload jobs, the files in the object store, and the trigger on its stream. A case reads these records through the store routes of the gate build, which use the ports of the connector set, and compares them with a golden. services/engine--go/gateway/internal/routes/upload/link.go:149; services/engine--go/gateway/internal/connector/processingtrigger/valkeystream/publisher.go:39; services/engine--go/gateway/internal/lexgate/stores_util.go:41; services/engine--go/gateway/internal/lexgate/stores_docs.go:14; services/engine--go/gateway/internal/lexgate/stores_docs.go:15; services/engine--go/gateway/internal/lexgate/stores_uploads.go:15; services/engine--go/gateway/internal/lexgate/stores_objects.go:26; tests/v2-e2e/support/v2/gate_stores.py:49; tests/v2-e2e/support/v2/gate_stores.py:103; docs/lex-gate/scenarios/2b-module-end-to-end.md:125
- H2b1.10The gateway sends the webhook for the end event to the receiver. The cases check the signature, the body against its golden and retries after a 5xx response. For a manual replay, the handler or the delivery worker can claim the job. The case checks one signed delivery, a replay log entry with HTTP 200 and zero endpoint failures. services/engine--go/gateway/internal/webhooks/attempt.go:100; tests/v2-e2e/support/webhook_receiver.py:68; tests/v2-e2e/support/webhook_receiver.py:120; docs/lex-gate/scenarios/2b-module-end-to-end.md:128; services/engine--go/gateway/internal/webhooks/replay.go:96–100; services/engine--go/gateway/internal/webhooks/replay.go:168; services/engine--go/gateway/internal/webhooks/replay.go:174; services/engine--go/gateway/internal/webhooks/sender.go:169; services/engine--go/gateway/internal/webhooks/sender.go:177–182; tests/v2-e2e/test_webhook_replay_request_e2e.py:113; tests/v2-e2e/test_webhook_replay_request_e2e.py:118; tests/v2-e2e/test_webhook_replay_request_e2e.py:123; tests/v2-e2e/test_webhook_replay_request_e2e.py:127
- H2b1.11The plugin requires one distinct store receipt with the same decoded key for each successful upload PUT. Missing or unexpected receipts fail the case. On the aws set, the receipt is the notification that the bucket puts on the queue
object-events. A notification that a case sends through the gate route object-event counts as no receipt. A body that is no JSON object goes to the queue as it is, with no mark. The gate counts delivery of the claimed replay job under its original request. The case waits for active replay handlers and sends before it takes the snapshot. Each result poll for the bound job must have one webhook-jobs.Get and one MongoDB lookup. The plugin checks the initial job read and delivery work against the route lock, and each selected case against its contracts and goldens. services/engine--go/gateway/internal/lexgate/object_events.go:14; services/engine--go/gateway/internal/lexgate/object_events.go:27; services/engine--go/gateway/internal/lexgate/aws_routes.go:34; services/engine--go/gateway/internal/lexgate/aws_routes.go:128; services/engine--go/gateway/internal/lexgate/aws_routes.go:145; tests/v2-e2e/lex_gate/objects.py:20; tests/v2-e2e/lex_gate/objects.py:33; tests/v2-e2e/lex_gate/objects.py:44; services/engine--go/gateway/internal/lexgate/replay.go:118; services/engine--go/gateway/internal/lexgate/replay.go:134; services/engine--go/gateway/internal/lexgate/replay.go:146–147; services/engine--go/gateway/internal/lexgate/replay.go:153; services/engine--go/gateway/internal/lexgate/routes.go:154; services/engine--go/gateway/internal/lexgate/routes.go:157; services/engine--go/gateway/internal/lexgate/routes.go:166–167; services/engine--go/gateway/internal/lexgate/recorder.go:128–130; services/engine--go/gateway/internal/lexgate/recorder.go:152–154; tests/v2-e2e/lex_gate/plugin.py:449; tests/v2-e2e/lex_gate/plugin.py:454; tests/v2-e2e/lex_gate/plugin.py:470–471; tests/v2-e2e/lex_gate/plugin.py:477; tests/v2-e2e/lex_gate/plugin.py:493; tests/v2-e2e/lex_gate/counts.py:161–162; tests/v2-e2e/lex_gate/counts.py:176–178; tests/v2-e2e/lex_gate/goldens.py:122
- H2b1.12The gateway uses a hash of each case ID for its counter directory. The plugin reports total and per-package coverage from fresh case counters. A run of the self-hosted set leaves out the files of the aws connector set, which its own conformance suites cover. It uses up to four workers to list the packages each case reached under the original case ID. Only a full gateway run checks the coverage threshold, required operations, every expected case and the result relay. The Executor reads the module report for the score. services/engine--go/gateway/internal/lexgate/coverage.go:14; services/engine--go/gateway/internal/lexgate/coverage.go:41; tests/v2-e2e/lex_gate/coverage.py:199; tests/v2-e2e/lex_gate/coverage.py:206; tests/v2-e2e/lex_gate/coverage.py:50; tests/v2-e2e/lex_gate/coverage.py:265–266; tests/v2-e2e/lex_gate/coverage.py:276–277; tests/v2-e2e/lex_gate/plugin.py:778–783; tests/v2-e2e/lex_gate/plugin.py:802–809; tests/v2-e2e/lex_gate/report.py:84; services/engine-rust/crates/lab-executor/src/lexgate/module.rs:78
- H2b1.13The Executor copies the report of the module unchanged into the run store, under the raw results of row 2b.1. services/engine-rust/crates/lab-executor/src/lexgate/record.rs:334
- H2b1.14The adapter
module-suite turns the report into the standard result of row 2b.1, with the threshold 1.0. The fixed range of its coverage is its lock less 1.0 point, the tolerance of the plugin. Row 2b scores the average of its built modules. Board H takes the result from here (H.6, H.7). services/engine-rust/modules/module-suite/module.toml:27–29; services/engine-rust/crates/lab-adapters/src/module_suite.rs:32; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:373
H2b2 · API management v2arch-v1
Proves API management v2 alone through its own interface: the admin routes of the dashboard and the usage meter give the same calls, contracts and outputs for the same inputs.
- sets the gate build, checks that the session runs the module alone and runs its suite (H2b2.1–H2b2.4)
- the test traffic: the cases drive the module and steer Mirage as its neighbours, and read the module's own databases (H2b2.5, H2b2.6)
- checks each case and the coverage, writes the report and the standard result, which board H judges (H2b2.7–H2b2.9)
- H2b2.1
lex-lab run runs row 2b.2 of the gate file: the module api-mgmt-v2, with make lex-gate-2b MODULE=api-mgmt-v2. With --align-session, the Executor first sets mgmt.build to gate through the session daemon. services/engine-rust/gates/lex-gate.toml:54–69; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:133; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:309
- H2b2.2With
--align-session, the Executor first gives the module its target module-api-mgmt-v2: it stops the other v2 apps, starts API management v2, puts identity, the gateway and processing on Mirage and the route of API management v2 itself on its real service (real_routes), which row 2b.1 leaves on Mirage. Then the gate checks the running apps against the [wiring] block of the module and refuses any other v2 service by its name, as for the gateway (H2b1.2). services/engine-rust/crates/lab-executor/src/align.rs:90; services/engine-rust/crates/lab-executor/src/align.rs:387; services/engine-rust/targets/module-api-mgmt-v2.toml:16; services/engine-rust/crates/lab-adapters/src/session_check.rs:73; services/engine-rust/crates/lab-adapters/src/session_check.rs:112; docs/lex-arch-v2/37-queues-and-module-alone.md:53–56; docs/lex-arch-v2/37-queues-and-module-alone.md:70–71
- H2b2.3lexsup starts API management v2 again in its gate build. The gate build hooks the module's clients of MongoDB and Valkey to count the calls of each case, serves the case route
POST /internal/lex-gate/case and empties the caches that reload by the clock at the end of each case. tools/lexsup/internal/catalog/v2.go:27; services/engine--go/mk/server.mk:25; services/engine--go/mgmt/internal/lexgate/gate.go:67; services/engine--go/mgmt/internal/lexgate/routes.go:29; services/engine--go/kit/gatehook/gatehook.go:26
- H2b2.4The Executor runs the command of the module, which runs pytest one case at a time with the plugin
lex_gate on the cases of API management v2. services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:715; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:747; tests/v2-e2e/lex_gate/plugin.py:229
- H2b2.5A case calls the admin routes with a staff token that Mirage signs as identity v2, and steers Mirage through its dashboard: as identity v2 it publishes the views of the directory; as API gateway v2 it puts records, takes the commands of
access 3.0 and webhooks 2.0 in the group api-gateway-v2 and publishes their changes and results, or holds them so that a write answers 202; as processing it publishes the end events that the usage meter reads. tests/v2-e2e/test_admin_api_e2e.py:76; tests/v2-e2e/test_admin_api_e2e.py:264; tests/v2-e2e/test_admin_api_e2e.py:369; tests/v2-e2e/test_usage_meter_e2e.py:128; services/engine-rust/crates/lab-mirage/src/peers.rs:223; services/engine-rust/crates/lab-mirage-peers/src/config.rs:91; services/engine-rust/crates/lab-mirage-peers/src/gateway.rs:213; docs/lex-gate/scenarios/2b-module-end-to-end.md:234–236
- H2b2.6The module keeps the usage ledger, its copy of the records of API gateway v2 and its copy of the directory of identity v2 in its own MongoDB, and its streams in Valkey. The case reads them and compares them with its goldens. docs/lex-gate/scenarios/2b-module-end-to-end.md:234–235
- H2b2.7The plugin checks each selected case against its contracts, goldens and
counts.api-mgmt-v2.lock. It writes a report for the selection. Only a full module run checks all required operations and cases, and compares coverage with coverage.api-mgmt-v2.lock. tests/v2-e2e/lex_gate/plugin.py:449; tests/v2-e2e/lex_gate/plugin.py:493; tests/v2-e2e/lex_gate/plugin.py:778–783; tests/v2-e2e/lex_gate/plugin.py:796–807; tests/v2-e2e/lex_gate/report.py:84; tests/v2-e2e/lex_gate/settings.py:86
- H2b2.8The Executor copies the report of the module unchanged into the run store, under the raw results of row 2b.2. services/engine-rust/crates/lab-executor/src/lexgate/record.rs:334
- H2b2.9The adapter
module-suite turns the report into the standard result of row 2b.2, with the threshold 1.0. Board H takes the result from here (H.6, H.7). services/engine-rust/crates/lab-adapters/src/module_suite.rs:32; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:373
H2b3 · identity v2arch-v1
Proves identity v2 alone through its own interface: the sign-in host, the OpenID Connect endpoints and the management API give the same calls, contracts and outputs for the same inputs.
- sets the gate build, checks that the session runs the module alone and runs its suite (H2b3.1–H2b3.4)
- the test traffic: the suite drives the JSON API of the sign-in host as its page does and calls the management API (H2b3.5, H2b3.6)
- checks each case and the coverage, writes the report and the standard result, which board H judges (H2b3.7–H2b3.9)
- H2b3.1
lex-lab run runs row 2b.3 of the gate file: the module identity-v2, with make lex-gate-2b MODULE=identity-v2. With --align-session, the Executor first sets identity.build to gate through the session daemon. services/engine-rust/gates/lex-gate.toml:71–86; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:133; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:309
- H2b3.2With
--align-session, the Executor first gives the module its target module-identity-v2: it stops the other v2 apps, starts identity v2 and puts the route of identity itself on its real service (real_routes), which rows 2b.1 and 2b.2 leave on Mirage. A module with no target file gets the same rule from the provider of its block. Then the gate checks the running apps against the [wiring] block of the module and refuses any other v2 service by its name, as for the gateway (H2b1.2). services/engine-rust/crates/lab-executor/src/align.rs:387; services/engine-rust/crates/lab-adapters/src/session_check.rs:26; services/engine-rust/crates/lab-adapters/src/session_check.rs:73; services/engine-rust/crates/lab-adapters/src/session_check.rs:112; services/engine-rust/targets/module-identity-v2.toml:15; docs/lex-arch-v2/37-queues-and-module-alone.md:53–56; docs/lex-arch-v2/37-queues-and-module-alone.md:70–71
- H2b3.3lexsup starts identity v2 again in its gate build. The gate build counts the calls of each case, serves
GET /internal/lex-gate/operations and the case route POST /internal/lex-gate/case behind the bearer token IDENTITY_V2_LEX_GATE_TOKEN, and empties its signing keys at the end of each case, so each case starts from the same state. tools/lexsup/internal/catalog/v2.go:38; services/engine--go/mk/server.mk:25; services/engine--go/identity/internal/lexgate/gate.go:67; services/engine--go/identity/internal/lexgate/routes.go:21; services/engine--go/kit/gatehook/gatehook.go:26; docs/lex-gate/scenarios/2b-module-end-to-end.md:260–264; docs/lex-gate/scenarios/2b-module-end-to-end.md:268–271
- H2b3.4The Executor runs the command of the module, which runs pytest one case at a time with the plugin
lex_gate on the cases of identity v2. The suite reads the origin of identity v2 from IDENTITY_V2_URL. services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:715; services/engine-rust/crates/lab-executor/src/lexgate/flow.rs:747; tests/v2-e2e/lex_gate/plugin.py:229; docs/lex-gate/scenarios/2b-module-end-to-end.md:260–264
- H2b3.5The suite drives the sign-in host as its page does: it reads the CSRF token from
GET /session/v1/state and sends each change as JSON with X-CSRF-Token (contract identity-session). It registers a user, reads the verification link at /dev/mail, signs in with the code flow and PKCE S256, and calls the management API with the access token of the user. The mail sender is the log sender. tests/v2-e2e/support/identity_session.py:273; tests/v2-e2e/support/identity_session.py:288; tests/v2-e2e/support/identity_session.py:327; tests/v2-e2e/support/identity_session.py:346; tests/v2-e2e/support/identity_session.py:393; tests/v2-e2e/support/identity_session.py:448; docs/lex-gate/scenarios/2b-module-end-to-end.md:241–245
- H2b3.6Identity v2 keeps its users, codes, tokens and organizations in its own MongoDB database and its limits in its own Valkey. Its outbox relay sends the email and the events in a background loop. services/engine--go/identity/internal/config/config.go:134; services/engine--go/identity/cmd/identity-v2/ports.go:33; services/engine--go/identity/cmd/identity-v2/ports.go:52; docs/lex-gate/scenarios/2b-module-end-to-end.md:272–274
- H2b3.7The plugin checks each selected case against its contracts, goldens and
counts.identity-v2.lock. It writes a report for the selection. Only a full module run checks all required operations and cases, and compares coverage with coverage.identity-v2.lock. tests/v2-e2e/lex_gate/plugin.py:449; tests/v2-e2e/lex_gate/plugin.py:493; tests/v2-e2e/lex_gate/plugin.py:778–783; tests/v2-e2e/lex_gate/plugin.py:796–807; tests/v2-e2e/lex_gate/report.py:84; tests/v2-e2e/lex_gate/settings.py:86
- H2b3.8The Executor copies the report of the module unchanged into the run store, under the raw results of row 2b.3. services/engine-rust/crates/lab-executor/src/lexgate/record.rs:334
- H2b3.9The adapter
module-suite turns the report into the standard result of row 2b.3, with the threshold 1.0. Board H takes the result from here (H.6, H.7). services/engine-rust/crates/lab-adapters/src/module_suite.rs:32; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:373
H2b4 · Scheduler v2arch-v1
Proves each corner case of the scheduler by itself: each case decides every input, every answer and every fault, and compares the output with the expected output.
- starts the stores and the coverage build of the scheduler (H2b4.1)
- the test traffic: the inputs and the faults of each case on both sides (H2b4.2–H2b4.4)
- stops the scheduler, reads the coverage and records each case (H2b4.5, H2b4.6)
- H2b4.1A run starts RabbitMQ, Valkey and MongoDB, then the scheduler built with
go build -cover, with GOCOVERDIR set. The harness starts the binary itself, because lexsup sends SIGKILL 10 s after SIGTERM and Go writes the counters only at a clean exit. The record names the state of each part: the scheduler and its stores are real, the API and the workers are mock, the outside providers are off. docs/lex-gate/scenarios/2b4-scheduler-v2.md:61–67; docs/lex-gate/scenarios/2b4-scheduler-v2.md:86–88; docs/lex-gate/scenarios/2b4-scheduler-v2.md:99–101; docs/lex-gate/scenarios/2b4-scheduler-v2.md:109–110
- H2b4.2The upstream harness sends the inputs of each case: the document rows, the triggers and the admin commands. It also sends a repeated trigger, a trigger for an absent document, a cancel in the middle of a run, a retry, a document removal, a pause or a capacity reset. docs/lex-gate/scenarios/2b4-scheduler-v2.md:63; docs/lex-gate/scenarios/2b4-scheduler-v2.md:77; docs/lex-gate/scenarios/2b4-scheduler-v2.md:111
- H2b4.3The scheduler dispatches the tasks of each case to the Valkey streams and reads their results, as in row 3b.4. docs/lex-gate/scenarios/2b4-scheduler-v2.md:45; docs/lex-gate/scenarios/2b4-scheduler-v2.md:69
- H2b4.4The downstream harness gives the result that the case sets: it answers, fails, repeats, delays or drops the result of a task. A case can also stop a store in the middle of a write, or stop the process with SIGTERM or SIGKILL. docs/lex-gate/scenarios/2b4-scheduler-v2.md:66; docs/lex-gate/scenarios/2b4-scheduler-v2.md:78–80
- H2b4.5Each case compares its output with its expected output. At the end, the run stops the scheduler with SIGTERM and waits for its exit, so Go writes the coverage counters. docs/lex-gate/scenarios/2b4-scheduler-v2.md:112–113; docs/lex-gate/scenarios/2b4-scheduler-v2.md:90
- H2b4.6The run reads the coverage with
go tool covdata percent and writes the result of each case and the coverage to the record of the run. The scenario scores the passed cases over all the cases, with the coverage beside them. The record needs a payload kind for pass or fail and for coverage, still to build. docs/lex-gate/scenarios/2b4-scheduler-v2.md:91; docs/lex-gate/scenarios/2b4-scheduler-v2.md:114–115; docs/lex-gate/scenarios/2b4-scheduler-v2.md:119–125; docs/lex-gate/scenarios/2b4-scheduler-v2.md:152
H3a · End-to-end, mocked inputs and outputsarch-v1
Measures the throughput of the end-to-end path with mocked inputs and outputs: Mirage answers at once in place of every provider and processing, so a fall of the rate is a fall of the path through API gateway v2.
- checks the session against the target and provisions the test customers (H3a.1, H3a.2)
- sets Mirage and starts the collectors, then runs the ladder through Surge (H3a.3–H3a.5)
- the test traffic: the upload by link, the trigger, the simulated run, the webhook and the status reads (H3a.6–H3a.14)
- writes the run record and the standard result, which board H judges (H3a.15, H3a.16)
- H3a.1
lex-lab run runs row 3a of the gate file: the suite e2e-3a on the target gateway-alone, with the parameter set gateway/instant. The module surge-load names the state of each part: the client and the scheduler are mock, the API is real, the workers are off and the providers are mock. Before the first case, the Executor reads the apps, the settings and the provider routes of the running session and compares them with the target. The apps api_gateway_v2, api_mgmt_v2, lab-mirage, lab-surge and lab-collect must run, and only lab-lens, arch-board, identity_v2, its sign-in page identity-v2-web and studio_v2 may run beside them. The routes processing and local-webhooks go to Mirage, and both blocks run their release builds. With --align-session, which make lex-gate passes, the Executor starts an app of the target that does not run, stops an app outside the target and sets a setting or a route that differs. Without that flag, a difference stops the run, and the message names the make command that fixes it. services/engine-rust/gates/lex-gate.toml:110–132; services/engine-rust/modules/surge-load/module.toml:26–30; services/engine-rust/targets/gateway-alone.toml:7; services/engine-rust/targets/gateway-alone.toml:11; services/engine-rust/targets/gateway-alone.toml:12; services/engine-rust/targets/gateway-alone.toml:13; services/engine-rust/targets/gateway-alone.toml:17–19; services/engine-rust/crates/lab-executor/src/flows.rs:81; services/engine-rust/crates/lab-executor/src/align.rs:47; services/engine-rust/crates/lab-executor/src/align.rs:142; services/engine-rust/crates/lab-executor/src/align.rs:311; services/engine-rust/crates/lab-executor/src/runner.rs:373
- H3a.2The session provisions the test customers when the setting
provision.customers changes. With --align-session, the Executor sets it when the customers file is missing; without that flag, the run stops and names the command. For each customer, lexsup draws a raw key and runs the admin command of API gateway v2, the owner of the access store. The command writes the key with its rate, the identity of the sign-in subject and a verified webhook endpoint at Surge's receiver. The file lab-customers.json gives Surge the gateway's base URL, the keys and the signing secrets. tools/lexsup/internal/cli/provision_v2.go:71; tools/lexsup/internal/cli/provision_v2.go:102; tools/lexsup/internal/provision/v2.go:29; services/engine-rust/crates/lab-executor/src/flows.rs:86; services/engine-rust/crates/lab-executor/src/flows.rs:98
- H3a.3For each case, the Executor sets Mirage's preset and the values of the case. The preset
instant plays each run at once: no delay, no failure, the mode run and 3 pages. services/engine-rust/params/gateway/instant.toml:4–5; services/engine-rust/presets/lab-mirage/instant.toml:5–11; services/engine-rust/crates/lab-executor/src/runner.rs:411
- H3a.4Before the load starts, the Executor starts the collectors of
lab-collect in its own process, on the session of the target. They read the apps and their processes, Docker, the sockets, the change stream of the processings in MongoDB and the INFO of the gateway's Valkey. A sampler turns their snapshot into series rows each second. The egress watch ends the load and makes the run invalid when an app of the target connects to a host outside the machine. These collectors keep their fast cadence for the whole run: only the app lab-collect slows down while its env is idle. services/engine-rust/crates/lab-executor/src/runner.rs:172–180; services/engine-rust/crates/lab-collect/src/collectors.rs:99; services/engine-rust/crates/lab-executor/src/sampler.rs:235; services/engine-rust/crates/lab-executor/src/egress.rs:45; services/engine-rust/crates/lab-executor/src/egress.rs:76; services/engine-rust/crates/lab-executor/src/egress.rs:110
- H3a.5The Executor runs the case of the suite,
gateway-steps-small, as a child process, lab-surge run, with the preset, the seed and the values of the case: 2, 4 and 6 uploads in flight in steps of 20 s. Surge's webhook receiver listens on the port that lexsup reserved for the app lab-surge, which the endpoints of the customers name. services/engine-rust/suites/e2e-3a.toml:3; services/engine-rust/cases/gateway-steps-small.toml:11–12; services/engine-rust/crates/lab-executor/src/runner.rs:202; services/engine-rust/crates/lab-executor/src/runner.rs:273; services/engine-rust/crates/lab-executor/src/surge.rs:99; services/engine-rust/crates/lab-executor/src/surge.rs:261
- H3a.6Surge creates each document by link:
POST /documents/upload with the key of a customer. The gateway checks the key against its copy in Valkey and the limits of the key, stores the upload job in MongoDB and answers with a presigned PUT link to the object store. services/engine-rust/crates/lab-surge-engine/src/client/link.rs:60; services/engine-rust/crates/lab-surge-engine/src/client/link.rs:79; services/engine--go/gateway/internal/routes/upload/link.go:25; services/engine--go/gateway/internal/routes/upload/link.go:149; services/engine--go/gateway/internal/keys/cache.go:101; services/engine--go/gateway/internal/routes/upload/link_answer.go:43
- H3a.7Surge PUTs the file straight to the presigned link, with the headers of the link and no API key. A document counts as accepted when its PUT succeeds. services/engine-rust/crates/lab-surge-engine/src/client/link.rs:116; services/engine-rust/crates/lab-surge-engine/src/client/link.rs:143; docs/lex-gate/scenarios/3a-end-to-end.md:122–123
- H3a.8The object store posts an S3 notification for each object under
api-uploads/ to the gateway's object-event route. The gateway lands the upload, creates the document and writes the trigger to its outbox. services/engine--go/gateway/internal/connector/own/objects/objects.go:78; services/engine--go/gateway/internal/routes/upload/events.go:148; services/engine--go/gateway/internal/routes/upload/landing.go:172; services/engine--go/gateway/internal/routes/upload/trigger.go:65
- H3a.9The relay of the outbox sends each trigger to the stream
lexselect:v2:processing:triggers in Valkey, under the key prefix of the env. services/engine--go/gateway/internal/connector/processingtrigger/outbox/relay.go:140; services/engine--go/gateway/internal/connector/processingtrigger/valkeystream/publisher.go:39; services/engine--go/contract/processingtrigger/v2/contract.go:23
- H3a.10Mirage reads the triggers in the consumer group
processing and plays each run at once, by the preset instant. services/engine-rust/crates/lab-mirage-proc/src/stream_triggers.rs:19; services/engine-rust/crates/lab-mirage-proc/src/stream_triggers.rs:21; services/engine-rust/crates/lab-mirage-proc/src/stream_triggers.rs:200; services/engine-rust/crates/lab-mirage-proc/src/worker.rs:82; services/engine-rust/crates/lab-mirage-proc/src/worker.rs:106; services/engine-rust/crates/lab-mirage-proc/src/worker.rs:146
- H3a.11For each run, Mirage writes the page files to the object store, then the
pages rows and the processings record to MongoDB, as the processing block does through the contract processing-data. services/engine-rust/crates/lab-mirage-proc/src/run.rs:255; services/engine-rust/crates/lab-mirage-proc/src/mongo.rs:186; services/engine-rust/crates/lab-mirage-proc/src/mongo.rs:190; services/engine-rust/crates/lab-mirage-proc/src/mongo.rs:207
- H3a.12Mirage then adds the end event of the run to the stream
lexselect:v2:processing:events. services/engine-rust/crates/lab-mirage-proc/src/stream_events.rs:11; services/engine-rust/crates/lab-mirage-proc/src/stream_events.rs:44; services/engine-rust/crates/lab-mirage-proc/src/worker.rs:186
- H3a.13The gateway reads each end event and sends a signed webhook to the endpoint of the owner. Surge's receiver checks the signature and ends the wait of the document. services/engine--go/kit/connector/processingevents/valkeystream/consumer.go:67; services/engine--go/gateway/internal/webhooks/handler.go:28; services/engine--go/gateway/internal/webhooks/attempt.go:100; services/engine-rust/crates/lab-surge-engine/src/receiver.rs:235; services/engine-rust/crates/lab-surge-engine/src/receiver.rs:360
- H3a.14Surge reads the status of each document,
GET /documents/{id}/processing/latest, until it is final, and once after its webhook. The gateway answers from the document and its newest processing in MongoDB. services/engine-rust/crates/lab-surge-engine/src/client.rs:454; services/engine-rust/crates/lab-surge-engine/src/client.rs:464; services/engine-rust/crates/lab-surge-engine/src/document.rs:696; services/engine-rust/crates/lab-surge-engine/src/document.rs:705; services/engine--go/gateway/internal/connector/documents/mongo/read.go:28; services/engine--go/gateway/internal/connector/processingdata/mongo/processings.go:15
- H3a.15Surge measures what a client sees and writes its report: the rate and the latency of each step and route group, the errors and the step that ended healthy. The Executor writes the run record: the report as
raw/lab-surge/report.json, the series rows of Surge and of the collectors as series.parquet, the events and the calls that Mirage counted. services/engine-rust/crates/lab-surge-engine/src/engine.rs:1357; services/engine-rust/crates/lab-surge-engine/src/report.rs:486; services/engine-rust/crates/lab-executor/src/runner.rs:243; services/engine-rust/crates/lab-executor/src/runner.rs:719; services/engine-rust/crates/lab-executor/src/runner.rs:727
- H3a.16The adapter
surge-load of the module turns the load record into the standard result of row 3a: the median of the repetitions as its measure, and the limits of each repetition as checks. The score of the row is the rate over the baseline for the same machine, parameter set and gateway limits, and the threshold is 0.5. Board H takes the result from here (H.6, H.7). services/engine-rust/modules/surge-load/module.toml:22–23; services/engine-rust/crates/lab-adapters/src/surge_load.rs:32; services/engine-rust/crates/lab-executor/src/lexgate/record.rs:373; services/engine-rust/gates/lex-gate.toml:110–118; services/engine-rust/gates/expectations/3a.toml:6–9
H3b1 · API gateway v2arch-v1
Loads API gateway v2 by its contract: the Studio routes and the public API at a rising rate, bursts, a held backlog, a race on an idempotency key and hostile requests.
- checks the session against the target and provisions the users and the keys (H3b1.1, H3b1.2)
- sets Mirage and starts the collectors, then runs each case through Surge (H3b1.3)
- the test traffic: the Studio ladder, the bursts and the backlog of uploads, the key race and the refused requests (H3b1.4–H3b1.8)
- writes the run record and the standard result, which board H judges (H3b1.9, H3b1.10)
- H3b1.1
lex-lab run runs row 3b.1 of the gate file: the suite gateway-3b1 on the target identity-studio, with the parameter set identity/instant. The module surge-load names the state of each part: the client and the scheduler are mock, the API is real, the workers are off and the providers are mock. The session must run identity_v2, api_gateway_v2, api_mgmt_v2, lab-mirage, lab-surge and lab-collect, the routes processing and local-webhooks on Mirage, and the release build of the three blocks. services/engine-rust/gates/lex-gate.toml:147–172; services/engine-rust/modules/surge-load/module.toml:26–30; services/engine-rust/targets/identity-studio.toml:8; services/engine-rust/targets/identity-studio.toml:12; services/engine-rust/targets/identity-studio.toml:13; services/engine-rust/targets/identity-studio.toml:14; services/engine-rust/targets/identity-studio.toml:18–21; services/engine-rust/crates/lab-executor/src/flows.rs:81; services/engine-rust/crates/lab-executor/src/align.rs:47
- H3b1.2The session provisions the test customers. For each one, lexsup runs the admin command of identity v2 for an organization and a root user, and the admin command of API gateway v2 for the API key with its rate and a verified webhook endpoint at Surge's receiver. The customers file gives Surge the keys, the sign-in fields and the signing secrets. tools/lexsup/internal/cli/provision.go:35; tools/lexsup/internal/cli/provision.go:58; tools/lexsup/internal/cli/provision.go:73; tools/lexsup/internal/cli/provision_identity.go:52; tools/lexsup/internal/cli/provision_identity.go:67; tools/lexsup/internal/cli/provision_v2.go:71
- H3b1.3The Executor sets Mirage's preset
instant, starts the collectors and the egress watch, and runs each case as lab-surge run. The capacity is session-steps, a ladder up to 3,000 actions a minute in 6 steps of 20 s. The floors are gateway-burst-10 and studio-burst-200 (bursts), gateway-waiting-20 (a backlog), race-key-idem-50 (a race) and malicious-gateway (refused requests). services/engine-rust/crates/lab-executor/src/runner.rs:172–180; services/engine-rust/crates/lab-executor/src/runner.rs:202; services/engine-rust/crates/lab-executor/src/runner.rs:411
- H3b1.4In
session-steps, each virtual user signs in once at identity v2 as a browser does, then 75% of its actions are Studio reads, Studio writes and calls of the public API, and the rest are refreshes at identity v2. As Studio v2 does, it reads and writes the session and the keys through the gateway, and the account and the organization at identity v2 itself (studio-api 2.0, ADR 083). services/engine-rust/crates/lab-surge-engine/src/session/flow.rs:166; services/engine-rust/crates/lab-surge-engine/src/session/flow.rs:243; services/engine-rust/crates/lab-surge-engine/src/session/flow.rs:308; services/engine-rust/crates/lab-surge-engine/src/session/flow.rs:472; services/engine-rust/crates/lab-surge-engine/src/session/action.rs:155; services/engine-rust/crates/lab-surge-engine/src/session/action.rs:177; services/engine-rust/crates/lab-surge-engine/src/session/action.rs:228; services/engine-rust/crates/lab-surge-engine/src/session/wire.rs:134
- H3b1.5Identity v2 publishes its key set on the stream
lexselect:v2:identity:keys (identity 2.0) at its start, at each change and each 5 minutes. The gateway follows the stream with no consumer group, keeps the newest set in memory and checks each access token against it with no call to identity v2, and a Studio route takes no API key. It answers each Studio route itself, the keys and the webhooks with the lock of an Idempotency-Key in its own Valkey, and sends no route to identity v2 (studio-api 2.0). Identity v2 answers the account and the organization to the browser of Studio v2, with CORS for the origins of its clients (identity-management 1.3). services/engine--go/gateway/internal/gateway/sessionauth.go:26; services/engine--go/gateway/internal/gateway/sessionauth.go:68; services/engine--go/gateway/internal/session/keys.go:14; services/engine--go/gateway/internal/session/keys.go:70; services/engine--go/kit/connector/identity/keyfeed/keyfeed.go:68; services/engine--go/kit/connector/identity/keyfeed/keyfeed.go:84; services/engine--go/identity/internal/keys/announce.go:85; services/engine--go/identity/internal/connector/valkey/keyset.go:30; services/engine--go/contract/studioapi/v2/operations.go:8; services/engine--go/identity/internal/mgmtapi/cors.go:28; services/engine--go/gateway/internal/routes/studiorest/idempotency.go:38
- H3b1.6The bursts and the backlog:
gateway-burst-10 sends 10 uploads by link at once, studio-burst-200 sends 200 Studio calls at once, and gateway-waiting-20 sends 20 uploads that Mirage holds, then releases at 10 s and at 20 s. Each upload goes the path of row 3a: the create, the PUT, the object event, the trigger, Mirage's run and the end event (H3a.6–H3a.14). services/engine-rust/crates/lab-surge-engine/src/client/link.rs:60; services/engine-rust/crates/lab-surge-engine/src/client/link.rs:116; services/engine-rust/crates/lab-mirage-proc/src/stream_triggers.rs:200; services/engine-rust/crates/lab-mirage-proc/src/stream_events.rs:44
- H3b1.7The race on the key sends many
POST /studio/keys with one Idempotency-Key at one instant, then lists the keys. The first request takes the lock in the gateway's own Valkey, and a later one gets the stored answer or 409, so one key exists. services/engine-rust/crates/lab-surge-engine/src/session/race.rs:165; services/engine-rust/crates/lab-surge-engine/src/session/race.rs:422; services/engine--go/gateway/internal/routes/studiorest/idempotency.go:38; services/engine--go/gateway/internal/connector/own/valkey/studio_idem.go:27
- H3b1.8The case
malicious-gateway sends the requests that attack the gateway: forged tokens, hostile path values, a large body and an API key on a Studio route. A 4xx answer other than 429 is a refusal, a 2xx answer is an unexpected accept, and the floor allows none and no 5xx. services/engine-rust/crates/lab-surge-engine/src/session/malicious.rs:38; services/engine-rust/crates/lab-surge-engine/src/session/malicious.rs:50; services/engine-rust/crates/lab-surge-engine/src/measure.rs:394; services/engine-rust/crates/lab-executor/src/verdict.rs:210
- H3b1.9The Executor writes the run record: Surge's report as
raw/lab-surge/report.json, the series of Surge and of the collectors, and the events. services/engine-rust/crates/lab-executor/src/runner.rs:243; services/engine-rust/crates/lab-executor/src/runner.rs:719; services/engine-rust/crates/lab-executor/src/runner.rs:727
- H3b1.10The adapter
surge-load makes the standard result of row 3b.1: the rate of the last healthy step of session-steps, where a step stays inside the shares of 5xx and 429, the latency and no unexpected accept. A floor that fails sets the score to 0. Board H takes the result from here (H.6, H.7). services/engine-rust/crates/lab-adapters/src/surge_load.rs:32; services/engine-rust/cases/session-steps.toml:21–27
H3b3 · identity v2arch-v1
Loads identity v2 by its contract: the sign-in, where a burst can exhaust a CPU, the rotation of refresh tokens, and the single-use values that must work one time under parallel load.
- checks the session against the target and provisions the users (H3b3.1, H3b3.2)
- sets Mirage and starts the collectors, then runs each case through Surge (H3b3.3)
- the test traffic: the refresh ladder, the bursts, the races on refresh tokens, codes and invitations, and the refused requests (H3b3.4–H3b3.8)
- judges each race, writes the run record and the standard result, which board H judges (H3b3.9, H3b3.10)
- H3b3.1
lex-lab run runs row 3b.3 of the gate file: the suite identity-3b3 on the target identity-studio with the parameter set identity/instant, on the session of row 3b.1. The module surge-load names the state of each part. services/engine-rust/gates/lex-gate.toml:180–204; services/engine-rust/modules/surge-load/module.toml:26–30; services/engine-rust/targets/identity-studio.toml:8; services/engine-rust/targets/identity-studio.toml:13; services/engine-rust/crates/lab-executor/src/flows.rs:81
- H3b3.2The session provisions the customers as in row 3b.1, and for each one a guest user in an organization of its own, which the race on the invitation needs. tools/lexsup/internal/cli/provision_identity.go:67; tools/lexsup/internal/cli/provision_identity.go:72; tools/lexsup/internal/cli/provision_identity.go:82
- H3b3.3The Executor sets Mirage's preset
instant, starts the collectors and the egress watch, and runs each case as lab-surge run. The capacity is refresh-steps, a ladder of refreshes. The floors are signin-burst-100 and refresh-storm-500 (bursts), race-refresh-50, race-invite-50 and race-code-50 (races), and malicious-identity (refused requests). services/engine-rust/crates/lab-executor/src/runner.rs:172–180; services/engine-rust/crates/lab-executor/src/runner.rs:202; services/engine-rust/crates/lab-executor/src/runner.rs:411
- H3b3.4Surge signs each virtual user in as the sign-in page does, with a cookie jar: the authorize request with PKCE S256, the CSRF token from
GET /session/v1/state, the JSON login with X-CSRF-Token, then the code exchange at /oauth/token. In refresh-steps it then refreshes its tokens at a rising rate. Identity v2 rotates the refresh token in its family, a reused refresh token revokes the family, and the codes and tokens stay in its own MongoDB database. services/engine-rust/crates/lab-surge-engine/src/session/flow.rs:166; services/engine-rust/crates/lab-surge-engine/src/session/flow.rs:204; services/engine-rust/crates/lab-surge-engine/src/session/flow.rs:243; services/engine-rust/crates/lab-surge-engine/src/session/flow.rs:308; services/engine-rust/crates/lab-surge-engine/src/session/flow.rs:344; services/engine-rust/crates/lab-surge-engine/src/session/pkce.rs:31; services/engine-rust/crates/lab-surge-engine/src/session/jar.rs:17; services/engine-rust/crates/lab-surge-engine/src/session/jar.rs:98; services/engine--go/identity/internal/provider/authorize.go:31; services/engine--go/identity/internal/web/signin.go:19; services/engine--go/identity/internal/web/signin.go:45; services/engine--go/identity/internal/web/signin.go:51; services/engine--go/identity/internal/provider/token.go:70; services/engine--go/identity/internal/provider/token.go:91; services/engine--go/identity/internal/provider/token.go:132; services/engine--go/identity/internal/config/config.go:134; services/engine--go/identity/cmd/identity-v2/ports.go:33; services/engine--go/identity/cmd/identity-v2/ports.go:52
- H3b3.5The bursts:
signin-burst-100 sends 100 sign-ins at the same moment, and refresh-storm-500 sends 500 refreshes of rotating tokens. Identity v2 limits the logins of an IP and of an address. services/engine--go/identity/internal/web/signin.go:51
- H3b3.6The races on the refresh token and on the code send one refresh token, or one authorization code, many times at one instant behind a barrier. Identity v2 takes the code with a find-and-delete and uses the refresh token with a conditional update, so one request wins. services/engine-rust/crates/lab-surge-engine/src/session/race.rs:165; services/engine-rust/crates/lab-surge-engine/src/session/race.rs:170; services/engine-rust/crates/lab-surge-engine/src/session/race.rs:203; services/engine-rust/crates/lab-surge-engine/src/session/race.rs:219; services/engine--go/identity/internal/connector/store/mongo/tokens.go:37; services/engine--go/identity/internal/connector/store/mongo/tokens.go:56; services/engine--go/identity/internal/connector/store/mongo/tokens.go:84
- H3b3.7The race on the invitation goes straight to identity v2, as Studio v2 does (ADR 074 D5): the root user invites the guest, Surge reads the token of the invitation at
/dev/mail, and many requests of the guest accept it. Identity v2 takes the invitation with a find-and-delete, so one accept wins. services/engine-rust/crates/lab-surge-engine/src/session/race.rs:299; services/engine-rust/crates/lab-surge-engine/src/session/race.rs:280; services/engine-rust/crates/lab-surge-engine/src/session/race.rs:350; services/engine--go/identity/internal/mgmtapi/mgmtapi.go:231; services/engine--go/identity/internal/orgs/invitations.go:57; services/engine--go/identity/internal/connector/store/mongo/orgs.go:112
- H3b3.8The case
malicious-identity sends the requests that attack identity v2: a login with no CSRF token, a wrong PKCE verifier and an unknown client. A 4xx answer other than 429 is a refusal, a 2xx answer is an unexpected accept, and the floor allows none and no 5xx. services/engine-rust/crates/lab-surge-engine/src/session/malicious.rs:38; services/engine-rust/crates/lab-surge-engine/src/session/malicious.rs:50; services/engine-rust/crates/lab-surge-engine/src/measure.rs:394; services/engine-rust/crates/lab-executor/src/verdict.rs:210
- H3b3.9Surge judges each race: a count of winners other than one is a race violation, and each race floor allows none. The Executor writes the run record: Surge's report as
raw/lab-surge/report.json, the series and the events. services/engine-rust/crates/lab-surge-engine/src/session/race.rs:77; services/engine-rust/crates/lab-surge-engine/src/session/race.rs:157; services/engine-rust/crates/lab-surge-engine/src/measure.rs:386; services/engine-rust/crates/lab-executor/src/verdict.rs:219; services/engine-rust/crates/lab-executor/src/runner.rs:243; services/engine-rust/crates/lab-executor/src/runner.rs:727
- H3b3.10The adapter
surge-load makes the standard result of row 3b.3: the rate of the last healthy step of refresh-steps. A floor that fails sets the score to 0. Board H takes the result from here (H.6, H.7). services/engine-rust/crates/lab-adapters/src/surge_load.rs:32
H3b4 · Scheduler v2arch-v1
Measures the throughput of the scheduler by itself: each side answers at once, so a fall of the measure points at the scheduler.
- starts the stores and the release build of the scheduler (H3b4.1)
- the test traffic: the triggers in, the tasks out, the results back and the final message (H3b4.2–H3b4.5)
- records the rates and the delays (H3b4.6)
- H3b4.1A run starts RabbitMQ, Valkey and MongoDB, then the release build of the scheduler, with 1, 2 or 4 instances, and sets the admission and capacity limits high. The record of the scenario names the state of each part: the scheduler and its stores are real, the API and the workers are mock, the outside providers and OpenSearch are off. docs/lex-gate/scenarios/3b4-scheduler-v2.md:60–67; docs/lex-gate/scenarios/3b4-scheduler-v2.md:89–91; docs/lex-gate/scenarios/3b4-scheduler-v2.md:108
- H3b4.2The upstream harness writes the document rows to MongoDB, because the scheduler drops a trigger whose document is absent. Then it publishes the triggers to the queue
scheduler_v2:triggers. docs/lex-gate/scenarios/3b4-scheduler-v2.md:62; docs/lex-gate/scenarios/3b4-scheduler-v2.md:73; docs/lex-gate/scenarios/3b4-scheduler-v2.md:92; docs/lex-gate/scenarios/3b4-scheduler-v2.md:123–124
- H3b4.3The scheduler takes each trigger and dispatches the tasks of its task graph to the streams
lexselect:scheduler_v2:tasks:{v2q}:<task>, in the group of the workers. docs/lex-gate/scenarios/3b4-scheduler-v2.md:71–76; docs/lex-gate/scenarios/3b4-scheduler-v2.md:79–80
- H3b4.4The downstream harness takes each task from its stream and writes its result at once, with a completion event on
lexselect:scheduler_v2:results. docs/lex-gate/scenarios/3b4-scheduler-v2.md:65; docs/lex-gate/scenarios/3b4-scheduler-v2.md:76; docs/lex-gate/scenarios/3b4-scheduler-v2.md:93; docs/lex-gate/scenarios/3b4-scheduler-v2.md:144–145
- H3b4.5After the last task, the scheduler sets the processing to SUCCESS in MongoDB and dispatches each success handler task. The downstream harness takes that task: it is the final message, and the processing ends there. docs/lex-gate/scenarios/3b4-scheduler-v2.md:77; docs/lex-gate/scenarios/3b4-scheduler-v2.md:82–85; docs/lex-gate/scenarios/3b4-scheduler-v2.md:94
- H3b4.6The run records the completions that the scheduler handles in a second, the delay from a completion to the next dispatch, the processings that end in a second and the most documents in flight with no failure, each with 1, 2 and 4 instances. The record needs a case and a payload kind of its own, still to build. docs/lex-gate/scenarios/3b4-scheduler-v2.md:95; docs/lex-gate/scenarios/3b4-scheduler-v2.md:102–108; docs/lex-gate/scenarios/3b4-scheduler-v2.md:150–151
H3b5 · Accounting v2arch-v1
Proves that no account goes above what it can pay under parallel load, and measures how long the block takes to answer a hold, to write the ledger and to close an hour.
- starts the block alone with Mirage and the harness (H3b5.1)
- the races: identical requests on one fact of money through the contracts, Mirage's parts and the stores (H3b5.2–H3b5.5)
- the lag: start and end events at a steady rate that grows in steps (H3b5.6)
- records the races, the invariants and the three times (H3b5.7)
- H3b5.1A run starts a lexsup session with three parts: the block
accounting-v2 in its release build, Mirage with its accounting parts, and the harness. The record names the state of each part: the block and its stores are real; the harness, processing, Stripe, AWS Marketplace, API management v2 and identity v2 are mock. docs/lex-gate/scenarios/3b5-accounting-v2.md:30–38; docs/lex-gate/scenarios/3b5-accounting-v2.md:82–83
- H3b5.2The races: the harness opens one fact of money and fires identical requests on it at the same instant: 50 start events for the last pages of one account, 50 credits of one top-up, 50 deliveries of one Stripe event, or 50 sends of one closed Marketplace hour. It plays API management v2 and identity v2: it reads
account-state and writes identity-events. docs/lex-gate/scenarios/3b5-accounting-v2.md:32; docs/lex-gate/scenarios/3b5-accounting-v2.md:38; docs/lex-gate/scenarios/3b5-accounting-v2.md:42–52
- H3b5.3The block works with Mirage's parts: processing sends the start and end events and waits for the hold, Stripe's worker sends the webhooks, and AWS Marketplace takes
BatchMeterUsage. docs/lex-gate/scenarios/3b5-accounting-v2.md:35–37
- H3b5.4The block keeps the holds, the journal and the hours in its own MongoDB and Valkey, and the stores decide who wins. docs/lex-gate/scenarios/3b5-accounting-v2.md:33–34
- H3b5.5A race violation is a page over the balance, a second booking of one idempotency key, or a count of winners other than one. After each case the money invariants of module 2b.5 hold: the journal sums to zero, and each idempotency key has one booking. docs/lex-gate/scenarios/3b5-accounting-v2.md:42–44; docs/lex-gate/scenarios/3b5-accounting-v2.md:54–55
- H3b5.6The lag: the harness sends start and end events at a steady rate, one rate in each step of a load that grows. The block answers each start event on
run-hold, writes the usage event of each end to its ledger and closes each hour after its lag, with Mirage's Stripe and Marketplace parts on the preset instant. docs/lex-gate/scenarios/3b5-accounting-v2.md:58–63; docs/lex-gate/scenarios/3b5-accounting-v2.md:67–69
- H3b5.7The run records the races, with the measure case run 3 times and each race floor once, and the money invariants. It records the lag too: the hold answer at p99 (200 ms or less), the time from an end to its usage event at p99 (2 s or less), the delay of an hour close (60 s or less), and the rate of the last step in which each time meets its target. A release takes the lag from the reference runner. The suite files, the row of the gate file and its expectation file are still to build. docs/lex-gate/scenarios/3b5-accounting-v2.md:48; docs/lex-gate/scenarios/3b5-accounting-v2.md:54; docs/lex-gate/scenarios/3b5-accounting-v2.md:65–70; docs/lex-gate/scenarios/3b5-accounting-v2.md:74–78; docs/lex-gate/scenarios/3b5-accounting-v2.md:89–90
H3c · Complete flowarch-v1
Gives the number that a client asks for: how many pages the whole product processes in a second, with the real providers.
- takes the owner's go-ahead for the paid calls and readies the environment (H3c.1)
- the test traffic: Surge's documents, the trigger, the tasks, the paid calls and the webhooks (H3c.2–H3c.6)
- records the page rate, the turnaround, the failures and the cost, outside the score (H3c.7)
- H3c.1A run needs the owner's go-ahead for the paid calls, with a budget of requests and of cost. Then it deploys the version to the environment of the run and sets each provider to its real route. The record names the state of each part: the clients are mock, everything else is real, also the providers. The Executor needs a mode for real routes with a budget, still to build. docs/lex-gate/scenarios/3c-complete-flow.md:57–61; docs/lex-gate/scenarios/3c-complete-flow.md:65–67; docs/lex-gate/scenarios/3c-complete-flow.md:152–153
- H3c.2The Executor starts Lex Lab Surge with the load and the document mix of the run, and raises the documents in flight in steps until the page rate stops its increase. docs/lex-gate/scenarios/3c-complete-flow.md:68–69
- H3c.3Surge uploads the documents to the public API and reads them. The API keeps them in its stores and sends the trigger to the scheduler. docs/lex-gate/scenarios/3c-complete-flow.md:32–37; docs/lex-gate/scenarios/3c-complete-flow.md:55
- H3c.4The scheduler dispatches the tasks to the workers and reads their results. docs/lex-gate/scenarios/3c-complete-flow.md:40–45
- H3c.5The workers call the real providers: OCR, ml_pp and the LLMs. Each call is paid, and the speed and the rate limits of the providers are part of the result. docs/lex-gate/scenarios/3c-complete-flow.md:47–52; docs/lex-gate/scenarios/3c-complete-flow.md:61
- H3c.6The API sends the webhook of each processed document to Surge, which measures the pages in a second. docs/lex-gate/scenarios/3c-complete-flow.md:29–32; docs/lex-gate/scenarios/3c-complete-flow.md:84–86
- H3c.7The run records the processed pages in a second, the turnaround of a document at p50, p95 and p99, the failed documents (0 at the reported rate) and the cost for 1,000 pages. The result stays out of the score, with a place of its own on the comparison page, still to build. docs/lex-gate/scenarios/3c-complete-flow.md:13; docs/lex-gate/scenarios/3c-complete-flow.md:70; docs/lex-gate/scenarios/3c-complete-flow.md:75–80; docs/lex-gate/scenarios/3c-complete-flow.md:154
E · Billingarch-v1
arch-v1 charges its own customers. It sells pages two ways: a prepaid PAYG wallet at $0.03 a page after 10,000 free pages, and enterprise subscriptions with overage. v2 bills its tenants in its own block, accounting-v2, in the zones of v2 on this board, with no link to this billing (ADR 075).
- starts a wallet top-up in the developer portal and turns it into a Stripe Checkout session (E.1–E.5)
- credits the wallet when the Stripe webhook arrives (E.6–E.11)
- reserves pages, tops up on a shortfall, and charges or releases them in worker-main (E.12–E.14)
- lets our staff adjust, freeze and grant a wallet, and provisions an enterprise subscription (E.15–E.17)
- turns the Stripe subscription and invoice webhooks into entitlements, and reports enterprise overage each minute (E.18–E.21)
- sends the billing emails through Mailjet (E.22)
- E.1A user opens the Billing tab of the developer portal and asks for a top-up. The portal calls
funding.create of its wallet module with the amount and a retry key, on the /portal socket namespace. services/developer-portal/src/features/billing/module.ts:52; services/developer-portal/src/features/billing/module.ts:87–98
- E.2event-bridge allows
wallet.funding.create.v3 (1,000 to 1,000,000 cents, 10 requests in 5 minutes) and publishes it to the topic exchange orchestrator with the routing key wallet.funding.create.v3.request. The headers carry the user id and the socket id. services/event-bridge/src/portal/registry.ts:447–457; services/event-bridge/src/portal/index.ts:33–44; services/event-bridge/src/sockets/utils.ts:57; services/event-bridge/src/rabbitMQ/publisher.ts:49; services/event-bridge/src/rabbitMQ/publisher.ts:64
- E.3The orchestrator takes the message from the queue
orchestrator-v3. The handler is a BillingEvent: it checks the input and calls the worker-api task. services/engine/microservices/orchestrator/core/orchestrator_v3.py:351; services/engine/microservices/orchestrator/core/orchestrator_v3.py:359; services/engine/microservices/orchestrator/controllers/wallet/funding.py:12–19; services/engine/microservices/orchestrator/controllers/billing/__init__.py:14–25
- E.4
task_wallet_funding_create_v3 checks that PAYG is on and the account is personal, then creates the funding order. services/engine/microservices/worker_api/tasks_v2/wallet/funding.py:73–100
- E.5worker-api stores the order in
wallet_funding_orders and creates a Stripe Checkout session with the idempotency key payg:{order}:checkout. The user pays on the Stripe page. services/engine/shared/services/wallet_funding.py:150; services/engine/shared/services/wallet_funding.py:168; services/engine/shared/services/wallet_funding.py:194; services/engine/shared/entities/payment.py:1007; services/engine/shared/entities/payment.py:1061; services/engine/shared/entities/wallet_funding_orders.py:15
- E.6Stripe posts the event to
POST /v1/stripe of web-hooks-service. The controller checks the stripe-signature header against the webhook secret and answers 400 if it fails. services/web-hooks-service/src/router.ts:57; services/web-hooks-service/src/sources/stripe/router.ts:13; services/web-hooks-service/src/sources/stripe/controller.ts:48–58
- E.7web-hooks-service calls the queue
stripe-webhooks-v1 as an RPC, with a reply and a timeout of 30 s, and the routing key webhooks.stripe.wallet.event.v2.request for a wallet event. A failure or a timeout gives Stripe a 500, so Stripe retries. services/web-hooks-service/src/sources/stripe/controller.ts:99–104; services/web-hooks-service/src/sources/stripe/enum.ts:21; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:122; services/web-hooks-service/src/destinations/rabbitMQ/rpcClient.ts:142
- E.8The orchestrator consumes
stripe-webhooks-v1. The wallet handler calls the worker-api task stripe_wallet_event and waits for it. services/engine/microservices/orchestrator/core/orchestrator_stripe_v1.py:38; services/engine/microservices/orchestrator/core/orchestrator_stripe_v1.py:40–49; services/engine/microservices/orchestrator/controllers/webhooks_stripe/wallet_events_v2.py:45–55
- E.9The task
stripe_wallet_event calls process_wallet_event. The subscription and invoice events of enterprise workspaces take the same road to their own tasks (E.18). services/engine/microservices/worker_api/tasks_v2/webhooks_stripe/wallet_events.py:8–22
- E.10worker-api reads the object again from Stripe and does not trust the event body alone. services/engine/shared/services/wallet_reconciliation.py:339; services/engine/shared/services/wallet_reconciliation.py:377
- E.11The event goes to
wallet_stripe_events, then reconcile_funding_order credits the wallet: credit_wallet adds to payg_wallets and inserts a row into payg_transactions. A repair loop runs the reconciliation every 60 s. services/engine/shared/services/wallet_reconciliation.py:343–374; services/engine/shared/services/wallet_reconciliation.py:436; services/engine/shared/services/wallet_reconciliation.py:489; services/engine/shared/services/wallet_funding.py:340; services/engine/shared/services/wallet_funding.py:405; services/engine/shared/services/payg_accounting.py:570; services/engine/shared/services/payg_accounting.py:576; services/engine/shared/entities/payg_wallets.py:13; services/engine/shared/entities/payg_transactions.py:12
- E.12A document of an API key starts:
get_pages books its pages. For a personal account reserve_pages takes the free pages first, then cents, and writes payg_reservations. services/engine/microservices/worker_main/scheduler_v2_tasks/task_get_pages.py:393; services/engine/microservices/worker_main/scheduler_v2_tasks/task_get_pages.py:483; services/engine/microservices/worker_main/scheduler_v2_tasks/task_get_pages.py:517; services/engine/microservices/worker_main/scheduler_v2_tasks/task_get_pages.py:791; services/engine/shared/services/payg_accounting.py:277; services/engine/shared/services/payg_accounting.py:353; services/engine/shared/entities/payg_reservations.py:12
- E.13If the balance is short, worker-main asks for an automatic top-up: it creates, finalizes and pays a Stripe invoice off session, then reserves again. If the order is not credited, it raises
PaygAdmissionUnavailable. services/engine/microservices/worker_main/scheduler_v2_tasks/task_get_pages.py:795–826; services/engine/shared/services/wallet_auto_topup.py:457; services/engine/shared/services/wallet_auto_topup.py:778; services/engine/shared/services/wallet_auto_topup.py:841; services/engine/shared/entities/payment.py:1138; services/engine/shared/entities/payment.py:1178; services/engine/shared/entities/payment.py:1204
- E.14When the run ends,
consume_reservation moves the reserved amount to used and inserts the row payg:processing:{id} into payg_transactions. When the run fails or is canceled, release_reservation returns the hold. services/engine/microservices/worker_main/scheduler_v2_tasks/task_finalize_page_quota.py:48; services/engine/microservices/worker_main/scheduler_v2_tasks/task_finalize_page_quota.py:62; services/engine/shared/services/payg_accounting.py:456; services/engine/shared/services/payg_accounting.py:461; services/engine/microservices/worker_main/scheduler_v2_tasks/task_release_page_quota.py:65–66
- E.15In the admin panel our staff adjust a wallet, freeze it or set the free page allowance. The panel sends the request over its socket to event-bridge, and the request takes the road of E.2 to E.4 to the worker-api task. services/admin/src/eventBridge/modules.ts:121; services/admin/src/modules/customers/useWalletAdjustment.ts:87; services/engine/microservices/orchestrator/controllers/admin_wallet/adjust.py:8–15
- E.16
task_admin_wallet_adjust_v3 and its two siblings call adjust_wallet, set_wallet_freeze and set_free_allowance, with the operator from the socket principal. Each correction is a unique financial effect. services/engine/microservices/worker_api/tasks_v2/admin_wallet/adjust.py:15; services/engine/shared/services/payg_accounting.py:598; services/engine/shared/services/payg_accounting.py:615; services/engine/shared/services/payg_accounting.py:641
- E.17For an enterprise workspace, the admin create and update tasks of worker-api call
provision_enterprise_billing, which creates or changes the Stripe subscription. services/engine/microservices/worker_api/tasks_v2/admin_workspace/create.py:290; services/engine/microservices/worker_api/tasks_v2/admin_workspace/update.py:405; services/engine/shared/services/enterprise_provisioning.py:248; services/engine/shared/services/enterprise_provisioning.py:310; services/engine/shared/entities/payment.py:290; services/engine/shared/entities/payment.py:351; services/engine/shared/entities/payment.py:356
- E.18The Stripe events
customer.subscription.* and invoice.* reach the orchestrator on the road of E.6 to E.8. The orchestrator hands them to the tasks stripe_subscription_created, updated and deleted, stripe_invoice_lifecycle and stripe_invoice_payment_failed. services/engine/microservices/orchestrator/controllers/webhooks_stripe/subscription_created_v2.py:281; services/engine/microservices/orchestrator/controllers/webhooks_stripe/invoice_lifecycle_v2.py:36; services/engine/microservices/worker_api/tasks_v2/webhooks_stripe/subscription_created.py:17; services/engine/microservices/worker_api/tasks_v2/webhooks_stripe/invoice_lifecycle.py:314; services/engine/microservices/worker_api/tasks_v2/webhooks_stripe/invoice_payment_failed.py:17
- E.19The workspace handlers write the subscription fields to
billing_entitlements, and the invoice lifecycle updates the invoice state. services/engine/microservices/worker_api/tasks_v2/webhooks_stripe/workspace_events.py:192; services/engine/microservices/worker_api/tasks_v2/webhooks_stripe/workspace_events.py:239; services/engine/microservices/worker_api/tasks_v2/webhooks_stripe/workspace_events.py:299; services/engine/microservices/worker_api/tasks_v2/webhooks_stripe/invoice_lifecycle.py:153; services/engine/shared/entities/billing_entitlements.py:113
- E.20An account with a workspace admits its pages against the entitlement. At the end of a run
_finalize_enterprise_usage writes api_usage_ledger and the snapshot of billing_usage_periods. services/engine/microservices/worker_main/scheduler_v2_tasks/task_get_pages.py:487–498; services/engine/microservices/worker_main/scheduler_v2_tasks/task_get_pages.py:672; services/engine/microservices/worker_main/scheduler_v2_tasks/task_finalize_page_quota.py:124; services/engine/microservices/worker_main/scheduler_v2_tasks/task_finalize_page_quota.py:239; services/engine/microservices/worker_main/scheduler_v2_tasks/task_finalize_page_quota.py:360; services/engine/shared/entities/api_usage_ledger.py:43; services/engine/shared/entities/billing_usage_periods.py:22
- E.21Every 60 s the usage reporter of worker-api reads the periods, queues the report in
stripe_usage_reports and sends the cumulative overage to Stripe as a usage record on the subscription item. services/engine/shared/services/stripe_usage_reporting.py:318; services/engine/shared/services/stripe_usage_reporting.py:344; services/engine/shared/services/stripe_usage_reporting.py:396; services/engine/shared/services/stripe_usage_reporting.py:525; services/engine/shared/entities/payment.py:916; services/engine/shared/entities/payment.py:933; services/engine/microservices/worker_api/entrypoint.py:597–600; services/engine/shared/entities/stripe_usage_reports.py:55
- E.22worker-api sends the billing emails through Mailjet: the limit notice of an enterprise workspace, checked every 30 s, and the inactivity reminder of a wallet. services/engine/shared/services/billing_notifications.py:38; services/engine/shared/services/billing_notifications.py:63; services/engine/shared/services/billing_notifications.py:223; services/engine/shared/services/billing_notifications.py:323; services/engine/shared/entities/mail.py:57; services/engine/microservices/worker_api/entrypoint.py:603–605
E · Billingarch-v2-aws
v2 bills its tenants in one block of its own, accounting-v2, on each target and with no link to arch-v1 (ADR 075). Each run holds its pages before its work, so no account goes above what it can pay. The block decides the answer of each key, and API gateway v2 writes it.
- admits a request by the key record, and opens a billing account for each new organization (NE.1, NE.2)
- holds the pages of a run at its start request, answers on run-hold, and settles or releases at its end event (NE.3–NE.5)
- meters each run into the usage ledger and sends the standing and the usage record to API gateway v2, which writes them (NE.6–NE.8)
- takes payments, webhooks and overage through the Stripe account of v2, and serves billing-api to Studio v2 and the admin panel (NE.9–NE.12)
- registers a Marketplace buyer, takes the entitlement events and sends the closed hours each hour (NE.13–NE.18)
- bills a customer's own install through a signed licence (NE.19–NE.22)
- NE.1API gateway v2 admits a request by the key record alone: yes, or no with a reason. A key of an account that cannot pay for one page gets a refusal. No request of an API client waits on the accounting block. M1 docs/adr/ADR_075_accounting_block.md:83–96; docs/lex-arch-v2/31-accounting-block.md:187–190; docs/lex-arch-v2/31-accounting-block.md:191–193
- NE.2Identity v2 announces a new organization on
identity-events. The accounting block reads it with its own group and opens a billing account. M1 docs/lex-arch-v2/31-accounting-block.md:283–285; docs/lex-arch-v2/31-accounting-block.md:125
- NE.3Processing counts the pages of a run and sends a start request with the page count on
run-hold. M1 docs/adr/ADR_075_accounting_block.md:83–96; docs/lex-arch-v2/31-accounting-block.md:194–196; docs/lex-arch-v2/31-accounting-block.md:120
- NE.4The module
holds checks the balance, the entitlement, the budgets and the document page limit in one transaction, holds the pages and answers on run-hold: held, or refused with a code. The run waits for the answer. A refused hold stops the run before its work, and a timeout fails it closed. M1 docs/adr/ADR_075_accounting_block.md:83–96; docs/lex-arch-v2/31-accounting-block.md:194–196; docs/lex-arch-v2/31-accounting-block.md:197–199; docs/lex-arch-v2/31-accounting-block.md:120
- NE.5The end event of a completed run settles the hold, and the end event of a failed run releases it (
processing-events, the group accounting-v2). The journal records each movement as two entries that sum to zero. The repair loop releases a stale hold. M1 docs/lex-arch-v2/31-accounting-block.md:202–204; docs/lex-arch-v2/31-accounting-block.md:205–206; docs/lex-arch-v2/31-accounting-block.md:168–170; docs/lex-arch-v2/31-accounting-block.md:124
- NE.6The meter writes one usage event for each run into the usage ledger, with a sequence number and a hash chain for each tenant. An hour closes a fixed lag after its end and never changes: a late event goes into the first open hour (usage 1.4). The meter of today runs in API management v2 and moves into the block. M1 docs/adr/ADR_075_accounting_block.md:35–42; docs/lex-arch-v2/31-accounting-block.md:177–179; docs/lex-arch-v2/31-accounting-block.md:119; services/engine--go/mgmt/internal/usage/meter.go:60–96; contracts/usage/v1/types.go:17; contracts/usage/v1/types.go:29
- NE.7The module
standing sends the standing and the limits of each owner and key, and the usage record of each owner, on account-state. API gateway v2 is the party that reads it (ADR 077 D15). M1 docs/adr/ADR_077_v2_routes_and_data.md:142–144; docs/lex-arch-v2/31-accounting-block.md:187–190; docs/lex-arch-v2/31-accounting-block.md:191–193; docs/lex-arch-v2/31-accounting-block.md:266–268; docs/lex-arch-v2/31-accounting-block.md:121
- NE.8API gateway v2 writes the standing and the limits on each key record of the owner, and the usage record that
GET /usage answers from. Each write is a compare-and-set on the revision of the record (B.18), and the sync of the gateway keeps the copy in Valkey true (B.19). A request of an API client waits for none of this. M1 docs/adr/ADR_077_v2_routes_and_data.md:142–144; docs/adr/ADR_077_v2_routes_and_data.md:75–89; docs/lex-arch-v2/31-accounting-block.md:191–193; docs/lex-arch-v2/31-accounting-block.md:266–268
- NE.9A tenant tops up a wallet through Stripe Checkout, saves a card, sets an auto top-up, or subscribes to a plan or a product. The payer takes the payment in the Stripe account of v2, and the journal credits the wallet. M1 docs/adr/ADR_075_accounting_block.md:98–104; docs/lex-arch-v2/31-accounting-block.md:215–216; docs/lex-arch-v2/31-accounting-block.md:217–220
- NE.10Stripe sends each event of the account of v2 with a signature to the receiver of the block. The receiver checks the signature, writes the event to a durable inbox, reads the object again from Stripe and applies it. M1 docs/lex-arch-v2/31-accounting-block.md:226–228
- NE.11For the overage of an Enterprise account, the payer sends one meter event for each run to Stripe Billing Meters, with the id of the usage event as its identifier. A graduated price gives the included pages at $0. M1 docs/lex-arch-v2/31-accounting-block.md:223–225; docs/lex-arch-v2/31-accounting-block.md:171–173
- NE.12A tenant in Studio v2 calls the billing routes of
studio-api on API gateway v2, which sends them on to billing-api. Until then the gateway answers them with fixed answers (ADR 074 D11). Our staff in the admin panel call billing-api. The routes cover the wallet, the funding orders, the cards, the periods, the portal, the usage, and the admin routes with their audit rows. M1 docs/lex-arch-v2/31-accounting-block.md:272–278; docs/lex-arch-v2/31-accounting-block.md:279–282; docs/lex-arch-v2/31-accounting-block.md:123
- NE.13A Marketplace buyer lands on our registration page with a token. The Marketplace payer calls
ResolveCustomer and gets CustomerAWSAccountId and LicenseArn. M1 docs/adr/ADR_075_accounting_block.md:98–104; docs/lex-arch-v2/31-accounting-block.md:236–250
- NE.14The Marketplace payer asks API gateway v2 for the tenant
mp:{CustomerAWSAccountId} and its first key on tenant-provisioning. The page of the registration shows the key one time. M1 docs/adr/ADR_077_v2_routes_and_data.md:142–144; docs/lex-arch-v2/31-accounting-block.md:243–244; docs/lex-arch-v2/31-accounting-block.md:122
- NE.15AWS sends the entitlement events
aws.agreement-marketplace through EventBridge, filtered by the product id. The payer turns them into the standing: yes, or no with SUBSCRIPTION_INACTIVE. M1 docs/lex-arch-v2/31-accounting-block.md:245–246
- NE.16The ledger hands the closed hours of each Marketplace tenant to the payer in our seller account. Until the meter moves into the block, the meter in API management v2 sends each hour 1 h after its end, in order of hour, on the stream
lexselect:v2:usage:totals (on AWS the SQS FIFO queue usage-in.fifo), and the function usagein checks the hash chain and stores it (usage 1.3). In a local env, lexsup runs the reader of the stream as the app marketplace_metering, which keeps the records and the chain heads in a Mongo database of its own (T-47). M1 docs/lex-arch-v2/31-accounting-block.md:240–241; services/engine--go/mgmt/internal/usage/totals.go:76; services/engine--go/mgmt/internal/usage/totals.go:98; contracts/usage/v1/CONNECTOR.md:44; contracts/usage/v1/CONNECTOR.md:58; contracts/usage/v1/CONNECTOR.md:63; tools/lexsup/internal/catalog/catalog.go:172; tools/lexsup/internal/envx/v2stores.go:37; tools/lexsup/internal/envx/v2stores.go:38
- NE.17Each hour, the payer sends
BatchMeterUsage to AWS with the dimension pages, 25 records in a call. A closed hour never changes, so each record is final. M1 docs/lex-arch-v2/31-accounting-block.md:236–250; docs/lex-arch-v2/31-accounting-block.md:177–179
- NE.18Each day, the payer compares the hours that it sent with the seller data feeds of AWS. AWS sends the bill to the buyer and pays us. M1 docs/lex-arch-v2/31-accounting-block.md:236–250; docs/lex-arch-v2/29-billing.md:48–51
E · Billingarch-v2-self
v2 bills its tenants in one block of its own, accounting-v2, on each target and with no link to arch-v1 (ADR 075). Each run holds its pages before its work, so no account goes above what it can pay. The block decides the answer of each key, and API gateway v2 writes it.
- bills a customer's own install through a signed licence (NE.19–NE.22)
- NE.19An offline install of a customer exports a signed usage file from its ledger each month, and the customer sends it to us. M1 docs/lex-arch-v2/29-billing.md:62–64; docs/lex-arch-v2/29-billing.md:264–265; docs/lex-arch-v2/31-accounting-block.md:254–258
- NE.20An online install of a customer sends the signed hourly totals of its ledger to our licence service each day. A gap, a lower sequence number or a second instance with the same id raises an alarm. M1 docs/lex-arch-v2/29-billing.md:59–61; docs/lex-arch-v2/29-billing.md:74–77; docs/lex-arch-v2/31-accounting-block.md:254–258
- NE.21The licence service answers with a fresh licence with a short lifetime: the customer, the page capacity, the validity window and the instance id. At expiry a grace period follows, then the install refuses new runs and the results stay readable. M1 docs/lex-arch-v2/29-billing.md:54–58; docs/lex-arch-v2/29-billing.md:59–61; docs/lex-arch-v2/29-billing.md:65–66; docs/lex-arch-v2/31-accounting-block.md:254–258
- NE.22A key in AWS KMS signs each licence with Ed25519, through a reviewed step that leaves an audit record. The binary holds the public key. M1 docs/lex-arch-v2/29-billing.md:72–73; docs/lex-arch-v2/29-billing.md:54–58; docs/lex-arch-v2/29-billing.md:78–80
G · Providers and platformarch-v1
arch-v1 calls many outside providers and uses many AWS services. This board names each one with the box that calls it and the line of the call, so a change of a provider or of the platform finds its callers.
- sends page images to OCR and ML providers and prompts to LLM providers (G.1–G.6)
- uses business services for payments, email, CRM, analytics, sign-in, alerts, error reports and the bot check (G.7–G.15, G.27)
- runs on AWS services for images, secrets, logs, egress, encryption, delivery, certificates, email intake, the overnight shutdown and backup (G.16–G.26)
- G.1worker-main sends each page image to Google Vision, the first OCR provider, with an API key. services/engine/shared/connectors/google_vision_ocr.py:48; services/engine/shared/connectors/google_vision_ocr.py:560; services/engine/shared/config.py:163–166
- G.2If Vision keeps throttling a page past the retry budget, worker-main sends it to Textract and posts an alert to Slack. services/engine/shared/connectors/textract_ocr.py:377; services/engine/shared/connectors/textract_ocr.py:408; services/engine/shared/config.py:148; services/engine/shared/providers/ocr_factory.py:135; services/engine/shared/providers/ocr_fallback_alert.py:58
- G.3worker-main posts page images to ml_pp for layout, tables, styling, key-values, handwriting and local OCR. In a QA environment it posts them to the ml_pp balancer, which sends them to server1 and, as backup, to Cloud Run; production's worker-main calls Cloud Run directly. services/engine/shared/connectors/ml_vision_web.py:121; services/engine/shared/connectors/local_ocr.py:190; services/engine/shared/config.py:976; services/ml_pp_balancer/haproxy.cfg:155; services/ml_pp_balancer/haproxy.cfg:159
- G.4worker-main sends vision and chat calls to OpenRouter through an OpenAI-compatible client. services/engine/shared/providers/llm_openai_compatible.py:100–102; services/engine/shared/providers/vlm.py:469
- G.5worker-main sends chat calls and embeddings to OpenAI. services/engine/shared/providers/llm_openai.py:42; services/engine/shared/providers/openai_embeddings.py:7
- G.6worker-main sends calls to Gemini. The default transport is Vertex AI, with a service account of the Google Cloud project. services/engine/shared/providers/gemini_transport.py:19; services/engine/shared/providers/gemini_transport.py:29; services/engine/shared/providers/llm_google.py:54; iac/gcp-vertex.tf:56
- G.7worker-api calls Stripe for the customers, the Checkout sessions, the portal and the subscriptions. Board F shows the money flow. services/engine/shared/connectors/stripe.py:21–22; services/engine/shared/entities/payment.py:37; services/engine/shared/entities/payment.py:177; services/engine/shared/entities/payment.py:193
- G.8Stripe posts its webhooks to web-hooks-service at
/v1/stripe. services/web-hooks-service/src/router.ts:57; services/web-hooks-service/src/sources/stripe/controller.ts:50; iac/waf.tf:43
- G.9worker-api sends the billing and account emails through Mailjet. services/engine/shared/providers/mailjet.py:25; services/engine/shared/entities/mail.py:57
- G.10worker-api syncs contacts to the HubSpot CRM and submits the contact form of the landing site to HubSpot Forms. services/engine/shared/connectors/hubspot.py:23; services/engine/shared/providers/hubspot_forms.py:65; services/engine/shared/providers/hubspot_forms.py:155
- G.11worker-api sends Studio events to PostHog in batches, and the web application and Lex Studio send their own events from the browser. services/engine/shared/connectors/posthog.py:35; services/engine/shared/connectors/posthog.py:93; services/app/src/libs/postHog/index.ts:24; services/developer-portal/src/core/analytics/posthog.ts:55
- G.12The frontends sign users in with Auth0, worker-api calls its management API, and event-bridge checks each token against the keys of the tenant. services/engine/shared/connectors/auth0.py:69–72; services/event-bridge/src/utils/verifyJwt.ts:23–25; services/app/src/components/organisms/Auth0Wrapper/index.tsx:22–23; services/admin/src/auth/Auth0AdminAuth.tsx:45; services/developer-portal/src/App.tsx:26
- G.13worker-main and worker-api post alerts to Slack through incoming webhooks. services/engine/shared/providers/slack.py:20; services/engine/shared/entities/slack.py:11; services/engine/shared/providers/ocr_fallback_alert.py:58
- G.14The workers and the web application send error reports to Sentry when
SENTRY_ENABLED is true. services/engine/shared/connectors/sentry.py:191; services/app/src/libs/sentry/index.ts:28
- G.15web-hooks-service checks the token of the landing contact form against the Turnstile siteverify endpoint. services/web-hooks-service/src/sources/landing-contact/turnstile.ts:65; services/web-hooks-service/src/sources/landing-contact/controller.ts:159
- G.16ECS pulls the image of each task from the one ECR repository. iac/aws-ecs.tf:594; iac/aws-ecs.tf:21
- G.17ECS reads the secret of the deployment from Secrets Manager and puts its sections into the environment of each task. iac/main.tf:32; iac/aws-ecs.tf:195–199
- G.18Each task writes its log to a CloudWatch log group, and an alarm watches the CPU of the service. iac/aws-ecs.tf:110; iac/aws-ecs.tf:563
- G.19CloudWatch alarms watch the CPU, the storage and the read operations of DocumentDB. iac/mongodb.tf:132; iac/mongodb.tf:163; iac/mongodb.tf:195
- G.20The tasks in the private subnets reach every provider above through the NAT gateway. iac/networking_v1.tf:169; iac/networking_v1.tf:194
- G.21Valkey encrypts its data at rest with a KMS key. iac/valkey.tf:162; iac/valkey.tf:205
- G.22A browser loads a frontend from CloudFront. A web ACL guards the distribution, and the origin is the frontends bucket in S3. iac/frontend.tf:233; iac/waf_cloudfront.tf:68; iac/frontend.tf:1; iac/frontend.tf:252–254
- G.23ACM issues the certificate of the load balancer, and the certificate of each CloudFront distribution. iac/aws-ecs.tf:88; iac/frontend.tf:78
- G.24The email intake Lambda function publishes
email_intake.create.v3.request to the orchestrator through RabbitMQ. iac/email_intake.tf:297; iac/email_intake.tf:531; services/lambdas/email-intake/main.go:16
- G.25Every 10 minutes the schedule starts the poweroff Lambda function. It reads and changes the desired count of the QA ECS services. iac/poweroff.tf:318; iac/poweroff.tf:220; services/lambdas/poweroff/reconcile.go:17–18; services/lambdas/poweroff/reconcile.go:117
- G.26AWS Backup saves the DocumentDB cluster each day. iac/mongodb.tf:234; iac/mongodb.tf:262; iac/mongodb.tf:281
- G.27Auth0 posts each sign-up and each login,
PostUserRegistration and PostLogin, to web-hooks-service at /v1/auth0. web-hooks-service publishes webhooks.auth0.v1.request to the orchestrator exchange, and worker-api creates the user of a sign-up. services/web-hooks-service/src/router.ts:56; services/web-hooks-service/src/sources/auth0/controller.ts:47–49; services/engine/microservices/orchestrator/controllers/auth/auth0_v1.py:57; services/engine/microservices/orchestrator/controllers/auth/auth0_v1.py:75
F · Front endsarch-v1
Ships the page of each web app as files apart from its back end (ADR 088), so server1 and CloudFront serve the same artifact with settings for each environment.
- keys each artifact by its commit, builds it in Docker after its checks and writes it to a bucket once (F.1–F.4)
- serves it from the local bucket with the env's config.js, or the source on a dev server (F.5–F.7)
- lets the page reach its back end on another origin (F.8, F.9), or on its own origin through the host (F.11)
- serves one release through CloudFront and server1 from the deploy branch (F.10, F.12–F.18)
- F.1
lexsup web publish gives the artifact of an app its key: the commit of HEAD when its inputs have no change, else <commit>-dirty-<12 hex>, the sha256 of the diff and of the untracked files. Only a local build may have a dirty key. tools/lexsup/internal/web/key.go:53; tools/lexsup/internal/web/key.go:90; tools/lexsup/internal/web/run.go:37
- F.2When the bucket does not hold the key, lexsup runs
docker buildx build --target web --output type=local with the commit time as SOURCE_DATE_EPOCH and the key as COMMIT_HASH. The check stage runs the tests of the page; the web stage holds the files alone. Scan refuses a config.js and an artifact.json in the files. tools/lexsup/internal/web/build.go:20; tools/lexsup/internal/web/build.go:26; tools/lexsup/internal/web/manifest.go:48; services/arch-board/Dockerfile:19; services/arch-board/Dockerfile:40
- F.3lexsup writes each file to
v2/web/<app>/<key>/ with If-None-Match: * and its sha256 as metadata, then artifact.json last. A file with the same sha256 counts as written; other content under the key stops the publish. tools/lexsup/internal/web/store.go:36; tools/lexsup/internal/web/store.go:43; tools/lexsup/internal/artifact/store.go:157
- F.4On each push of a branch, the workflow
web-artifacts assumes lexselect-lz-ci-publish-us-east-2 through GitHub OIDC and runs the same publish against the bucket of lexselect-shared, whose policy refuses a put without If-None-Match and every delete under v2/. M0 .github/workflows/web-artifacts.yml:68–82; docs/lex-arch-v2/11-build-and-publish.md:175–181
- F.5With
web.build=release, lexsup web run publishes the checkout's key if it is missing, gets its files from the local bucket with a check of each sha256, and writes config.js from the entries of kind public in the page's runtime.toml. tools/lexsup/internal/web/run.go:114; tools/lexsup/internal/web/store.go:63–93; tools/lexsup/internal/web/serve.go:27; tools/lexsup/internal/web/serve.go:49
- F.6The static host serves the files on the app's port:
config.js and index.html with revalidation for index.html and no-store for config.js, the hashed files under /assets/ for a year, and index.html for a route of the page. Each file carries the headers of the artifact's _headers.json, such as a CSP, and that file is not served. tools/lexsup/internal/web/serve.go:83; tools/lexsup/internal/web/serve.go:103–110; tools/lexsup/internal/web/serve.go:117–130; tools/lexsup/internal/web/serve.go:135–149; tools/lexsup/internal/web/host.go:38
- F.7With
web.build=dev, lexsup web run becomes the app's Vite dev server, which serves the source with auto reload and config.js from the app's environment. The board's dev server runs its Go generator after each save and reloads the page. tools/lexsup/internal/web/run.go:207; tools/web/vite-config-js.mjs:62; services/arch-board/web/vite.config.mjs:40; services/arch-board/web/vite.config.mjs:62
- F.8The page reads the address of its back end from
config.js and reaches it there: the dashboards open their WebSocket at LAB_API_URL/ws, Lab Lens calls /api, and Studio v2 calls API gateway v2 at LEXSELECT_API_BASE_URL and signs in at LEXSELECT_IDENTITY_ISSUER. services/lab-mirage-web/kit/kit.js:52; services/lab-mirage-web/kit/kit.js:234; services/lab-lens-web/src/core/configuration.ts:41; services/lab-lens-web/src/api/client.ts:36; services/studio-v2/src/core/configuration.ts:102; services/studio-v2/src/core/configuration.ts:104
- F.9A lab back end accepts the page's request when its Origin is its own Host or an origin in
LAB_UI_ALLOWED_ORIGINS, which lexsup sets to the page's address, and answers a read with CORS headers for that origin only. services/engine-rust/crates/lab-ui/src/server.rs:220; services/engine-rust/crates/lab-ui/src/server.rs:231; services/engine-rust/crates/lab-ui/src/server.rs:252; services/engine-rust/crates/lab-ui/src/server.rs:265; services/engine-rust/crates/lab-ui/src/server.rs:270–284; services/engine-rust/crates/lab-ui/src/server.rs:312; tools/lexsup/internal/envx/web.go:56
- F.10The custom resource verifies the release bundle and writes its files into the private bucket. M0 deploy/web/aws/installer.py:15–43
- F.11The sign-in page of identity v2 runs on the issuer's origin. In connected mode, its host sends each public path of
proxy-paths.json to identity v2 with its Host and Origin. The Vite dev server reads the same file. M0 tools/lexsup/internal/web/host.go:69; tools/lexsup/internal/web/host.go:86; tools/lexsup/internal/web/host.go:97; tools/lexsup/internal/web/serve.go:85–91; tools/lexsup/internal/web/serve_artifact.go:49–68; services/identity-v2-web/vite.config.ts:36; services/identity-v2-web/vite.config.ts:87
- F.12The protected server1 job supplies temporary S3 reader credentials. The installer stages and checks the seven bundles. M0 deploy/web/deploy-branch.yml:136–147
- F.13Traefik forwards each site hostname to one Nginx process. Nginx serves the corresponding release directory. M0 docs/adr/ADR_088_front_ends_ship_as_file_artifacts.md:138–140
- F.14CloudFront serves the active release and config.js. The viewer function returns 503 on reserved Identity routes. M0 deploy/web/aws/viewer.js:10–27
- F.15In VPN-only mode, DNS points each hostname to the shared API Gateway endpoint behind the corporate WireGuard hub. The private API invokes a streaming relay that fetches the page from CloudFront. The firewall accepts the proxy credential. M0 deploy/web/aws/deploy.py:117; deploy/web/aws/deploy.py:145–149; deploy/web/aws/deploy.py:155–162; deploy/web/aws/private.yaml:40–59; deploy/web/aws/private.yaml:89–93
- F.16CI records the seven S3 manifests and bundle digests after it packages the files. M0 .github/workflows/web-artifacts.yml:158–163
- F.18The portable stack installs the selected apps from the customer’s regional S3 bucket. Each nested stack returns its CloudFront hostname. M0 deploy/web/aws/package.py:44–62
- F.17A push verifies the contract and the release. A live configuration starts the selected deliveries. M0 deploy/web/deploy-branch.yml:108–115; deploy/web/deploy-branch.yml:136–147
A · Architecturesarch-v2-aws
Shows where each architecture runs and who reaches it: arch-v1 and v2 each in a frame, and a chip on each v2 block for each place that runs it.
- serves the products, Lex Studio, the public API and the admin dashboard of today from arch-v1 in the legacy account (A.1–A.4)
- runs v2 in three places, server1, our AWS and a customer's AWS from AWS Marketplace, each block with a chip for each place that runs it (A.5, A.6)
- keeps API management v2 and the admin dashboard in the places that LexSelect runs, so the LexSelect admin's line is drawn in their two hues only (A.7)
- keeps the data of each frame in areas by purpose, each with the store of each place
- carries data between the user data of arch-v1 and of v2 in our AWS through the planned sync module (A.8)
- A.1The users of today's products open the web application, Playground or the Word add-in. Each loads from its CloudFront distribution in the legacy account. iac/frontend.tf:233; iac/frontend.tf:1; docs/lex-arch-v2/26-block-separation.md:150–151
- A.2The API client (server to server) calls the public API of arch-v1 with its API key, on every version that it uses today. The gateway checks the key of each call. services/web-hooks-service/src/extapi/middleware/apiKeyAuth.ts:71; docs/lex-arch-v2/26-block-separation.md:150–151
- A.3The API manager manages the keys, the webhooks and the wallet in Lex Studio (
services/developer-portal), on arch-v1. services/developer-portal/src/features/keys/module/index.ts:33; docs/lex-arch-v2/26-block-separation.md:150–151
- A.4The LexSelect admin signs in to the admin dashboard in v1 mode with Auth0. The dashboard talks over Socket.IO to event-bridge. services/admin/src/eventBridge/service.ts:11–14; docs/adr/ADR_081_admin_dashboard_both_architectures.md:31–32
- A.5The API client (server to server) calls API gateway v2 with its API key, in each place of v2: on server1 in its Docker form, and in our AWS and in a customer's AWS as Lambda functions. M1 services/engine--go/gateway/internal/gateway/auth.go:48; docs/adr/ADR_067_api_v2_self_serve_go.md:107–110; docs/lex-arch-v2/27-deployment-targets.md:51–53; docs/lex-arch-v2/27-deployment-targets.md:122–131; docs/lex-arch-v2/28-marketplace-target.md:20–22; docs/lex-arch-v2/26-block-separation.md:153–164
- A.6The API manager manages the keys and the webhooks in Studio v2, in each place of v2. Studio v2 calls only API gateway v2. M1 services/studio-v2/src/core/configuration.ts:102; docs/adr/ADR_074_studio_v2_on_api_gateway_v2.md:44–46; docs/lex-arch-v2/27-deployment-targets.md:122–131; docs/lex-arch-v2/27-deployment-targets.md:135–136
- A.7The LexSelect admin signs in to the admin dashboard in v2 mode, on server1 and in our AWS, at identity v2 with the staff claim. The dashboard talks only to API management v2, over REST and SSE. A customer's AWS holds neither. M1 services/admin/src/eventBridge/service.ts:11–14; docs/adr/ADR_081_admin_dashboard_both_architectures.md:34–35; docs/adr/ADR_081_admin_dashboard_both_architectures.md:40–41; docs/lex-arch-v2/27-deployment-targets.md:133–134; docs/adr/ADR_077_v2_routes_and_data.md:52–53
- A.8The planned sync module carries data between the user data of arch-v1 and the user data of v2 in our AWS, in both directions. It is a module of its own, and its design is a later record. M3 docs/lex-arch-v2/16-standalone-v2.md:394–400; docs/adr/ADR_077_v2_routes_and_data.md:43–45
L · Landing zonearch-v2-aws
Gives the API its own AWS accounts, apart from arch-v1, with access and guardrails managed in one place.
- one account per purpose under a new management account, each with the same baseline (L.2)
- sign-in through Identity Center, with temporary credentials only (L.1, L.7)
- a CI role per account, and production deploys inside approved windows (L.3, L.8)
- organization-wide logging and security findings (L.4–L.5)
- L.1The CEO, the tech lead, the engineers and product sign in through IAM Identity Center in the management account, each in their group. No group holds write access to the management account or a production account. In a shared account, two sets write, each for one purpose: DevSecrets, the development secrets, in lexselect-shared, and Seller, the CEO's AWS Marketplace and AWS Partner Central, in lexselect-marketplace. Today's long-lived keys retire: the iac-admin user, labeling-agent and the deployment repository's GH_PAT. M1 docs/research/2026-11-05-aws-platform-v2.md:345–359; docs/research/2026-11-05-aws-platform-v2.md:403–412; docs/research/2026-11-14-landing-zone-questions.md:339–343; docs/adr/ADR_082_credentials_resolve_in_process_by_identity.md:191–192; docs/lex-arch-v2/38-marketplace-seller.md:197–199
- L.2Identity Center assigns permission sets in every member account, and Control Tower applies its controls and the SCPs to each OU, each first proven on a non-prod OU. CloudFormation stack sets give each new account its baseline when it enters its OU: the deploy role, a permissions boundary, a VPC, a DNS zone under aws.lexselect.io, threat detection with an alert, and the role through which Drata reads the account. M1 docs/research/2026-11-05-aws-platform-v2.md:314–321; docs/research/2026-11-05-aws-platform-v2.md:284–285; docs/research/2026-11-14-landing-zone-questions.md:94–97; docs/research/2026-11-14-landing-zone-questions.md:203–205; docs/research/2026-11-14-landing-zone-questions.md:56–59; docs/research/2026-11-14-landing-zone-questions.md:373–375; docs/research/2026-11-14-landing-zone-questions.md:371–372
- L.3GitHub Actions assumes the deploy role of an account through OIDC, each session for one hour, and the role runs CloudFormation change sets: the deploy branches (dev, daily, weekly) reach non-prod. The deploy role of a production, customer or shared account starts closed and takes a job only inside a window that a second person opened in AWS. The landing zone changes through a workflow whose apply role has a window of the same kind. M1 docs/research/2026-11-05-aws-platform-v2.md:361–370; docs/research/2026-11-14-landing-zone-questions.md:157–159; docs/research/2026-11-14-landing-zone-questions.md:203–205; docs/research/2026-11-14-landing-zone-questions.md:346–348; docs/research/2026-11-14-landing-zone-questions.md:349–351
- L.4The organization's CloudTrail and Config deliver every account's history to log-archive. M1 docs/research/2026-11-05-aws-platform-v2.md:297; docs/research/2026-11-05-aws-platform-v2.md:314–321
- L.5GuardDuty, Security Hub and Access Analyzer report to the security account as delegated administrator. GuardDuty runs in each account, and a finding of medium severity or more sends a message to the alarm topic of that account, which also takes the alarms of an application. Drata reads each account for the SOC 2 monitors through a role in that account. M1 docs/research/2026-11-05-aws-platform-v2.md:298; docs/research/2026-11-14-landing-zone-questions.md:373–375; docs/research/2026-11-14-landing-zone-questions.md:376–378; docs/research/2026-11-14-landing-zone-questions.md:371–372
- L.6The v1 link, in the legacy account, keeps arch-v2-aws's Database in lexselect-prod in step with arch-v1, one way, and carries no usage; nothing in lexselect-prod reaches the legacy account. How the link crosses the accounts is still open (item 16). M1 docs/lex-arch-v2/16-standalone-v2.md:28–36; docs/lex-arch-v2/16-standalone-v2.md:51–56; docs/research/2026-11-05-aws-platform-v2.md:213–220
- L.7An SCP on the Security, Infrastructure, Workloads and Sandbox OUs denies IAM users and access keys, and centralized root access removes the new accounts' root credentials: nothing in the new accounts holds a long-lived AWS key but one reader, an IAM user that reads configuration and logs in the accounts a list names. The ban is on from the start. The Legacy OU takes both once its keys retire, in a milestone after M1. M1 docs/research/2026-11-05-aws-platform-v2.md:325–343; docs/research/2026-11-05-aws-platform-v2.md:403–412; docs/research/2026-11-14-landing-zone-questions.md:331–335; docs/research/2026-11-14-landing-zone-questions.md:336–338; docs/implementation-plans/2026-11-06-m1-landing-zone-runbook.md:66; docs/implementation-plans/2026-11-06-m1-landing-zone-runbook.md:771–783
- L.8AWS gives the approval; GitHub runs the job and authorizes none. A person asks for a window, and a different person opens it in AWS: the CEO for the tech lead, the tech lead or the CEO for an engineer. The window's function refuses a window that a person asks for their own work. The open role takes the jobs of the named person alone, until the time ends. For a change by hand, TEAM gives a person a permission set for a time after a second person's approval. The rule has one switch, which starts off while the landing zone is built; the root user of the management account is above the rule, and a root sign-in sends a message to the CEO and the tech lead. M1 docs/research/2026-11-05-aws-platform-v2.md:372–381; docs/research/2026-11-14-landing-zone-questions.md:344–345; docs/research/2026-11-14-landing-zone-questions.md:352–354; docs/research/2026-11-14-landing-zone-questions.md:346–348; docs/research/2026-11-14-landing-zone-questions.md:349–351; docs/research/2026-11-14-landing-zone-questions.md:355–357; docs/research/2026-11-14-landing-zone-questions.md:410; docs/research/2026-11-14-landing-zone-questions.md:358–359
- L.9On each push of a branch, the workflow
web-artifacts assumes lexselect-lz-ci-publish-us-east-2 in lexselect-shared through OIDC and writes the web artifact of each app to the artifact bucket under v2/web/<app>/<commit>/, once. The role reaches v2/web/ only, and the bucket policy refuses a put without If-None-Match and every delete under v2/, also for Admin. Board F draws the rest of the path. M1 .github/workflows/web-artifacts.yml:68–82; docs/lex-arch-v2/11-build-and-publish.md:175–181; docs/adr/ADR_088_front_ends_ship_as_file_artifacts.md:32–38
B · Self-hostedarch-v2-self
Opens the API gateway v2 block of the block view in its Docker form, the form of the AWS containers target and the self-hosted target: one Go service that serves the routes of the public API that v2 needs, holds only its own data and meets each neighbour through a contract, each behind a connector. The aws set replaces each connector with an AWS service (ADR 092).
- serves the routes of v2 in all 11 versions, one handler per route through the version map (B.1, B.2)
- reads the key record, which says yes or no with a reason, and counts requests in the instance (B.3, B.4)
- takes a file into its own bucket and hears the put event of a linked file (B.5, B.6)
- writes one document record, writes the trigger to an outbox, and a relay puts it on the trigger stream (B.7–B.10, B.21)
- hears the end event on the processing-events stream and sends the webhook (B.11–B.13)
- sends a failed delivery again when a route of Studio v2 asks for it, in its own process (B.14)
- reads every result from the result files and their index (B.15)
- writes its analytics, when enabled, to OpenSearch (B.16)
- returns the usage record that another part writes (B.17)
- writes the key records with a compare-and-set on their revision, for its own routes and for each command of API management v2, copies each write to Valkey and keeps the copy true with its sync (B.18, B.19)
- writes the webhook endpoints for Studio v2 and for each command of API management v2 (B.20)
- follows the change streams of the endpoints and the documents, publishes the live events on a channel, and sends them to Studio v2 over SSE (B.22, B.23)
- takes the newest key set of identity v2 from its stream and checks each access token with it, with no call (B.24)
- B.1A client calls a route that API gateway v2 serves, in each of the 11
X-API-Version dates, with the same status codes, bodies, headers and errors. Every multipart upload and the sub-documents route stay on arch-v1. M1 services/engine--go/gateway/internal/gateway/gateway.go:163; docs/adr/ADR_067_api_v2_self_serve_go.md:179–185; docs/adr/ADR_071_gateway_owns_its_data.md:126–127; docs/adr/ADR_071_gateway_owns_its_data.md:131–133; contracts/public-api/v1/versions.go:5; contracts/public-api/v1/versions.go:21
- B.2The version map turns the request's version into a set of features, and the route's one handler branches on them, so one deploy serves every version. M1 services/engine--go/gateway/internal/gateway/engine.go:52; docs/adr/ADR_067_api_v2_self_serve_go.md:64–67; contracts/public-api/v1/version_map.go:7–10; contracts/public-api/v1/version_map.go:57; contracts/public-api/v1/version_map.json:54–55; contracts/public-api/v1/version_map.json:106–107
- B.3The limits: the instance counts the requests of each key for the minute in memory and decides with no store call, and each second it syncs its counts with Valkey, so the instances see each other. It counts the requests at the same time in the instance. A request whose key the cache does not know and allow takes one token from the budget of its client address in Valkey before the key store is read. A key that the store proves gets the token back, also when its answer refuses the work; an expired key keeps it. A request with a known key makes no address call. The stored answers of idempotent writes are in MongoDB, in
idempotent_responses, under the key id and the SHA-256 of the client's Idempotency-Key. A TTL index removes an answer after 24 hours, and a read ignores an answer that is past its time. M1 services/engine--go/gateway/internal/gateway/gateway.go:156; services/engine--go/gateway/internal/gateway/auth.go:48; services/engine--go/gateway/internal/gateway/iplimit.go:24; services/engine--go/gateway/internal/gateway/ratelimit.go:50; services/engine--go/gateway/internal/limits/limiter.go:73; services/engine--go/gateway/internal/limits/sync.go:35; services/engine--go/gateway/internal/connector/limits/valkey/counters.go:36; services/engine--go/gateway/internal/gateway/idempotency.go:57; services/engine--go/gateway/internal/gateway/idempotency.go:77; services/engine--go/gateway/internal/connector/own/mongo/idempotency.go:73; services/engine--go/gateway/internal/connector/own/mongo/idempotency.go:90; docs/adr/ADR_071_gateway_owns_its_data.md:51–56; docs/adr/ADR_067_api_v2_self_serve_go.md:69–82
- B.4The auth reads the key record by the hash of the key, through the
access contract, from the copy in Valkey, and keeps it in memory for 10 seconds, an unknown key too. A change of a key reaches each instance on the channel lexselect:v2:access:changes (B.18, B.19). The record says yes or no: on no, the gateway answers with the status and the text of the record. A credential that is a token of identity v2 takes the token path instead: the gateway verifies it with the newest key set of identity v2, which it takes from its stream and keeps in memory (B.24), with no call, reads the owner record of its org claim and admits the call with the limits of that record. M1 services/engine--go/gateway/internal/gateway/auth.go:48; services/engine--go/gateway/internal/keys/cache.go:101; services/engine--go/gateway/internal/connector/access/valkeycopy/reader.go:42; services/engine--go/gateway/internal/keys/cache.go:204; services/engine--go/gateway/internal/gateway/auth.go:58; services/engine--go/gateway/internal/gateway/sessionauth.go:26; services/engine--go/gateway/internal/session/keys.go:14; services/engine--go/kit/connector/identity/keyfeed/keyfeed.go:84; services/engine--go/gateway/internal/session/session.go:101; services/engine--go/gateway/internal/connector/access/valkeycopy/reader.go:48; docs/adr/ADR_071_gateway_owns_its_data.md:51–56; docs/adr/ADR_077_v2_routes_and_data.md:91–108; contracts/access/v2/interface.go:16–84; contracts/access/v2/interface.go:89–122
- B.5A client PUTs its file to the presigned link of API gateway v2's bucket. M1 services/engine--go/gateway/internal/routes/upload/link_answer.go:43; services/engine--go/gateway/internal/connector/own/objects/objects.go:96; docs/adr/ADR_067_api_v2_self_serve_go.md:179–185; docs/adr/ADR_071_gateway_owns_its_data.md:36–49
- B.6RustFS posts the put event to API gateway v2's object-event route, with its token; a repeated event changes nothing. M1 services/engine--go/gateway/internal/connector/own/objects/objects.go:78; services/engine--go/gateway/internal/routes/upload/events.go:148; docs/adr/ADR_071_gateway_owns_its_data.md:36–49; contracts/object-events/v1/interface.go:7–24
- B.7API gateway v2 keeps the upload job in its own MongoDB, accepts the file and writes one document record for it, with revision 1 and the location of the file in its bucket. The file stays where it is. If a delete removed the record before the trigger, the landing ends the upload as canceled. M1 services/engine--go/gateway/internal/routes/upload/link.go:149; services/engine--go/gateway/internal/routes/upload/landing.go:172; services/engine--go/gateway/internal/routes/upload/landing.go:176; services/engine--go/gateway/internal/routes/upload/accept.go:122; services/engine--go/gateway/internal/routes/upload/accept.go:128; services/engine--go/gateway/internal/connector/documents/mongo/create.go:29; services/engine--go/gateway/internal/connector/documents/mongo/create.go:80; docs/adr/ADR_071_gateway_owns_its_data.md:58–61
- B.8It writes the trigger to the outbox
processing_trigger_outbox in its own MongoDB, through the processing-trigger contract: the document, the location of its file, the overrides, the values of the key record and the request id. The entry has the id of the message and a sequence number, and a repeated write keeps the first entry. The upload counts as accepted only after the write. A relay puts the entry on the stream lexselect:v2:processing:triggers (B.21). M1 services/engine--go/gateway/internal/routes/upload/trigger.go:65; services/engine--go/gateway/internal/connector/processingtrigger/outbox/outbox.go:56; services/engine--go/gateway/internal/connector/processingtrigger/outbox/outbox.go:67; services/engine--go/gateway/internal/connector/processingtrigger/outbox/mongo.go:84; services/engine--go/gateway/internal/app/selfhosted.go:88; docs/adr/ADR_071_gateway_owns_its_data.md:63–67; contracts/processing-trigger/v2/interface.go:7–17; contracts/processing-trigger/v2/interface.go:31–40; contracts/processing-trigger/v2/contract.go:20–21
- B.9Processing reads the trigger with its consumer group and gets the file from the location that the trigger names. In the tests, Lex Lab Mirage plays processing: it takes each trigger and reads no file. M1 services/engine-rust/crates/lab-mirage-proc/src/stream_triggers.rs:283; services/engine-rust/crates/lab-mirage-proc/src/worker.rs:106; docs/adr/ADR_071_gateway_owns_its_data.md:63–67; docs/adr/ADR_071_gateway_owns_its_data.md:73–76; contracts/processing-trigger/v2/interface.go:7–17; contracts/processing-trigger/v2/interface.go:31–40; contracts/processing-trigger/v2/contract.go:20–21
- B.10Processing writes the run record at the start of the run, then one result file for each page and the index of the run, through the
processing-data contract. Mirage builds each page from its seed, so each run gives the same results. M1 services/engine-rust/crates/lab-mirage-proc/src/worker.rs:146; services/engine-rust/crates/lab-mirage-proc/src/run.rs:151; services/engine-rust/crates/lab-mirage-proc/src/run.rs:255; services/engine-rust/crates/lab-mirage-proc/src/mongo.rs:186; services/engine-rust/crates/lab-mirage-proc/src/mongo.rs:207; docs/adr/ADR_071_gateway_owns_its_data.md:63–67; contracts/processing-data/v2/interface_write.go:10–37
- B.11When the run ends, processing puts
document.processing.completed or failed on the stream lexselect:v2:processing:events, through the processing-events contract. M1 services/engine-rust/crates/lab-mirage-proc/src/stream_events.rs:38; docs/adr/ADR_071_gateway_owns_its_data.md:63–67; docs/adr/ADR_071_gateway_owns_its_data.md:36–49; contracts/processing-events/v1/interface.go:6–17; contracts/processing-events/v1/interface.go:22–36
- B.12API gateway v2 reads the event with its consumer group, removes the page count from its data and records one webhook job for each subscribed endpoint in its own MongoDB. M1 services/engine--go/kit/connector/processingevents/valkeystream/consumer.go:88; services/engine--go/gateway/internal/webhooks/handler.go:28; docs/adr/ADR_071_gateway_owns_its_data.md:36–49; contracts/processing-events/v1/interface.go:6–17; contracts/processing-events/v1/interface.go:22–36
- B.13The sender reads the endpoint through the
webhooks contract, signs each event, queued from the accept and completed or failed from processing, with the endpoint's secret, posts it to the client with today's retries and writes the delivery record. M1 services/engine--go/gateway/internal/webhooks/attempt.go:100; services/engine--go/contract/webhookdelivery/v1/headers.go:45; services/engine--go/gateway/internal/connector/webhooks/mongo/endpoints.go:39; services/engine--go/gateway/internal/connector/webhooks/mongo/deliveries.go:17; docs/adr/ADR_071_gateway_owns_its_data.md:36–49; contracts/webhooks/v1/interface.go:55–91
- B.14When a user of Studio v2 asks for a replay of a failed delivery, API gateway v2 checks the delivery and its endpoint and starts the replay in its own process, and answers 202 at once. The replay checks the job store and the budget and sends the delivery again, and its result is a row of the delivery list. The stream
lexselect:v2:webhook:replay (webhook-replay 3.0) stays: API gateway v2 reads it with its consumer group, drops a request that is older than 10 minutes and sends the delivery again, but no block sends on it now, because API management v2 serves only the admin dashboard. M1 services/engine--go/gateway/internal/connector/webhookreplay/valkeystream/server.go:74; services/engine--go/gateway/internal/webhooks/replay_server.go:25; services/engine--go/gateway/internal/routes/studiohooks/replay.go:23; services/engine--go/gateway/internal/routes/studiohooks/replay.go:52; docs/adr/ADR_070_api_gateway_v2_and_api_management_v2.md:36–39; docs/adr/ADR_070_api_gateway_v2_and_api_management_v2.md:46–58; docs/adr/ADR_068_api_management_v2_block.md:33–36; docs/adr/ADR_071_gateway_owns_its_data.md:36–49; docs/adr/ADR_077_v2_routes_and_data.md:55–62; docs/adr/ADR_077_v2_routes_and_data.md:50–62; contracts/webhook-replay/v3/contract.go:32–34; contracts/webhook-replay/v3/interface.go:7; contracts/webhook-replay/v3/interface.go:25
- B.15The read routes (status, pages, parse, render, list, get) read the document from API gateway v2's own MongoDB, and the run, its pages and its result files through the
processing-data contract. M1 services/engine--go/gateway/internal/connector/documents/mongo/read.go:28; services/engine--go/gateway/internal/connector/processingdata/mongo/processings.go:15; services/engine--go/gateway/internal/connector/processingdata/mongo/page_contents.go:14; docs/adr/ADR_067_api_v2_self_serve_go.md:179–185; docs/adr/ADR_071_gateway_owns_its_data.md:58–61; docs/adr/ADR_071_gateway_owns_its_data.md:63–67; contracts/processing-data/v2/interface_read.go:6–34; contracts/processing-data/v2/interface_read.go:37–57
- B.16While
API_GATEWAY_V2_ANALYTICS_ENABLED is true, API gateway v2 writes each audit event, the API activity and the success signal to OpenSearch, through the api-events contract. A write that finds 256 writes in progress is dropped and counted. M1 services/engine--go/gateway/internal/connector/apievents/opensearch/publisher.go:104; services/engine--go/gateway/internal/connector/apievents/opensearch/publisher.go:177; docs/adr/ADR_071_gateway_owns_its_data.md:36–49; contracts/api-events/v1/interface.go:9–25; contracts/api-events/v1/interface.go:30–48
- B.17The usage routes return the usage record of the owner, through the
access contract. It reads the copy in Valkey. Another part writes the record in MongoDB, the sync copies it (B.19), and API gateway v2 counts no pages and no money. M1 services/engine--go/gateway/internal/routes/usage/module.go:67; services/engine--go/gateway/internal/connector/access/valkeycopy/reader.go:64; docs/adr/ADR_071_gateway_owns_its_data.md:51–56; contracts/access/v2/interface.go:16–84; contracts/access/v2/interface.go:89–122
- B.18API gateway v2 writes each key record and owner record to MongoDB through the
access contract: for the key routes of Studio v2, for the owner record of a new organization, for its admin command, and for each command of API management v2 on lexselect:v2:access:commands (access 3.0). A write is a compare-and-set on the revision of the record: it succeeds only when the stored revision is the revision that the writer read. A stale write gets ErrStale with the current record. A write that succeeds adds 1 to the revision. The writer then applies the record to the copy in Valkey, which keeps only a higher revision, and publishes the change on lexselect:v2:access:changes. Each instance of API gateway v2 drops its entry in memory. A failed copy write is logged, and the sync of B.19 makes the copy. The sync also puts each change, without the secret hash, on lexselect:v2:access:events, and the gateway puts the result of each command there. API management v2 applies both to its own copy, and the request of the admin dashboard gets its answer from the result. M1 services/engine--go/gateway/internal/routes/studiokeys/service.go:107; services/engine--go/gateway/internal/connector/access/through/through.go:100; services/engine--go/gateway/internal/connector/access/mongo/cas.go:123; services/engine--go/gateway/internal/connector/access/through/through.go:50; services/engine--go/gateway/internal/connector/access/valkeycopy/copy.go:73; services/engine--go/gateway/internal/connector/access/valkeycopy/copy.go:90; services/engine--go/gateway/internal/admin/keycreate.go:89; services/engine--go/gateway/internal/admin/keycreate.go:99; services/engine--go/gateway/internal/accesscmd/accesscmd.go:52; services/engine--go/gateway/internal/app/commands.go:43; services/engine--go/mgmt/internal/adminapi/owners.go:93; services/engine--go/mgmt/internal/records/commands.go:49; services/engine--go/mgmt/internal/records/handler.go:85; services/engine--go/mgmt/internal/connector/records/mongo/store.go:108; docs/adr/ADR_077_v2_routes_and_data.md:75–89; docs/adr/ADR_077_v2_routes_and_data.md:91–108; contracts/access/v2/interface.go:16–84; contracts/access/v2/interface.go:89–122; docs/adr/ADR_083_v2_services_meet_only_through_queues.md:32–35; docs/adr/ADR_083_v2_services_meet_only_through_queues.md:43–46; contracts/access/v3/queue.go:9–17; contracts/access/v3/queue.go:102–121; contracts/access/v3/queue.go:159–185
- B.19The sync of API gateway v2 copies each change of the records from MongoDB to Valkey. One instance holds a lease of 15 seconds. It follows the change stream of the four collections from its resume point and saves the point after each change. For each change it writes the copy, which keeps only a higher revision, and publishes the change on the same channel as B.18. For a key, an owner record or a usage record it also publishes the event of access 3.0 on the stream
lexselect:v2:access:events, with the record and a key without its secret hash (ADR 083). If the resume point is empty or lost, or if the copy has no fill marker in Valkey, the sync fills the copy again from the collections, sets the marker and then follows the stream. A restart of Valkey removes the marker, so it loses no record. M1 services/engine--go/gateway/internal/app/selfhosted.go:94; services/engine--go/gateway/internal/accesssync/sync.go:64; services/engine--go/gateway/internal/accesssync/sync.go:110; services/engine--go/gateway/internal/accesssync/sync.go:144; services/engine--go/gateway/internal/accesscmd/events.go:41; services/engine--go/gateway/internal/connector/access/valkeycopy/copy.go:102; services/engine--go/gateway/internal/connector/access/mongo/feed.go:97; services/engine--go/gateway/internal/connector/access/mongo/feed.go:132; services/engine--go/gateway/internal/connector/access/valkeycopy/lease.go:50; docs/adr/ADR_077_v2_routes_and_data.md:91–108; contracts/access/v2/interface.go:16–84; contracts/access/v2/interface.go:89–122
- B.20API gateway v2 writes the webhook endpoints that a user manages in Studio v2, and reads their delivery records, in v2's MongoDB through the
webhooks contract. Each change of an endpoint is a compare-and-set on its revision (webhooks 1.2). A change of the URL first reads the old endpoint, and if that read fails the change answers its error and writes nothing. For the admin dashboard, API management v2 sends a pause, a resume or a delete as a command on lexselect:v2:webhooks:commands (webhooks 2.0) with the revision that it read. API gateway v2 does the same compare-and-set and puts the result on lexselect:v2:webhooks:events, next to each change of B.22. The signing secret is sealed at rest (AES-256-GCM, webhooks 1.1), API gateway v2 opens it when it sends a webhook (B.13), and the events carry no secret. M1 services/engine--go/gateway/internal/routes/studiohooks/crud.go:110; services/engine--go/gateway/internal/connector/webhooks/mongo/manage.go:48; services/engine--go/gateway/internal/routes/studiohooks/send.go:194; services/engine--go/gateway/internal/webhookscmd/webhookscmd.go:64; services/engine--go/mgmt/internal/adminapi/webhooks.go:35; services/engine--go/mgmt/internal/records/handler.go:110; services/engine--go/mgmt/internal/connector/records/mongo/store.go:143; docs/adr/ADR_068_api_management_v2_block.md:27–31; docs/adr/ADR_077_v2_routes_and_data.md:64–73; docs/adr/ADR_077_v2_routes_and_data.md:50–62; contracts/webhooks/v1/interface.go:55–91; contracts/webhooks/v1/interface.go:22–53; docs/adr/ADR_083_v2_services_meet_only_through_queues.md:32–35; docs/adr/ADR_083_v2_services_meet_only_through_queues.md:43–46; contracts/webhooks/v2/queue.go:9–17; contracts/webhooks/v2/queue.go:98–112; contracts/webhooks/v2/queue.go:135–157
- B.21A relay in API gateway v2 puts each entry of the trigger outbox on the stream
lexselect:v2:processing:triggers. One instance holds a lease of 15 seconds in Valkey. It reads the unsent entries in the order of their sequence number, 100 at a time, at each write of its own process and each 500 ms, and puts each entry on the stream, then marks it sent. While it drains, it renews the lease 3 times in each lease time, and a lease that is lost stops the drain at once. A failed publish ends the round at that entry, so no later entry passes it, and the next round tries it again. A crash between the publish and the mark puts the message on the stream twice with the same id, and the consumer drops the repeat. A sent entry leaves the outbox after 24 hours. A restart of Valkey loses no trigger and no cancel (ADR 077 D14). M1 services/engine--go/gateway/internal/app/selfhosted.go:109; services/engine--go/gateway/internal/triggerrelay/module/module.go:30; services/engine--go/gateway/internal/connector/processingtrigger/outbox/relay.go:55; services/engine--go/gateway/internal/connector/processingtrigger/outbox/relay.go:92; services/engine--go/gateway/internal/connector/processingtrigger/outbox/relay.go:118; services/engine--go/gateway/internal/connector/processingtrigger/outbox/relay.go:139; services/engine--go/gateway/internal/connector/processingtrigger/outbox/mongo.go:104; services/engine--go/gateway/internal/connector/processingtrigger/outbox/mongo.go:122; services/engine--go/gateway/internal/connector/processingtrigger/valkeystream/publisher.go:37; docs/adr/ADR_077_v2_routes_and_data.md:137–140; docs/adr/ADR_071_gateway_owns_its_data.md:63–67; docs/adr/ADR_071_gateway_owns_its_data.md:36–49; contracts/processing-trigger/v2/interface.go:7–17; contracts/processing-trigger/v2/interface.go:31–40; contracts/processing-trigger/v2/contract.go:20–21
- B.22Two followers in API gateway v2 each follow the change stream of one collection: the webhook endpoints, which API gateway v2 writes, and the documents. One instance holds a lease for each follower, keeps its resume point in the collection
sync_cursors and publishes each change, with its kind, id, owner and revision, on the Valkey channel lexselect:v2:studio:events (studio-api 1.5). The follower of the endpoints then reads the endpoint and publishes the event of webhooks 2.0 on the stream lexselect:v2:webhooks:events, without its secret (ADR 083). If the resume point is lost, the follower removes it and publishes a reset, and the next round starts at the present. The handler of identity events publishes account.updated and organization.updated on the same channel. At the start, the gateway turns on the change streams of each followed collection, for DocumentDB. M1 services/engine--go/gateway/internal/app/selfhosted.go:148; services/engine--go/gateway/internal/app/selfhosted.go:128–131; services/engine--go/gateway/internal/app/commands.go:87; services/engine--go/gateway/internal/webhookscmd/webhookscmd.go:167; services/engine--go/gateway/internal/livesync/module/module.go:29; services/engine--go/gateway/internal/livesync/sync.go:59; services/engine--go/gateway/internal/livesync/sync.go:110; services/engine--go/gateway/internal/connector/studiolive/mongo/feed.go:111; services/engine--go/gateway/internal/connector/studiolive/valkey/bus.go:44; services/engine--go/gateway/internal/identityevents/handler.go:67; services/engine--go/gateway/internal/identityevents/handler.go:69; docs/adr/ADR_077_v2_routes_and_data.md:91–108; docs/adr/ADR_077_v2_routes_and_data.md:110–112; contracts/studio-api/v1/types.go:13–25
- B.23The hub of each instance reads the channel and the access changes of the copy in Valkey, and sends each change to the open streams of its owner, or of its user for an account change. Studio v2 opens
GET /api/studio/events with its access token and gets the frames change and reset as server-sent events, with a keep-alive each 25 seconds, so it reads the record again without a poll. A new subscription of the hub, or a stream that falls behind, gives a reset. A stream ends at the expiry of its token, and the hub allows at most 5 streams for each user on one instance (a sixth gets 429). M1 services/engine--go/gateway/internal/routes/studioevents/module.go:38; services/engine--go/gateway/internal/connector/studiolive/valkey/bus.go:63; services/engine--go/gateway/internal/routes/studioevents/hub.go:140; services/engine--go/gateway/internal/routes/studioevents/hub.go:161; services/engine--go/gateway/internal/routes/studioevents/hub.go:99; services/engine--go/gateway/internal/routes/studioevents/stream.go:20; services/studio-v2/src/core/rest/events.ts:82; services/studio-v2/src/core/rest/events.ts:126; docs/adr/ADR_077_v2_routes_and_data.md:91–108; contracts/studio-api/v1/types.go:13–25
- B.24Identity v2 publishes its whole public key set on the stream
lexselect:v2:identity:keys (identity 2.0): at its start, at each change of the set and each 5 minutes. Each instance of API gateway v2 reads the newest entry at its start and then each new entry, with no consumer group, and keeps the set with the highest revision in memory. The token path of B.4 verifies each token with that set and makes no call to identity v2. With no set, a token gets 503 that names the missing key set, and the public API serves as usual. In the module test of the gateway, Lex Lab Mirage publishes the set with a test key. M1 services/engine--go/kit/connector/identity/keyfeed/keyfeed.go:68; services/engine--go/kit/connector/identity/keyfeed/keyfeed.go:84; services/engine--go/gateway/internal/session/keys.go:70; services/engine--go/gateway/internal/session/keys.go:97; services/engine--go/gateway/internal/app/session.go:17; services/engine--go/identity/internal/keys/announce.go:85; services/engine--go/identity/internal/connector/valkey/keyset.go:30; docs/lex-arch-v2/37-queues-and-module-alone.md:34–40; contracts/identity/v2/interface.go:5–42
D · AWS Serverlessarch-v2-aws
Our own deployment of v2 on AWS-managed services: arch-v2-aws in lexselect-prod. The v1 link copies the keys and the tenants in from arch-v1, one way, and the accounting block of v2 bills its runs through the Stripe account of v2, with no link to the billing of arch-v1 (ADR 075).
- keeps a copy of the keys and the tenants of arch-v1 in its own database, through the v1 link (D.1)
- takes the JSON upload of the pilot's API version from arch-v1's load balancer (D.2–D.4)
- takes the file straight into its own bucket and completes the document from the bucket's event (D.5–D.8)
- processes with its own scheduler and workers, from its own trigger queue (D.9, D.10)
- sends each webhook from the function that reads the queue processing-events and the function that the wake queue starts (D.11, D.12)
- bills each run in its accounting block, through the Stripe account of v2 (D.13)
- D.1The synchronizer of the v1 link copies the keys and the tenants of arch-v1 into arch-v2-aws's database, one way. Nothing in arch-v2-aws calls arch-v1, and the link carries no usage and no billing answer (ADR 075). M1 docs/lex-arch-v2/16-standalone-v2.md:28–36; docs/lex-arch-v2/16-standalone-v2.md:38–48; docs/lex-arch-v2/16-standalone-v2.md:51–56; docs/research/2026-11-05-aws-platform-v2.md:213–220; docs/adr/ADR_075_accounting_block.md:146–148
- D.2A client calls the public API at the address that it uses today. arch-v1's load balancer receives the request. docs/lex-arch-v2/17-alb-version-rule.md:6–10; docs/lex-arch-v2/17-alb-version-rule.md:15–20
- D.3One rule of the load balancer sends the JSON upload of the pilot's
X-API-Version to the function 1b-upload-by-link in lexselect-prod. Every other request goes on to arch-v1. M1 docs/lex-arch-v2/17-alb-version-rule.md:6–10; docs/lex-arch-v2/17-alb-version-rule.md:15–20; docs/lex-arch-v2/17-alb-version-rule.md:24–25; docs/lex-arch-v2/17-alb-version-rule.md:34–35; docs/lex-arch-v2/17-alb-version-rule.md:38–41; docs/research/2026-11-05-aws-platform-v2.md:239–251; services/engine--go/gateway/internal/targets/targets.go:63
- D.4The function
1b-upload-by-link reads the tenant and the answer of the API key in the key record of arch-v2-aws's database. It records the job and the document that waits for its file, and it answers with a presigned link. M1 docs/lex-arch-v2/14-upload-on-v2.md:23–29; docs/lex-arch-v2/14-upload-on-v2.md:40–44; docs/lex-arch-v2/17-alb-version-rule.md:27–32; docs/lex-arch-v2/16-standalone-v2.md:8–17; docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/lex-arch-v2/16-standalone-v2.md:28–36; docs/research/2026-11-05-aws-platform-v2.md:239–251; docs/research/2026-11-05-aws-platform-v2.md:213–220
- D.5The client PUTs the file to its link, straight into arch-v2-aws's bucket. M1 docs/lex-arch-v2/14-upload-on-v2.md:40–44; docs/lex-arch-v2/17-alb-version-rule.md:27–32; docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/research/2026-11-05-aws-platform-v2.md:239–251; docs/research/2026-11-05-aws-platform-v2.md:206–211
- D.6The bucket sends the
ObjectCreated:Put event of a key under api-uploads/ to the SQS queue object-events in the same account (ADR 092 D7). M1 services/engine--go/gateway/internal/stackgen/store.go:139; services/engine--go/gateway/internal/connector/own/awss3/files.go:26; docs/lex-arch-v2/14-upload-on-v2.md:30–32; docs/lex-arch-v2/14-upload-on-v2.md:96–99; docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/research/2026-11-05-aws-platform-v2.md:239–251; docs/adr/ADR_092_aws_connector_set_of_api_gateway_v2.md:72–73
- D.7The function
1b-upload-by-link-complete reads the queue object-events as its event source and gets the Object Created event of the bucket. The trigger of the function is an object event (ADR 090 D4, ADR 092 D7). M1 services/engine--go/gateway/internal/targets/targets.go:68; services/engine--go/gateway/internal/stackgen/plan.go:113; services/engine--go/gateway/internal/stackgen/trigger.go:99; services/engine--go/gateway/internal/connector/own/awss3/events.go:15; docs/lex-arch-v2/14-upload-on-v2.md:30–32
- D.8The function
1b-upload-by-link-complete checks the file and completes the document in arch-v2-aws's database. M1 docs/lex-arch-v2/14-upload-on-v2.md:30–32; docs/lex-arch-v2/14-upload-on-v2.md:55–56; docs/lex-arch-v2/14-upload-on-v2.md:100–104; docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/research/2026-11-05-aws-platform-v2.md:233–238; docs/research/2026-11-05-aws-platform-v2.md:239–251
- D.9It writes the processing trigger to the outbox table of the database. The function
1b-upload-by-link-relay reads the DynamoDB Stream of the table and sends each trigger to arch-v2-aws's trigger queue. The function also stores the webhook job of document.processing.queued for each endpoint, and the job store sends a wake to the queue webhook-send. M1 services/engine--go/gateway/internal/connector/processingtrigger/awsdynamo/outbox.go:72; services/engine--go/gateway/internal/targets/targets.go:76; services/engine--go/gateway/internal/stackgen/trigger.go:115; services/engine--go/kit/serve/lambdaevents/stream.go:35; services/engine--go/gateway/internal/webhooks/emit.go:28; services/engine--go/gateway/internal/connector/own/awsdynamo/webhook_jobs.go:153; docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/research/2026-11-05-aws-platform-v2.md:239–251; docs/research/2026-11-05-aws-platform-v2.md:530
- D.10arch-v2-aws's own scheduler v2 reads the trigger and processes the document with its workers and the ML providers. It writes the processings, the pages and the results to the database. M1 docs/lex-arch-v2/16-standalone-v2.md:19–26; docs/research/2026-11-05-aws-platform-v2.md:206–211; docs/research/2026-11-05-aws-platform-v2.md:239–251
- D.11The scheduler puts
document.processing.completed or failed on the SQS queue processing-events. The function 2-processing-webhook reads the queue as its event source (ADR 090 D4, ADR 092 D2). M1 services/engine--go/gateway/internal/stackgen/model.go:120; services/engine--go/gateway/internal/stackgen/trigger.go:99; services/engine--go/gateway/internal/connector/processingevents/awssqs/consumer.go:25; services/engine--go/gateway/internal/app/aws.go:135; services/engine--go/gateway/internal/targets/targets.go:84; docs/lex-arch-v2/14-upload-on-v2.md:105–108; docs/research/2026-11-05-aws-platform-v2.md:239–251
- D.12The function
2-processing-webhook makes one delivery job for each endpoint of the tenant that takes the event. The function 2-processing-webhook-send signs the event with the secret of the tenant and posts it to the endpoint of the client. When a job is due, the job store sends a wake to the SQS queue webhook-send, and the send function reads it (ADR 092 D7). A timer of one minute is the floor. M1 services/engine--go/gateway/internal/connector/own/awsdynamo/webhook_wake.go:49; services/engine--go/gateway/internal/connector/own/awsdynamo/webhook_wake.go:98; services/engine--go/gateway/internal/stackgen/model.go:146; services/engine--go/gateway/internal/webhooks/module.go:100; docs/lex-arch-v2/14-upload-on-v2.md:105–108; docs/lex-arch-v2/16-standalone-v2.md:8–17; docs/research/2026-11-05-aws-platform-v2.md:239–251; services/engine--go/gateway/internal/targets/targets.go:89; services/engine--go/gateway/internal/targets/targets.go:89; services/engine--go/gateway/internal/webhooks/dispatch.go:32
- D.13The accounting block of arch-v2-aws reads the terminal event of each run from the bus, books its pages, and bills through the Stripe account of v2 (row E). It has no link to the billing of arch-v1. M1 docs/adr/ADR_075_accounting_block.md:31–33; docs/adr/ADR_075_accounting_block.md:146–148; docs/lex-arch-v2/31-accounting-block.md:459–461; docs/lex-arch-v2/31-accounting-block.md:124
C · AWS Marketplacearch-v2-aws
The stack that a buyer installs from AWS Marketplace in an AWS account of their own. It is serverless as much as possible: the API runs as Lambda functions, and the scheduler, the workers and the ML models, which cannot run as Lambda functions, run as containers.
- installs from one CloudFormation template, with the function packages from our buckets and the images from the registry of AWS Marketplace (C.1–C.3)
- serves the public API from Lambda functions behind API Gateway, with a key table of its own (C.4, C.5)
- takes a file through a presigned URL and hears its put event (C.6, C.7)
- hands the document to processing through the processing data and the trigger queue (C.8, C.9)
- processes in containers: the scheduler distributes the tasks, the workers do them, the scheduler assembles the results (C.10–C.13)
- answers the API with the terminal event, and the API sends the webhook (C.14–C.16)
- reads every result from the processing data (C.17)
- counts the usage in a ledger, sends the hourly totals to the metering block in our seller account, which reports them to AWS Marketplace and writes the answer of each key (C.18–C.21)
- C.1The customer starts the CloudFormation template, from the listing on AWS Marketplace or directly. It creates the whole stack in their account: a VPC of its own, the functions, the queues, the stores and the services. M1 docs/lex-arch-v2/28-marketplace-target.md:13–15; docs/lex-arch-v2/28-marketplace-target.md:18–19; docs/lex-arch-v2/28-marketplace-target.md:131–133
- C.2Each Lambda function loads its precompiled package from our distribution bucket of the Region. Each release has a path of its own. The make rule
functions builds one zip for each function, and the same code gives the same bytes (ADR 090). lexsup functions publish writes each zip to the artifact bucket under the key of its content, and the manifest of the commit last. M1 docs/lex-arch-v2/28-marketplace-target.md:20–22; docs/lex-arch-v2/28-marketplace-target.md:145–148; services/engine--go/mk/functions.mk:28; tools/lexsup/internal/functions/functions.go:66; tools/lexsup/internal/functions/functions.go:103
- C.3Amazon ECS pulls the images of the scheduler and the workers. For a buyer, the subscription lets the account pull them from the registry of AWS Marketplace. M1 docs/lex-arch-v2/28-marketplace-target.md:23–25; docs/lex-arch-v2/28-marketplace-target.md:131–133
- C.4A client calls the public API. API Gateway is the front door, and a Lambda function serves each route: the units table of API gateway v2 has one row for each function (ADR 090). M1 docs/lex-arch-v2/28-marketplace-target.md:20–22; docs/lex-arch-v2/28-marketplace-target.md:143–144; docs/adr/ADR_067_api_v2_self_serve_go.md:153–154; services/engine--go/gateway/internal/targets/targets.go:61; services/engine--go/gateway/internal/fnboot/lambda.go:33
- C.5The function checks the key in the key table of the stack's own data store. The key record holds the answer for the key: yes, or no with a reason. M1 docs/lex-arch-v2/28-marketplace-target.md:30–32; docs/lex-arch-v2/28-marketplace-target.md:158–159; docs/adr/ADR_072_v2_billing_one_meter_two_payers.md:39–40
- C.6The client PUTs its file to the upload bucket through a presigned URL. M1 docs/lex-arch-v2/28-marketplace-target.md:143–144
- C.7The bucket sends its put event to the SQS queue
object-events. The object-event function reads the queue as its event source (ADR 092 D7). M1 services/engine--go/gateway/internal/stackgen/store.go:139; services/engine--go/gateway/internal/stackgen/trigger.go:99; services/engine--go/gateway/internal/connector/own/awss3/events.go:15; docs/lex-arch-v2/28-marketplace-target.md:143–144; docs/lex-arch-v2/28-marketplace-target.md:158–159; docs/adr/ADR_092_aws_connector_set_of_api_gateway_v2.md:72–73
- C.8The function accepts the file and writes the document to the processing data. M1 docs/lex-arch-v2/28-marketplace-target.md:20–22; docs/lex-arch-v2/28-marketplace-target.md:158–159
- C.9The function writes the trigger to the outbox table. The relay function reads the DynamoDB Stream of the table and puts the trigger on the trigger queue. The message holds the S3 location of the document and the data of the job. M1 services/engine--go/gateway/internal/connector/processingtrigger/awsdynamo/outbox.go:72; services/engine--go/gateway/internal/targets/targets.go:76; services/engine--go/gateway/internal/stackgen/trigger.go:115; services/engine--go/kit/serve/lambdaevents/stream.go:35; docs/lex-arch-v2/28-marketplace-target.md:168–172
- C.10The scheduler takes the message and extends its visibility timeout while the document is in progress. M1 docs/lex-arch-v2/28-marketplace-target.md:27–29; docs/lex-arch-v2/28-marketplace-target.md:173–174
- C.11The scheduler downloads the document and distributes the tasks between the workers. The ML workers run on GPU instances and scale on the count of the messages that wait. M1 docs/lex-arch-v2/28-marketplace-target.md:27–29; docs/lex-arch-v2/28-marketplace-target.md:183–187
- C.12Each worker writes the result of its task to the processing data, under the IDs of the document and the task. After a restart, the scheduler continues from the tasks that are done. M1 docs/lex-arch-v2/28-marketplace-target.md:179–180
- C.13The scheduler assembles the results, stores them in the result bucket and deletes the trigger message. M1 docs/lex-arch-v2/28-marketplace-target.md:27–29; docs/lex-arch-v2/28-marketplace-target.md:173–174
- C.14The scheduler puts the terminal event of the run on the events queue. M1 docs/lex-arch-v2/28-marketplace-target.md:168–172
- C.15A function takes the event from the events queue. Its handler is safe to repeat. M1 docs/lex-arch-v2/28-marketplace-target.md:168–172
- C.16The function signs the webhook and sends it to the client. When a job is due, the job store sends a wake to the SQS queue
webhook-send, and the send function reads it. M1 services/engine--go/gateway/internal/connector/own/awsdynamo/webhook_wake.go:49; services/engine--go/gateway/internal/connector/own/awsdynamo/webhook_wake.go:98; services/engine--go/gateway/internal/stackgen/model.go:146; services/engine--go/gateway/internal/webhooks/module.go:100; docs/lex-arch-v2/28-marketplace-target.md:20–22; docs/lex-arch-v2/28-marketplace-target.md:168–172; docs/adr/ADR_092_aws_connector_set_of_api_gateway_v2.md:61–63
- C.17The read routes read the processings, the pages and the results from the processing data. M1 docs/lex-arch-v2/28-marketplace-target.md:20–22; docs/lex-arch-v2/28-marketplace-target.md:158–159
- C.18A function reads each terminal event from the events queue and writes one usage event to the usage ledger in the data store: the id
v2:{processing_id}:pages, the pages and a sequence number. The stack makes no MeterUsage call. M1 docs/adr/ADR_072_v2_billing_one_meter_two_payers.md:32–37; docs/lex-arch-v2/28-marketplace-target.md:264–268
- C.19Each hour, the stack sends the closed hours of its ledger to the Marketplace payer of the accounting block in our seller account. M1 docs/adr/ADR_072_v2_billing_one_meter_two_payers.md:56; docs/lex-arch-v2/28-marketplace-target.md:264–268; docs/lex-arch-v2/31-accounting-block.md:240–241
- C.20The Marketplace payer sends
BatchMeterUsage to AWS Marketplace with the dimension pages. The entitlement events of AWS come back to it. M1 docs/adr/ADR_072_v2_billing_one_meter_two_payers.md:56; docs/adr/ADR_072_v2_billing_one_meter_two_payers.md:55; docs/lex-arch-v2/28-marketplace-target.md:264–268; docs/lex-arch-v2/31-accounting-block.md:236–250
- C.21The Marketplace payer writes the standing of the key in the key table of the stack: yes, or no with
SUBSCRIPTION_INACTIVE. This step and the two before it occur only in an install from the listing. M1 docs/adr/ADR_072_v2_billing_one_meter_two_payers.md:39–40; docs/adr/ADR_072_v2_billing_one_meter_two_payers.md:55; docs/lex-arch-v2/28-marketplace-target.md:264–268; docs/lex-arch-v2/31-accounting-block.md:245–246