feat(dawarich): fetch daily movement values from a Dawarich instance

Connect, status, places, settings, test, sync and disconnect replace their
stubs. A nightly job (03:20) and the connect backfill read the timeline,
visits and residency endpoints through safeFetch and store one row of daily
values per local day: distances, places visited, minutes away from the home
place and the sealed country with its travel-day verdict. A private instance
needs its exact origin in DAWARICH_PRIVATE_ORIGINS.

The connection joins the shared ledger and the connection health model,
watched for errors only. The day carries a movement block, the model
projection drops the travel country, the two movement channels join the
correlation matrix under the environment module, travel days become trip
suggestions, and the days travel in the environment backup section.
This commit is contained in:
Marc-André Bombeck committed 2026-10-16 01:20:53 +02:00
1 parent 1e7fc08f57
commit b838ed4403
95 files changed
+4466 -158

No files matched your search

+3
View File
@@ -113,6 +113,8 @@ export interface BackupSummary {
environmentContexts: number;
/** Declared stretches spent away from home. */
environmentTravelLocations: number;
/** Local days of Dawarich movement values. */
dawarichDays: number;
/** ECG strips, with their rhythm verdict and their trace. */
ecgRecordings: number;
}
@@ -209,6 +211,7 @@ export function summarizeBackup(payload: BackupPayload): BackupSummary {
userAchievements: payload.userAchievements.length,
environmentContexts: payload.environmentContexts.length,
environmentTravelLocations: payload.environmentTravelLocations.length,
dawarichDays: payload.dawarichDays.length,
ecgRecordings: payload.ecgRecordings.length,
};
}
+34
View File
@@ -1651,6 +1651,37 @@ const environmentTravelLocationBackupSchema = z
})
.passthrough();
/**
* v1.43 — one local day of Dawarich movement values. Daily values only; the
* country rides readable (portable) or sealed (disaster recovery).
*/
const dawarichDayBackupSchema = z
.object({
date: environmentDayKey,
totalDistanceM: z.number().int().nonnegative().nullable().optional(),
drivingDistanceM: z.number().int().nonnegative().nullable().optional(),
trainDistanceM: z.number().int().nonnegative().nullable().optional(),
placesVisited: z.number().int().nonnegative().nullable().optional(),
awayFromHomeMinutes: z
.number()
.int()
.min(0)
.max(25 * 60)
.nullable()
.optional(),
countryCode: z
.string()
.regex(/^[A-Z]{2}$/)
.nullable()
.optional(),
countryCodeEncrypted: base64BytesSchema.nullable().optional(),
isTravelDay: z.boolean().nullable().optional(),
fetchedAt: isoDateTime.optional(),
createdAt: isoDateTime.optional(),
updatedAt: isoDateTime.optional(),
})
.passthrough();
/**
* A turn's stored tables, bounded at restore. The live path never stores more
* than `RESULTS_MAX_BYTES` of table JSON per turn (`fitResultsToStorage`), so
@@ -2293,6 +2324,9 @@ export const backupPayloadSchema = z
environmentTravelLocations: z
.array(environmentTravelLocationBackupSchema)
.default([]),
// v1.43 — the Dawarich movement days, restored with the environment
// section. A file written before them carries no key.
dawarichDays: z.array(dawarichDayBackupSchema).default([]),
// The ECG strips. Defaulted for the same reason as the sections above: a
// file written before the recordings travelled carries no key, and an
// account whose watch has never taken one writes [].