| 1 | // Package dbreads is a forwarded `carlos db` read (spec |
| 2 | // docs/superpowers/specs/2026-10-22-db-region-forward-design.md): the wire |
| 3 | // the console, the box and the CLI share, and the box's half of the work. |
| 4 | // Every object lives under db-reads/ in the deployment bucket and is a |
| 5 | // conditional create; the store's lifecycle rule is the only deletion (J2, |
| 6 | // J4). |
| 7 | package dbreads |
| 8 | |
| 9 | import ( |
| 10 | "time" |
| 11 | |
| 12 | "github.com/carlosframework/platform/internal/runs" |
| 13 | ) |
| 14 | |
| 15 | // Capability is what a box publishes in its edges file while its armed |
| 16 | // db-reads loop's last readiness probe passed (spec §7.1). |
| 17 | const Capability = "db-read-1" |
| 18 | |
| 19 | // Purpose is the envelope's fixed purpose and the sealing's HKDF info: one |
| 20 | // string, so nothing else signed by the root or sealed by this package can be |
| 21 | // mistaken for a db read. |
| 22 | const Purpose = "carlos-db-read-v1" |
| 23 | |
| 24 | // Prefix is the one prefix every db read object lives under. |
| 25 | const Prefix = "db-reads/" |
| 26 | |
| 27 | const ( |
| 28 | OpQuery = "query" |
| 29 | OpPull = "pull" // plan 3 |
| 30 | |
| 31 | PickupWindow = 60 * time.Second // from issued_at (§5.7) |
| 32 | Skew = 60 * time.Second |
| 33 | ConsoleWaitsPicked = 2 * time.Minute |
| 34 | PlanBudget = 10 * time.Minute |
| 35 | QueryTimeout = 5 * time.Minute |
| 36 | OwnerDeadline = 20 * time.Minute |
| 37 | OwnerGrace = time.Minute |
| 38 | RequestBound = 22 * time.Minute |
| 39 | CLIBound = 23 * time.Minute |
| 40 | CancelEvery = 5 * time.Second |
| 41 | ListEvery = 30 * time.Second |
| 42 | ProbeEvery = 5 * time.Minute |
| 43 | WorkerExitGrace = 5 * time.Second |
| 44 | MaxJitter = 500 * time.Millisecond |
| 45 | |
| 46 | DefaultMaxRestored int64 = 2 << 30 // CARLOS_DB_READ_MAX_BYTES |
| 47 | // PlanBytesFactor bounds a plan's LTX files, all together, at this many |
| 48 | // times the restored-size cap: the most a worker writes before it |
| 49 | // restores (Astra round 1, finding 1). |
| 50 | PlanBytesFactor int64 = 2 |
| 51 | MaxOutputBytes = runs.MaxOutputBytes |
| 52 | ChunkBytes = runs.ChunkBytes |
| 53 | ChunkEvery = runs.ChunkEvery |
| 54 | // MaxPullBytes is a pull's cap on its planned LTX files (spec §5.7, rev |
| 55 | // 7: measured on dev, 2026-10-23). CARLOS_DB_PULL_MAX_BYTES on a box can |
| 56 | // only lower it, so no box ships more than a CLI accepts. |
| 57 | MaxPullBytes int64 = 2 << 30 |
| 58 | // PullChunkBytes is a pull's chunk: larger than a query's, so a full |
| 59 | // pull is about two thousand objects, not eight. |
| 60 | PullChunkBytes = 1 << 20 |
| 61 | |
| 62 | ReadsPerBox = 2 |
| 63 | MaxConnections = 3 // two reads and one probe (carlos-dbread.socket) |
| 64 | OpenPerPerson = 2 |
| 65 | OpenPerConsole = 16 |
| 66 | |
| 67 | DiskFloor int64 = 5 << 30 |
| 68 | DiskFreePercent = 10 |
| 69 | |
| 70 | // MaxSQLBytes keeps a request well inside the root envelope's payload |
| 71 | // bound (release.MaxRootEnvelopeBytes/2). |
| 72 | MaxSQLBytes = 256 << 10 |
| 73 | ) |
| 74 | |