Two independent facts force a server between the browser and the engine, and both were measured before the phase started.
| Fact | Consequence |
|---|---|
StarRocks answers on port 9030 with the binary MySQL protocol | No browser implements it. The frontend cannot open that socket from JavaScript, with or without CORS. |
The FE's HTTP shortcut POST /api/query returns 501 Not Implemented on 3.5.21 | There is no HTTP escape hatch in this build either. The tier is the only path. |
Phase 9 needed ten charts, which four queries cannot feed, so seven consolidations were added later (resumen, por-fuente, por-anio-fuente, por-mes, por-rango-valor, por-contratista, por-municipio). The table below is what closed this phase; the full list lives in the Phase 9 report.
| Endpoint | Returns |
|---|---|
GET /api/v1/consolidados/por-anio | Contracts and exact value per year — 29 rows, including the year 0 that means "no usable date". |
GET /api/v1/consolidados/por-entidad?anio=2024&limit=20 | Top entity codes by contracted value for one year. |
GET /api/v1/consolidados/por-departamento?anio=2024 | Value per department for one year. |
GET /api/v1/consolidados/texto?termino=computadores | Contracts whose object text contains the term, case-folded. |
Every response shares one envelope, so the page never parses two formats:
{ "data": [ … ], "generatedAt": "2026-11-25T20:41:12Z",
"source": "starrocks 3.5.21-85fccf8", "cached": false, "rows": 29 }
source is the engine's own current_version(), asked once and cached. A screenshot cannot claim a number came from somewhere else.
These are not stylistic: each one prevents a specific wrong answer. SUM(CAST(valor AS DECIMAL(20,0))) keeps the sum exact instead of order-dependent doubles. LOWER() on both sides of the LIKE is mandatory because StarRocks compares byte-exact and the stored text is uppercase — without it the search returns zero. Grouping is on codes, not names, so no collation rule can merge two entities into one group.
The service connects as secop_reader, never as root. The grant and the refusal were both captured:
SHOW GRANTS FOR 'secop_reader';
GRANT SELECT ON ALL TABLES IN DATABASE secop TO USER 'secop_reader'@'%'
CREATE TABLE secop.prohibido (a int); -- executed as secop_reader
ERROR 5203: Access denied; you need (at least one of) the
CREATE TABLE privilege(s) on DATABASE secop
Credentials arrive as SR_URL, SR_USER and SR_PASSWORD, and the application refuses to start without them — see section 7, where that claim had to be earned twice.
Each endpoint was compared with the same aggregation run directly on StarRocks as the same read-only user. Not "looks plausible" — equal to the last digit.
| Endpoint | API | Direct SQL on 9030 |
|---|---|---|
por-entidad 2024, top 1 | 702,066,010 · 867 · 542,835,589,430 | 702,066,010 · 867 · 542,835,589,430 |
por-departamento 2023, top 1 | Bogotá D.C. · 19,106 · 5,079,420,810,687 | Bogotá D.C. · 19,106 · 5,079,420,810,687 |
por-anio, year 0 | 120,778 | 120,778 |
por-anio 2024 | 71,901 | 71,901 |
texto = computadores | 2,018 | 2,018 |
Two of those numbers are also cross-checks against earlier phases: 120,778 is the count of null date markers from Phase 4, and 2,018 is exactly what Q2a measured in Phase 5. The API is not a second opinion, it is the same answer through another door.
There is no materialised view, no cron and no polling. Each request reads the engine; the heaviest consolidation measured 334 ms in Phase 5, so that is already interactive. In front of it sits a 60-second courtesy cache, and ?refresh=true always bypasses it.
| Request | cached | Meaning |
|---|---|---|
| First call, key never seen | false | Answered by StarRocks. |
| Immediate repeat, same key | true | Served from memory; the flag says so instead of pretending. |
Same key with ?refresh=true | false | Cache skipped, engine asked again. |
At 334 ms a pre-aggregated copy would add a staleness window and buy no visible time. It stays a documented option with a threshold: the day a consolidation crosses about 2 s, the view comes back — and Phase 5's profile already shows where that time would come from.
With a second instance pointed at a dead port, the API answered:
HTTP/1.1 503
{ "error": "engine_unavailable", "engine": "starrocks",
"message": "StarRocks did not answer: Connection refused", "at": "…" }
CORS was checked in both directions: localhost:5173 gets 200 with Access-Control-Allow-Origin, any other origin gets 403 and no header. The engine itself stays bound to loopback.
One measured caveat worth writing down: the container needs roughly 13–15 s before it answers. A curl fired at 14 s returned an empty reply — not a 503, not a 500. An empty socket is what a client sees when it arrives before Tomcat is listening, and confusing that with an application error costs an hour.
The plan said the app must refuse to start without credentials. The first build started anyway without SR_URL and sat there answering 503 to everything — a service that looks healthy and answers nothing, which is the exact opposite of the requirement. Spring leaves an unresolved ${SR_URL} in place longer than the phrase "fail fast" suggests.
Fixed with an explicit StartupCheck that inspects the environment during context creation and throws. Measured afterwards, in both directions:
without SR_URL / SR_USER / SR_PASSWORD Exited (1) IllegalStateException: Missing required environment variables: SR_URL, SR_USER, SR_PASSWORD with the three variables 200 · rows=29 · source=starrocks 3.5.21-85fccf8 · cached=false
To prove the reader could not create tables, I put SHOW GRANTS and CREATE TABLE in one file and ran it as root — which created the very table the test was meant to be denied. The next attempt then failed with "table already exists", which looks like a permission error and is not one. The table was dropped (secop is back to contratos and entidades) and the test re-run with the DDL as the only statement, as the reader: ERROR 5203 Access denied.
The lesson is the same one Phase 4 taught with the null markers: a test that shares its setup with its subject proves nothing.
Four payloads were captured from the running API into src/test/resources/golden/. They are not invented; they are today's answers, frozen so the React page can be built against them before it exists.
| Test | What it pins |
|---|---|
| Envelope, 4 payloads | The five keys exist, rows == data.size(), source names the engine, generatedAt is an ISO instant. |
| Aggregation shape, 3 payloads | Each row has a key, a positive contratos, and valor as a JSON number — the page plots it directly. |
| Figures still true | 71,901 contracts in 2024 · 2,018 text matches · 29 distinct years. A SQL change that moves an answer breaks the build. |
mvn test → 8 tests, 0 failures.
All four endpoints return numbers identical to a direct query on 9030. The application refuses to start without its credentials (exit 1, named variables) and starts when they are present. With the engine unreachable it answers 503 with a body that names the engine, not a stack trace. The read-only user is proven read-only. The JSON contract is frozen in fixtures with three figures pinned. Credentials live nowhere in the repository.
Not in this phase: the React page (Phase 9) and the compose packaging (Phase 10). The API currently runs as a container on the lab network, started by hand; making that one command is F10's job.