## Web Publishing Design

CogOS provides the bridge. The cogent decides what to build.

### Architecture

Request Flow
Browser
│
▼ Cloudflare (Access auth + DNS)
│
▼ Web Gateway Lambda (new, per-cogent, Function URL)
│
├─── Static: /*
│ │
│ ▼ map URL → web/{path} in file store
│ ▼ read from Postgres
│ ▼ return HTML/JS/CSS
│
└─── Dynamic: /api/*
│
▼ append to io:web:request channel
▼ auto-delivery created, handler marked RUNNABLE
▼ SQS → ingress Lambda → executor dispatches handler
▼ handler calls web.respond()
▼ gateway reads io:web:response:{id}
▼ return HTTP response

### Separation of Concerns

CogOS (OS layer)

Web Gateway Lambda
Routes HTTP → file store or channels

`web` Capability
publish(), unpublish(), respond(), list()

`io:web:*` Channels
Request/response message plumbing

CDK Infrastructure
Lambda, Function URL, DNS, IAM

Cogent (App layer)

Published files
HTML/JS/CSS in web/* file store prefix

Handler process
Daemon subscribed to io:web:request

Route logic
Process decides what /api/* paths do

Frontend behavior
JS knows which endpoints are fast/slow

### Discord Analogy

Concept | Discord | Web
--- | --- | ---
IO Bridge | Discord Bridge (Fargate) | Web Gateway Lambda
Inbound Channel | io:discord:dm | io:web:request
Capability | discord.send_message() | web.respond()
Dispatch | append → delivery → ingress → executor | append → delivery → ingress → executor
Handler | discord cog handler coglet | web cog handler coglet

### New Infra (Cogtainer CDK)

Web Gateway Lambda — Python 3.12, 512 MB, 60s timeout, Function URL, VPC (Postgres access)

Cloudflare DNS — point subdomain at Function URL (Access policy already exists)

io:web:request channel — created in image boot, like io:discord:* channels

Everything else unchanged: ALB, dashboard, executor, scheduler, polis infra