Skip to content

Commit e425e0c

Browse files
authored
Merge pull request #37 from 777genius/fix/review-v2-live-lifecycle
fix(review): preserve lifecycle targets in partial projections
2 parents 8e4ef41 + e553bdb commit e425e0c

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

__tests__/unit/review-projection/build-current-review-projection.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,14 @@ describe('BuildCurrentReviewProjection', () => {
300300
CheckConclusion.Neutral
301301
);
302302
expect(result.envelope.publishing.inlineReviewChunks).toEqual([]);
303-
expect(result.envelope.publishing.lifecycle).toEqual([]);
303+
expect(result.envelope.publishing.lifecycle).toEqual([
304+
expect.objectContaining({
305+
targetId: 'target-1',
306+
threadId: 'thread-1',
307+
mutationEligible: false,
308+
reasonCodes: expect.arrayContaining(['partial_coverage']),
309+
}),
310+
]);
304311
expect(result.envelope.snapshot).toEqual({
305312
occurrenceProvenance: [],
306313
lineageHints: [],

src/review-projection/application/build-current-review-projection.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,17 @@ export class BuildCurrentReviewProjection {
160160
const coverageOnly = coverage.state === ProjectionCoverageState.Partial;
161161
const allClear =
162162
!coverageOnly && canClaimAllClear(coverage, inventory, occurrences, gate);
163-
const lifecycleFacts = coverageOnly
164-
? []
165-
: buildLifecycleFacts(
166-
inventory,
167-
lifecycleDecisions,
168-
command.priorLineageHints,
169-
coverage,
170-
occurrences
171-
);
163+
// Preserve target identities even for partial coverage so the control plane
164+
// can prove that live lifecycle state is still the state this projection saw.
165+
// buildLifecycleFacts already makes every partial-coverage target ineligible
166+
// for mutation.
167+
const lifecycleFacts = buildLifecycleFacts(
168+
inventory,
169+
lifecycleDecisions,
170+
command.priorLineageHints,
171+
coverage,
172+
occurrences
173+
);
172174
const inlineChunks = coverageOnly
173175
? []
174176
: buildInlineChunks(occurrences, this.limits);
@@ -476,7 +478,7 @@ function buildInlineChunks(
476478

477479
assertWithinProjectionLimit('maxInlineComments', comments.length, limits);
478480
const chunks: ReviewProjectionInlineChunkFact[] = [];
479-
for (let offset = 0; offset < comments.length; ) {
481+
for (let offset = 0; offset < comments.length;) {
480482
const chunkComments = comments.slice(
481483
offset,
482484
offset + limits.maxInlineCommentsPerChunk

0 commit comments

Comments
 (0)