Skip to content

Conversation

@tumbledwyer
Copy link
Contributor

Also fixed only reverse engineering corrections with an approval

Fixed only reverse engineering corrections with an approval
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the DECLARATION_UPDATED action (Update action) and fixes the reverse engineering logic to only apply to corrections that have been approved. The changes include:

  • Implementation of the Update action that creates a new DECLARE action with input/output tracking
  • Refactored postProcess function to track approved corrections and only reverse engineer when corrections are approved
  • Removed the full declaration from correction annotations to fix reverse engineering behavior
  • Added comprehensive test coverage for updates, corrections without approval, and mixed scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
v1-to-v2-data-migration/tests/unit/postProcess.test.ts Added test cases for Update actions, corrections without approval, and mixed scenarios; also added approval actions to existing correction tests to validate the new approval-based reverse engineering logic
v1-to-v2-data-migration/helpers/transform.ts Implemented DECLARATION_UPDATED handling, refactored postProcess to track approved corrections, removed declaration spreading from correction annotations, and updated postProcess signature to accept current declaration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

})

const result = transform(registration, birthResolver, 'birth')
console.log(JSON.stringify(result, null, 2))
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This console.log statement should be removed before merging to production. Debug logging statements should not be committed to the codebase.

Suggested change
console.log(JSON.stringify(result, null, 2))

Copilot uses AI. Check for mistakes.
const birthResolver = buildBirthResolver()

await t.step(
'should set annotation to previous declaration and reverse enngineer the original declaration',
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: 'enngineer' should be 'engineer'.

Copilot uses AI. Check for mistakes.
action.declaration = previousDeclaration
if (hasKeys(annotation)) {
previousDeclaration = deepMerge(previousDeclaration, annotation)
action.annotation = deepMerge(previousDeclaration, annotation)
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 549 merges annotation into previousDeclaration again after it was already merged on line 548. This appears to be a logic error. After line 548 updates previousDeclaration, line 549 should likely just assign previousDeclaration to action.annotation without merging annotation again. The current implementation would merge the annotation values twice, which is redundant and may produce incorrect results.

Suggested change
action.annotation = deepMerge(previousDeclaration, annotation)
action.annotation = previousDeclaration

Copilot uses AI. Check for mistakes.
corrections.push({ index: i, action: documents.actions[i] })
}
}
const approvedCorrections = []
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approvedCorrections array should have an explicit type annotation. Since it stores requestId values which can be string or undefined according to the Action interface, it should be typed as Array<string | undefined> or the push operation on line 528 should guard against undefined values.

Suggested change
const approvedCorrections = []
const approvedCorrections: Array<string | undefined> = []

Copilot uses AI. Check for mistakes.
@tumbledwyer tumbledwyer merged commit 1cb9de6 into main Dec 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants