Repository navigation
Conversation
) join-fleet-cases attached a new detection to whichever fleet case already held one of its entities, whatever that case's status, and a merge kept the oldest case's status. Once #12 lets an analyst close a fleet case, a false_positive verdict would carry onto every later detection sharing an entity, and a resolved case would grow silently. Closed means a status outside ACTIVE_CASE_STATUSES (#84): - the entity lookup only matches active cases, so a group whose entities only closed cases hold opens a new case; - detections already on a closed case are left out of the join: never moved, and not counted toward the two agents a group needs; - a closed case is never a merge target or source. The detection link re-checks the status at write time, since the console's status write does not take the cron's lock. FleetCaseEntity becomes unique per (fleetCaseId, kind, key), with an index on (tenantId, kind, key) for the lookup, so the new case can list an entity its closed predecessor keeps. "One active case per entity" is held by the cron under its per-tenant advisory lock. A merge copies entities instead of re-pointing them, so two active cases listing one entity (a reopened case, later) merge without a key clash. Fixes #86 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jihair54 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #86. Draft until @SoFrexs is fine with the design in #86 (comment), chiefly the entity key change below; I'll rework it if not.
What changes. A fleet case whose status is outside
ACTIVE_CASE_STATUSES(#84), that isresolvedorfalse_positive, keeps its detections, entities and status, and stops growing. Inlib/fleet-case-store.ts:upsertGrouponly looks up entities of active cases. A group whose entities only closed cases hold opens a new case, and a closed case is never a merge target or source.withoutJudgeddrops detections already on a closed case beforejoinDetections. They are never moved into the new case, and they do not count toward the two agents a group needs.mergeInto. It copies entities instead of re-pointing them, so two active cases that list one entity (a reopened case, later) merge without a key clash.Schema.
FleetCaseEntitygoes from@@unique([tenantId, kind, key])to@@unique([fleetCaseId, kind, key]), plus@@index([tenantId, kind, key])for the lookup. The@@index([fleetCaseId])is dropped, since the new unique key leads with it. The new case can then list an entity that its closed predecessor keeps, and the console still shows the closed case's entities (fleet-case-load.ts). "One active case per entity and tenant" is now held by the cron under its per-tenant lock.db pushapplies this without data loss, because every existing row stays unique under the new key, which is looser than the old one.Tests (
tests/integration/join-fleet-cases-cron.test.ts, "a closed fleet case (#86)"). The status is set on the row, since nothing writesFleetCase.statusyet:resolvedand forfalse_positive: a later sighting opens a new case standing on the new detections alone (their severity, their two agents). The closed case is byte-for-byte unchanged, and a second run changes nothing;investigatingcase still grows.Tested
docker-compose.test.yml):join-fleet-cases-cronandfleet-cases-consolepass: 23 and 9 tests.lib/fleet-case-store.tsand these tests, 4 of the 5 new tests fail. The one that still passes is "an investigating case still grows", which guards behavior that must not change.cases-detail"does not mark the narrative stale when no detection changed after generation", is flaky on main as well: it failed 1 run out of 3 with main's code, and 2 out of 3 on this branch. It does not touch fleet cases.tsc --noEmitis clean afterprisma generate.eslint: only themax-lines-per-functionwarning onupsertGroup. It is already there on main, and this PR takes it from 72 to 76 lines.server, which includes the integration suite, the cross-OS unit jobs anddco.🤖 Generated with Claude Code