Image-to-Text
PyTorch
Safetensors
PEFT
English
remote-sensing
satellite-imagery
earth-observation
change-detection
visual-grounding
image-captioning
visual-question-answering
optical-sar-fusion
sar
multimodal
lora
Instructions to use thundercode/SatQuery with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use thundercode/SatQuery with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
release: add docs/architecture/README.md
Browse files- docs/architecture/README.md +148 -0
docs/architecture/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SatQuery AI — Architecture
|
| 2 |
+
|
| 3 |
+
> This is the index for the architecture reference. Each chapter below is a separate file in this folder.
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
This is the architecture reference for SatQuery AI. It is written as a **hub plus ten deep
|
| 7 |
+
sub-documents**, because the system is large enough that a single file would either be superficial or
|
| 8 |
+
unreadable.
|
| 9 |
+
|
| 10 |
+
> **Status vocabulary used everywhere in these docs:** `IMPLEMENTED` (the code exists and runs) ·
|
| 11 |
+
> `VERIFIED` (checked against evidence) · `MEASURED` (a number was produced) · `ATTEMPTED` (tried,
|
| 12 |
+
> outcome recorded) · `NOT RUN` · `BLOCKED` · `DEFERRED` · `REJECTED` (tried and explicitly not
|
| 13 |
+
> accepted) · `OPEN` (known, unresolved) · `RESOLVED` · `CLOSED`.
|
| 14 |
+
>
|
| 15 |
+
> Every substantive claim in this set carries one of these tags, and every non-obvious claim cites
|
| 16 |
+
> the file it came from.
|
| 17 |
+
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
## 1. The thesis in one paragraph
|
| 21 |
+
|
| 22 |
+
SatQuery AI answers natural-language questions about satellite imagery. It is **not** one large
|
| 23 |
+
vision-language model. It is a **router plus specialists** system: a small learned router reads the
|
| 24 |
+
question and decides *which capability* is being asked for; the controller then runs exactly one
|
| 25 |
+
specialist; an evidence engine aggregates what that specialist produced; a confidence stage attaches
|
| 26 |
+
a calibrated (or honestly uncalibrated) number; and the whole thing is returned as one typed
|
| 27 |
+
`ResultEnvelope`. The only trained parameters in the system are six small modules sitting on frozen,
|
| 28 |
+
publicly-pinned backbones.
|
| 29 |
+
|
| 30 |
+
`docs/ARCHITECTURE_FREEZE.md` section 5 gives each layer exactly one verb, and the whole design
|
| 31 |
+
follows from that sentence:
|
| 32 |
+
|
| 33 |
+
> router **understands**; policy engine **decides**; specialists **compute**; VLM **explains**;
|
| 34 |
+
> evidence engine **proves**.
|
| 35 |
+
|
| 36 |
+
## 2. Sub-documents
|
| 37 |
+
|
| 38 |
+
| # | Document | What it covers |
|
| 39 |
+
|---|---|---|
|
| 40 |
+
| 01 | [System overview](01-system-overview.md) | the thesis, the component inventory, the frozen-backbone strategy, what is deliberately absent |
|
| 41 |
+
| 02 | [Deployment topology](02-deployment-topology.md) | the four tiers, the gateway, the outbound tunnel, wake flow, cold start, `transport_mode` |
|
| 42 |
+
| 03 | [Request lifecycle](03-request-lifecycle.md) | the nine-state controller, validation rules, modality inference, tiling |
|
| 43 |
+
| 04 | [Router](04-router.md) | frozen MiniLM, the five-head adapter, `interpret()` vs `chooseTask()`, the lexical fallback, the label space |
|
| 44 |
+
| 05 | [Specialists](05-specialists.md) | all six tasks: entry points, preprocessing, postprocessing, outputs |
|
| 45 |
+
| 06 | [Evidence and confidence](06-evidence-and-confidence.md) | the evidence schema, the aggregation pipeline, temperature scaling, the eight execution events |
|
| 46 |
+
| 07 | [Configuration freeze](07-configuration-freeze.md) | the registry, the enforced invariants, the config hash, why it is frozen |
|
| 47 |
+
| 08 | [API contract](08-api-contract.md) | the four endpoints, the envelopes, error codes, transport headers |
|
| 48 |
+
| 09 | [Frontend](09-frontend.md) | the static pages, the Analyze console, real-vs-preview, platform traps |
|
| 49 |
+
| 10 | [Observability and operations](10-observability-and-ops.md) | health, counters, traces, what is and is not observed |
|
| 50 |
+
|
| 51 |
+
## 3. The system at a glance
|
| 52 |
+
|
| 53 |
+
```mermaid
|
| 54 |
+
flowchart TB
|
| 55 |
+
subgraph Client
|
| 56 |
+
U[Browser]
|
| 57 |
+
end
|
| 58 |
+
subgraph Static["Static tier"]
|
| 59 |
+
CF["Cloudflare Pages<br/>satquery.pages.dev"]
|
| 60 |
+
end
|
| 61 |
+
subgraph Gateway["Gateway tier (Render)"]
|
| 62 |
+
R["satquery-orchestrator<br/>validate · CORS · limits · timeouts · errors"]
|
| 63 |
+
end
|
| 64 |
+
subgraph Inference["Inference tier (GitHub Codespace, CPU)"]
|
| 65 |
+
A["FastAPI · build_space_app()"]
|
| 66 |
+
CTRL["Controller (9-state FSM)"]
|
| 67 |
+
ROUTER["Router<br/>MiniLM + 5-head adapter"]
|
| 68 |
+
SPEC["Specialists<br/>vqa · caption · grounding · change · change_vqa · optical_sar"]
|
| 69 |
+
EV["Evidence engine<br/>dedup · order · renumber · cap"]
|
| 70 |
+
CONF["Confidence<br/>temperature scaling"]
|
| 71 |
+
A --> CTRL --> ROUTER --> SPEC --> EV --> CONF
|
| 72 |
+
end
|
| 73 |
+
U -->|HTTPS| CF
|
| 74 |
+
CF -->|"HTTPS JSON /api/*"| R
|
| 75 |
+
R -->|"outbound long-poll POST /tunnel/agent"| A
|
| 76 |
+
CONF -->|ResultEnvelope| R
|
| 77 |
+
R -->|envelope + error translation| CF
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
## 4. Cross-cutting principles
|
| 81 |
+
|
| 82 |
+
These recur in every sub-document and are the reason the code looks the way it does.
|
| 83 |
+
|
| 84 |
+
### 4.1 One config system, no magic numbers
|
| 85 |
+
|
| 86 |
+
Every tunable value lives in `configs/base.yaml`. The loader (`core/config.py`) validates it against
|
| 87 |
+
the frozen architecture and hashes it. **No number is hard-coded in Python.** This is enforced
|
| 88 |
+
socially and structurally: a reviewer who finds a literal in a specialist has found a bug.
|
| 89 |
+
|
| 90 |
+
### 4.2 Frozen backbones, trained modules
|
| 91 |
+
|
| 92 |
+
No backbone is fine-tuned. `all-MiniLM-L6-v2`, `SmolVLM-500M-Instruct`, `RemoteCLIP ViT-B/32` and
|
| 93 |
+
`CROMA-base` are all pinned **by revision** and fetched from the Hub at run time. What this project
|
| 94 |
+
trains is small: a 50,822-parameter router adapter, four heads, and one LoRA adapter. This is what
|
| 95 |
+
makes the system CPU-runnable.
|
| 96 |
+
|
| 97 |
+
### 4.3 Typed contracts between every layer
|
| 98 |
+
|
| 99 |
+
`core/schemas.py` is the binding contract. No specialist may invent its own result shape; every
|
| 100 |
+
specialist returns a `SpecialistResult`. The schemas carry validators that encode real findings —
|
| 101 |
+
for example `Evidence` **refuses** spatial coordinates without a `coordinate_system`, because a bare
|
| 102 |
+
box is meaningless.
|
| 103 |
+
|
| 104 |
+
### 4.4 Honest degradation over confident fabrication
|
| 105 |
+
|
| 106 |
+
The system is built so that "we could not do this" is representable and preferred to a plausible
|
| 107 |
+
guess. Concretely:
|
| 108 |
+
|
| 109 |
+
- a missing calibration artifact yields `method="uncalibrated"`, `calibrated=None` — **never** a
|
| 110 |
+
fabricated fitted number;
|
| 111 |
+
- a missing optional artifact **degrades** a capability rather than crashing the service;
|
| 112 |
+
- a *corrupt* artifact **raises**, because silently treating a corrupt file as "no file" would hide
|
| 113 |
+
an operational defect;
|
| 114 |
+
- the evidence engine records `dropped_over_limit` rather than silently truncating;
|
| 115 |
+
- the grounding specialist marks a result `degraded` when it produces no localisation.
|
| 116 |
+
|
| 117 |
+
### 4.5 Reproducibility is a structural property
|
| 118 |
+
|
| 119 |
+
`EvidenceEngine.aggregate` is pure and deterministic — no clock, no RNG, no I/O. Evidence ids are
|
| 120 |
+
assigned from *sorted position*, not input order, so the same inputs produce byte-identical output.
|
| 121 |
+
`evidence_digest()` exists so that reproducibility is a test assertion rather than a hope.
|
| 122 |
+
|
| 123 |
+
### 4.6 No chain-of-thought anywhere
|
| 124 |
+
|
| 125 |
+
`ExecutionTrace` records **observable facts only** — states, timings, counts, config hash, model
|
| 126 |
+
refs. There is no field for model reasoning and no LLM-generated confidence. This is a deliberate
|
| 127 |
+
constraint from the architecture freeze, not an omission.
|
| 128 |
+
|
| 129 |
+
## 5. What the system deliberately does not have
|
| 130 |
+
|
| 131 |
+
| Absent | Why |
|
| 132 |
+
|---|---|
|
| 133 |
+
| Database, auth, queue | the gateway is stateless by design |
|
| 134 |
+
| GPU requirement | device is chosen via `SATQUERY_DEVICE`; all placement is `.to(device)` |
|
| 135 |
+
| Gradio GUI | the frontend is a separate static tier; `app/space_app.py` serves JSON only |
|
| 136 |
+
| End-to-end benchmark | none exists; none is claimed |
|
| 137 |
+
| Chain-of-thought | traces carry observable facts only |
|
| 138 |
+
| Backbone redistribution | backbones are fetched, pinned by revision |
|
| 139 |
+
|
| 140 |
+
## 6. Where to start reading
|
| 141 |
+
|
| 142 |
+
- **New to the project** → [01 System overview](01-system-overview.md), then
|
| 143 |
+
[03 Request lifecycle](03-request-lifecycle.md).
|
| 144 |
+
- **Running it** → [`DEPLOYMENT.md`](../DEPLOYMENT.md) and
|
| 145 |
+
[02 Deployment topology](02-deployment-topology.md).
|
| 146 |
+
- **Auditing the numbers** → [`BENCHMARKS.md`](../BENCHMARKS.md) and [`EVALUATION.md`](../EVALUATION.md).
|
| 147 |
+
- **Understanding the router defect** → [04 Router](04-router.md) and
|
| 148 |
+
[`RESEARCH_NOTES.md`](../RESEARCH_NOTES.md).
|