File size: 4,985 Bytes
d2d1903 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | # ARCHITECTURE โ ืืื ื ืืืขื
ืืืื ื ืฉืืืื ืโmonorepo ืืชืื ืก. `core/` (+`config`/`calibration`/`pipeline`),
`verticals/logistics/` ืโ`harness/` ืืืจ ืืืื ื ืืืขื; `infra/` ืโ`delivery/`
ืขืืืื ืโ`legacy/` ืืืืืจืืช ืืฉืืืื ืืืืื (`MIGRATION_MAP.md`).
## ืขืงืจืื ืื ืื
ืชืืืช ืืืจืืช ืืืืืื ืืื ืืืื:
```
core โ verticals โ infra โ delivery
โฒ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
delivery ื-infra ืืฉืชืืฉืื ื-core; core ืื ืืืืข ืขื ืืฃ ืืื ืืื
```
`core/` ืืกืืจ ืฉืึตืืข ืขื ืฉืื ืฉืืื ืืืจืช. ืื ืืฉืื ืโ`core/` ืฆืจืื ืืืืื ืโ`infra/`
ืื ืโ`verticals/` โ ืืื ืื ืฉืืื ืโ`core/`.
## ืืฉืืืืช
### `core/` โ ืืืืื ืืื ืืืืืช โ
ืืืืจ ื-Stage 0
ืืืื ืื ืชืื ืื ืืงื ืื ื ืืืืชืืืืงื ืืืืจืืื ืืกืืืช. stdlib ืืืื, ืืื I/O, ืืื state.
- `events.py` โ `CanonicalEvent`
- `state.py` โ `EntityState`
- `ontology.py` โ `Entity`, `ENTITY_TYPES`
- `signals.py` โ ฮ, ฯ, ฮพ, ฮณ, ฮบ, ฮฉ (signal math)
- `drift.py` โ `DriftIssue`, `drift_score`, `severity_from_score`
- `decisions.py` โ `DecisionItem`, `recommendation_for_issue`
ืื ืืฉืืื ืืืืืื ืฉืืืืืช ืืืืืช ืืืืกื ืโ100% ืืืืืงืืช correctness ืืืืชืืืช.
ืืืื: 36 ืืืืงืืช, ืืืื ืืืืงืช leadโtime ืืื ืืืจืืืืืช (`tests/test_core_integration.py`).
### `verticals/` โ adapters ืืื ืืื โ
Stage 1 (logistics)
adapter ืขืืฉื ืขืืืื ืืืช: ืืืคื ืกืืื ืืืืืืช ืฉื ืืงืื ืโcanonical events/metrics
ืฉโ`core/` ืืืื. **ืฉืื ืืืืืงื ืื ืืืืืช ืโadapter** โ ืืื ืชืจืืื ืืืื.
`logistics/` ืืื ืโadapter ืืจืืฉืื (`config.yaml` + `adapter.py`).
`team_drift_detector.py` ืืืืจ ืืืื โ detector, ืื core, superseded ืข"ื ืืฆืื ืืจ ืืื ืจื.
### `harness/` โ harness ืืืืืช โ
Stage 2
ืืืืื ืชืจืืืฉืื ืืชืืืืื ืืืืื ืืช ืืื ืืข ืืื ground truth: precision, recall,
detection delay, leadโtime. ืชืืื ืโ`core/` ืืืื. ืื ืฉืขืจ CI ืืื ืืืื ืฉื ืืืืฆืจ
(`python -m harness`).
### `infra/` โ ืฉืืืช ืชืฉืชืืช (Stage 3, ืืคืจืืกืืช)
**3a โ
** `infra/storage/` โ ืืืกืื: tenants, calibrations, runs (SQLite ืืืื,
ืโ`Database` ืโ`db.py` ืืื ืโseam ืโPostgres). `infra/service.py` โ
`OrgStateService`, ืฉืืืช ืืชืืืืจ ืฉืืืืจืช `core` ืโ`storage`.
**3b โ
** `infra/api/` โ shell ืืง ืฉื HTTP: `handlers.py` (ืืืืืงื ืืืืจื, ืืื
fastapi), `errors.py` (ืืืื ืฉืืืืืช), `app.py` (ืืืืื FastAPI). ืืฉืจืฉืจืช:
FastAPI app โ handlers โ OrgStateService โ core+storage.
**3c โ
** `infra/ingestion/` โ `connectors.py` (`Connector` ABC,
`InMemoryConnector`, `CSVFolderConnector`, `build_connector`) +
`scheduler.py` (`Schedule` ื ืฉืืจ, `is_due`/`due_schedules` ืืืืจืื,
`IngestionService`, `run_scheduler` loop ืืง). connector = "ืืืืคื ืืืืื",
ืโadapter ืขืืืื ืืขื ืืืคืื ืืกืืื.
**3d โ
** `infra/deployment/` โ `settings.py` (`RuntimeSettings` ืโenv),
`observability.py` (logging ืืืื ื JSON), `scheduler_service.py` (entry point
ืฉื ืโworker). `Dockerfile` + `docker-compose.yml` ืืจืืช ืโrepo โ api ืโscheduler
ืืฉื ื processes ืขื image ืืื ืฉืืืืงืื DB ืืื ืืจื `ORGSTATE_DB_PATH`.
ื ืืชืจ: auth/RBAC (`auth_*.py`) ืโbackend Postgres โ ืคืจืืกืืช ื ืคืจืืืช ืืจื ืโseam.
### `delivery/` โ ืคืื ืืื ืืงืื (Stage 4)
ืืื ื ืืืืื, ืชืืจ ืืืืืืช, evidence views, ืืฉืืืจืืื, branded report builder,
PDF export. ืืืื ืโ`legacy/`: `customer_report_builder.py`,
`executive_audit_report_builder.py`, `branded_report_builder_v31.py`,
`*_dashboard*.py`, `evidence_view_builder.py`, `pdf_exporter_v28.py`.
## ื ืชืื ืื ืชืื ืื (ืืฉืืืื ื ืืืฉืื)
```
ืืงืืจ ืืืื ืฉื ืืงืื
โ verticals/<vertical> (ืืืคืื ืกืืื โ CanonicalEvent)
โ core (EntityState โ signals ฮฯฮพฮณฮบ โ ฮฉ โ drift_score โ DecisionItem)
โ infra (persist, schedule, serve via API)
โ delivery (executive report, decision queue, evidence view)
```
## ืืืืืืช ืืื ื ืืืืขืืช
- **`infra/` ืืื `platform/`** โ `platform` ืืฆื ืขื ืืืืื stdlib ืืฉื ืื.
- **`core/` ืืื ืชืืืืืช** โ ืืื ืฉืืืืืงืืช ืืืื ืืืืจืืช, ืืฉืื ืืคืฉืจ ืืืื
"ืืืืจืื" I/O ืื state ืืชืื ืืืืื.
- **`legacy/` ื ืฉืืจ ืจืฅ** โ ืื ืืฉืืจืื ืืืื. ืื ืฉืื ืืืืจ ืจืืื, ืืืืืฃ ืืช
ืโimport, ืืืืืง ืืช ืืืงืืจ ืโ`legacy/` ืจืง ืืฉืืืืืงืืช ืืจืืงืืช.
|