feat: platform backbone and field capture complete (checkpoint)

Platform backbone (plan 2026-10-13-plattform-rueckgrat), all tasks reviewed:
- webhooks with delivery table, retries and stable delivery id
- calendar handlers; a finished task removes its Outlook event
- tasks, automations, inspections, varroa, treatments, feedings,
  harvests, colonies, wintering, stock and bottling record domain events
  in the same transaction; legacy post-commit calls removed
- row locks through one helper (lockRowForUpdate, lockRowsForShare,
  lockRowsForUpdate)
- job framework with JobRun, cli exit codes, cleanup, task templates,
  daily evaluation, hourly app-backup and the rekey job
- system API and page "Verwaltung > System" with retry
- @nestjs/schedule removed, guard tests against in-process schedulers

Field capture T3 (plan 2026-10-13-t3-erfassung-am-stand), all tasks reviewed:
- inspection photo offline without metadata
- bulk capture for treatments, feedings and varroa (backend + frontend)
- offline stand mode with service worker, offline pages and packs
- offline session, cold start and logout on shared devices

Docs: ARCHITECTURE.md assumptions and sections updated, TASKS.md.
Gates: backend lint, typecheck, 1770 unit, 420 e2e, build, no schema
drift; frontend lint, typecheck, 913 tests, build. Not rolled out.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Nick SzaunigandClaude Opus 5.5 committed 2026-10-14 11:36:38 +02:00
1 parent c01a38835a
commit cdd30cf3ee
288 files changed
+39165 -2853

No files matched your search

@@ -0,0 +1,86 @@
import { readdirSync, readFileSync } from 'node:fs';
import { join, relative, sep } from 'node:path';
// Side effects run through the domain-event backbone. runAfterCommit and the
// direct wrappers stay only for the legacy paths that have no event yet
// (ARCHITECTURE assumption 11). A new caller must record an event instead.
const SRC = join(__dirname, '..');
const DEFINITION = 'common/after-commit.ts';
function productionSources(dir: string): string[] {
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
const path = join(dir, entry.name);
if (entry.isDirectory()) {
return productionSources(path);
}
return entry.name.endsWith('.ts') && !entry.name.endsWith('.spec.ts')
? [path]
: [];
});
}
function withoutComments(source: string): string {
return source.replace(/\/\*[\s\S]*?\*\//g, '').replace(/^\s*\/\/.*$/gm, '');
}
function filesCalling(call: string): string[] {
return productionSources(SRC)
.filter((file) =>
withoutComments(readFileSync(file, 'utf8')).includes(call),
)
.map((file) => relative(SRC, file).split(sep).join('/'))
.filter((file) => file !== DEFINITION)
.map((file) => `src/${file}`)
.sort();
}
describe('legacy after-commit paths', () => {
it('runAfterCommit is only used by the remaining legacy paths', () => {
expect(filesCalling('runAfterCommit(')).toEqual([
'src/automation/automation.service.ts',
'src/calendar-sync/calendar-sync.service.ts',
'src/webhooks/webhooks.service.ts',
]);
});
it('only the queen assignment still enqueues a calendar entry directly', () => {
expect(filesCalling('calendarSync.enqueue(')).toEqual([
'src/queens/queens.service.ts',
]);
});
it('only the modules without an event still dispatch webhooks directly', () => {
expect(filesCalling('webhooks.dispatch(')).toEqual([
'src/colonies/colonies.service.ts',
'src/honey-batches/honey-batches.service.ts',
'src/queens/queens.service.ts',
'src/storage/storage.service.ts',
]);
});
it('no longer defines the removed post-commit automation wrappers (only SWARM_MOOD_HIGH and STOCK_ITEM_LOW keep one)', () => {
const removed = [
'evaluateInspection',
'evaluateVarroaMeasurement',
'evaluateTreatment',
'evaluateFeeding',
'evaluateColonyHealth',
'evaluateRawMaterialLow',
].map(
(name) =>
[
name,
new RegExp(
String.raw`\b(?:public\s+|private\s+)?async\s+${name}\s*\(`,
),
] as const,
);
const definitions = productionSources(SRC).flatMap((file) => {
const source = withoutComments(readFileSync(file, 'utf8'));
return removed
.filter(([, pattern]) => pattern.test(source))
.map(([name]) => name);
});
expect(definitions).toEqual([]);
});
});