Skip to content

VxCentralScan: improve Importer correctness#8215

Merged
eventualbuddha merged 10 commits intomainfrom
fix/central-scan/improve-importer
Apr 1, 2026
Merged

VxCentralScan: improve Importer correctness#8215
eventualbuddha merged 10 commits intomainfrom
fix/central-scan/improve-importer

Conversation

@eventualbuddha
Copy link
Copy Markdown
Contributor

Overview

Refs #8041

Before making structural changes to VxCentralScan to support interpreting while scanning, I wanted to improve the foundation a bit. This PR fixes a few issues Claude and I found while perusing Importer. Mostly they're edge case handlng, but could represent real correctness issues.

Demo Video or Screenshot

n/a

Testing Plan

Existing automated tests.

`interpretSheet` either returns `Ok` or throws, so the `Result` is
superfluous. The error check also threw anyway, to no effect. Removes
the dead code.
There's no good reason to mutate the workspace state in `continueImport`
if there is no scanning job in progress.
This method recurses, adding a stack frame for each iteration. This
could theoretically be a problem if it waits a long time. Since there's
no real benefit to the recursive version over a `while` loop, I'm
switching to the latter.
If `finishBatch` were called again during one of the function's
`await`s, it would not exit immediately since `currentBatch` has not yet
been cleared, causing it to try to end the batch and remove the batch
directory multiple times. Clearing `currentBatch` right away ensures
that any re-entrant calls bail early.
Rather than just silently ignoring the error or a subsequent
`finishBatch` error, log the errors as scan batch failures.
- It isn't re-entrant, so calling it again during its run would cause
invalid state.
- It wouldn't clean up the batch in the db or the scan target directory
if anything failed before setting `this.currentBatch`.
Copy link
Copy Markdown
Contributor

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 improves correctness and edge-case handling in VxCentralScan’s backend Importer to better support future structural changes (e.g., interpreting while scanning) by tightening batch lifecycle management and error handling.

Changes:

  • Simplifies interpretSheet to return the direct interpretation result (instead of a Result wrapper that couldn’t actually represent failures).
  • Adds protection and cleanup for batch startup failures (isStartingBatch, partial setup cleanup, and improved failure handling).
  • Improves scanning continuation robustness (explicit “no current batch” checks, better failure logging, non-recursive polling loop in test helper).

@eventualbuddha eventualbuddha marked this pull request as ready for review March 30, 2026 23:43
@eventualbuddha eventualbuddha requested a review from kshen0 March 30, 2026 23:44
Verifies that `finishBatch` clears `this.currentBatch` before async
cleanup (endBatch, fsExtra.remove), preventing concurrent calls from
doing duplicate work.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@eventualbuddha eventualbuddha enabled auto-merge (squash) April 1, 2026 16:31
@eventualbuddha eventualbuddha merged commit e495fb2 into main Apr 1, 2026
58 checks passed
@eventualbuddha eventualbuddha deleted the fix/central-scan/improve-importer branch April 1, 2026 16:37
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