feat: T4 wave 4 - rules suggest, takeover, chains, autopilot A1-A3, suggestions page, varroa bands UI

- Automation rules propose suggestions instead of creating tasks;
  notify per rule config; corrected varroa measurements refresh or
  resolve their suggestion
- Inspection values can be taken over into the colony card
  (occupiedFrames 0-40, strength deprecated); warning counts use the
  same visibility rule as the notification list
- Biotech chains: swarm check after queen cells, queen acceptance
  check, split schedules (raise own, queen cell, queen)
- Season autopilot core with A1 inspection due, A2 varroa measurement,
  A3 recheck after treatment; colony sync and daily step
- Frontend: suggestions page with groups, bulk accept, undo, paging,
  focus management and permission gating
- Frontend: varroa traffic light from seasonal bands, sample size,
  one range request for the colony chart
- Notifications: mark-read answers 404 for rows the user may no
  longer see

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 15:22:36 +02:00
1 parent 64a2b7dad9
commit 02eb16924e
142 files changed
+11847 -1251

No files matched your search

+29 -19
View File
@@ -86,28 +86,30 @@ describe('Colonies (e2e)', () => {
raceColonyId,
...splitColonyIds,
].filter(Boolean);
// Rule tasks are written without a user - their audit entry and
// TaskCreated are not covered by the userId cleanup below.
const ruleTaskIds = (
await prisma.task.findMany({
where: { relatedId: { in: colonyIds } },
// Rule suggestions are written without a user - their audit entry and
// warning are not covered by the userId cleanup below.
const suggestionIds = (
await prisma.suggestion.findMany({
where: { colonyId: { in: colonyIds } },
select: { id: true },
})
).map((task) => task.id);
).map((suggestion) => suggestion.id);
await prisma.auditLog.deleteMany({
where: { entityType: 'Task', entityId: { in: ruleTaskIds } },
where: { entityType: 'Suggestion', entityId: { in: suggestionIds } },
});
await prisma.domainEvent.deleteMany({
where: { aggregateType: 'Colony', aggregateId: { in: colonyIds } },
});
await prisma.notification.deleteMany({
where: {
OR: [
{ aggregateType: 'Colony', aggregateId: { in: colonyIds } },
{ aggregateType: 'Task', aggregateId: { in: ruleTaskIds } },
{ relatedId: { in: colonyIds } },
{ relatedType: 'Suggestion', relatedId: { in: suggestionIds } },
],
},
});
await prisma.task.deleteMany({ where: { id: { in: ruleTaskIds } } });
await prisma.notification.deleteMany({
where: { relatedId: { in: colonyIds } },
await prisma.suggestion.deleteMany({
where: { id: { in: suggestionIds } },
});
await prisma.colonyLineage.deleteMany({
where: { OR: [{ fromColonyId: colonyId }, { toColonyId: colonyId }] },
@@ -330,7 +332,7 @@ describe('Colonies (e2e)', () => {
expect(colony.status).toBe('WEAK');
});
it('creates the COLONY_HEALTH_CRITICAL task only after the event is processed, and only on the transition', async () => {
it('proposes the COLONY_HEALTH_CRITICAL check only after the event is processed, and only on the transition', async () => {
const created = await request(app.getHttpServer())
.post('/api/v1/colonies')
.set('Authorization', `Bearer ${beekeeperToken}`)
@@ -356,15 +358,19 @@ describe('Colonies (e2e)', () => {
to: { status: 'ACTIVE', healthStatus: 'CRITICAL' },
});
expect(
await prisma.task.count({ where: { relatedId: healthColonyId } }),
await prisma.suggestion.count({
where: { colonyId: healthColonyId, ruleKey: 'COLONY_HEALTH_CRITICAL' },
}),
).toBe(0);
await drainDomainEvents(app, [healthColonyId]);
expect(
await prisma.task.count({ where: { relatedId: healthColonyId } }),
await prisma.suggestion.count({
where: { colonyId: healthColonyId, ruleKey: 'COLONY_HEALTH_CRITICAL' },
}),
).toBe(1);
// Already critical: a further edit is no transition and opens no second task.
// Already critical: a further edit is no transition and proposes nothing a second time.
await request(app.getHttpServer())
.patch(`/api/v1/colonies/${healthColonyId}`)
.set('Authorization', `Bearer ${beekeeperToken}`)
@@ -372,11 +378,13 @@ describe('Colonies (e2e)', () => {
.expect(200);
await drainDomainEvents(app, [healthColonyId]);
expect(
await prisma.task.count({ where: { relatedId: healthColonyId } }),
await prisma.suggestion.count({
where: { colonyId: healthColonyId, ruleKey: 'COLONY_HEALTH_CRITICAL' },
}),
).toBe(1);
});
it('two concurrent PATCHes into CRITICAL produce one transition event and one task', async () => {
it('two concurrent PATCHes into CRITICAL produce one transition event and one suggestion', async () => {
const created = await request(app.getHttpServer())
.post('/api/v1/colonies')
.set('Authorization', `Bearer ${beekeeperToken}`)
@@ -405,7 +413,9 @@ describe('Colonies (e2e)', () => {
).toBe(1);
await drainDomainEvents(app, [raceColonyId]);
expect(
await prisma.task.count({ where: { relatedId: raceColonyId } }),
await prisma.suggestion.count({
where: { colonyId: raceColonyId, ruleKey: 'COLONY_HEALTH_CRITICAL' },
}),
).toBe(1);
});
});