gateway/

directory
v0.3.0-20261203221930-... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0

README

SubmitQueue Gateway

The gateway is the RPC entry point to SubmitQueue. It accepts Land, Cancel, GetRequestSummaryByID, GetRequestSummaryByChangeURI, List, GetRequestHistoryByID, GetRequestHistoryByChangeURI, and Ping calls. It validates edge-owned input and hands asynchronous work to the orchestrator through the message queue.

Request receipts and current summaries

Land first creates an internal request summary in accepting state. That receipt prevents a failed publish from exposing work that was never admitted. After the start message is published, the gateway records the accepted log through the request materializer.

The materializer appends the log, chooses the winning current status, and activates or repairs the public projections:

  • The authoritative request summary keyed by sqid.
  • One change-URI mapping per submitted URI.
  • The queue-ordered projection used by List.

GetRequestSummaryByID and GetRequestSummaryByChangeURI read authoritative summaries. List reads the queue projection and may briefly lag while later log materialization repairs a partial attempt. If recording accepted fails after publication, Land still succeeds because subsequent pipeline logs can advance the internal accepting summary and create the public projections.

Request log ownership

The gateway owns the request log read model and is the only service that reads it.

  • Land publishes first and then attempts to materialize accepted; publication is its success boundary. Cancel materializes cancelling before publishing so the user's intent is visible when the RPC returns.
  • For statuses produced downstream, the orchestrator publishes entries to the log topic through submitqueue/orchestrator/core/request.PublishLog. The gateway consumes that topic and persists each entry through the same materializer (submitqueue/gateway/core/request).
  • Orchestrator DLQ reconciliation transitions durable request state and publishes terminal log entries to the same log topic; the gateway remains the materializer.
  • GetRequestHistoryByID and GetRequestHistoryByChangeURI read retained request-log rows directly.

The materializer appends every audit event, selects the current authoritative winner, and repairs the queue projection. The normal orchestrator pipeline does not read or write the request-log store directly.

A finished status keeps the reason and metadata it was first recorded with. When the orchestrator repairs a request already in that state it resends the terminal log marked resent, with whatever details the repairing path knows, which may differ from the original's or be none. So a log restating the summary's finished status and request version only fills details the summary lacks, whichever copy arrives first, and the resent marker stays in History, never in the summary.

Request hook events

The materializer publishes SubmitQueue's request hook events (submitqueue/core/hookevent) to the submitqueue-hook topic, which the orchestrator pipeline's hook stage consumes, one event per change of the request. The update that takes the summary out of accepting announces request.received, once. That is normally Land, and a later log only when Land failed to record accepted; a failed receipt publish is only counted on request_hook.publish_errors and never repeated. Every delivery of a log that restates a landed, error or cancelled summary announces request.landed, request.failed or request.cancelled, so a failed publish is returned and the log's redelivery repairs it; a copy that arrives after the queue has forgotten the event id reaches hooks twice. Events therefore follow the summary users see, including a request whose start failed before the orchestrator saved it, and a stale or unfinished log publishes nothing. A request.failed payload also carries the summary's failure_category, its reason as failure_reason, for a duplicate the in-flight request as duplicate_of, and for a merge conflict its paths as conflicting_files, when it has them.

Final log recovery

The primary gateway-log consumer sends failed deliveries to log_dlq after a non-retryable error or exhaustion of its finite retry budget. The gateway's gateway-log-dlq consumer replays retained entries through the same log controller and materializer, with unlimited attempts, capped backoff, and no second-level DLQ. Valid log deliveries are acknowledged only after history, summary, URI mappings, and receipt projection succeed. Replays may append equivalent history rows; terminal-summary precedence and mapping repair are unchanged.

With valid envelope metadata, malformed payloads and payload-queue identity conflicts stay in log_dlq, with topic/group-tagged diagnostics and deserialize or identity-error counters. Retrying unchanged bad data does not repair it. This is retention, not isolated quarantine: poison records can occupy the fetch window and delay later recovery. Operators must durably export a bad record and record its disposition before deleting it; corrected payloads must be replayed through gateway materialization. No export/replay CLI is provided. Rolling back the gateway stops automatic recovery but must leave the backlog intact.

Invalid envelope metadata is logged and rejected before the controller runs. If no further DLQ exists, rejection may acknowledge and discard the delivery without retry; operators investigate the logged failure if needed.

Directories

Path Synopsis
log
core
extension
storage
Package storage resolves the gateway's queue-scoped stores: the append-only request log and the read models behind request-summary retrieval and List.
Package storage resolves the gateway's queue-scoped stores: the append-only request log and the read models behind request-summary retrieval and List.
storage/mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL