fix(FN-4811): persist done-task integrity warnings across engine restarts

The periodic self-healing sweep at
SelfHealingManager.reconcileDoneTaskIntegrity() emits a single
'Integrity warning: done-task finalize evidence is unproven (<reason>)' log
entry per task when the task is in 'done' but has no provable on-main
evidence. Dedup was via an in-memory finalizeUnprovenWarned Set per manager
instance, so every engine restart resurfaced the same warning on the next
sweep — significant noise on done tasks that legitimately lack evidence,
typically residue of FN-4811 contamination (FN-4771/FN-4778 in production).

Adds an optional MergeDetails.integrityWarning = { warnedAt, reason } field
and persists it on the first warning. Both warning sites in
reconcileDoneTaskIntegrity() (the unproven-and-still-mergeable branch and
the unproven-final branch) now consult the persisted record:

  - Same reason as persisted → skip re-emitting, just rehydrate the in-memory
    Set for in-process consistency.
  - Different reason → re-warn (so a *new* classification problem still
    surfaces) and update the persisted record.

Tests added under
packages/engine/src/__tests__/reliability-interactions/integrity-warning-persisted-dedup.test.ts
(real-git, 4 cases):

  - First sweep: emits warning + persists record.
  - Second sweep, same instance: in-memory Set dedupes (existing contract).
  - Fresh manager (simulated engine restart) + pre-persisted record:
    persisted dedup suppresses re-emission.
  - Fresh manager + persisted record with different reason: must re-warn
    and overwrite the persisted reason.

Full engine suite: 308 files, 5041 tests pass, 1 skipped. Lint clean.

Fusion-Task-Id: FN-4811
This commit is contained in:
Fusion
2026-05-16 16:51:43 -07:00
parent ba8e912aa8
commit f4aa6d7b8b
4 changed files with 293 additions and 2 deletions

View File

@@ -1217,6 +1217,21 @@ export interface MergeDetails {
resolutionMethod?: "ai" | "auto" | "mixed" | "theirs" | "ours" | "abort";
attemptsMade?: 1 | 2 | 3;
autoResolvedCount?: number;
/**
* FN-4811 follow-up: persisted record of a done-task finalize-integrity warning.
* When set, the periodic integrity sweep skips re-emitting the same warning across
* engine restarts — the in-memory `finalizeUnprovenWarned` Set is volatile and would
* otherwise spam the log every time the sweep ran on a fresh process.
*
* `warnedAt` is the ISO timestamp of the first warning; `reason` is the classifier
* reason (e.g. "missing-evidence", "foreign-start-point", "no-owned-commit-foreign-deltas").
* Clear this field when the task evidence is later proven (e.g., via
* `task:integrity-reconcile-modified-files` repair path).
*/
integrityWarning?: {
warnedAt: string;
reason: string;
};
}
/** Represents an agent's checkout lease on a task. */