fix(extract): check every document before writing, including targets they share (#43) - #53
Merged
Merged
Conversation
|
The changes in this PR will be included in the next version bump.
|
|
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.


Closes #43
Summary
Previously,
extractwith several documents planned and wrote one document at a time. Now every document is checked before any is written:sharedTargetErrors()(invalidate.ts) groups blocks from different documents by resolved target, sosrc/x.tsand./src/../src/x.tsare one file. It applies the existingtargetConflict()rule, now generalised: only distinctregion=values in one language may share a file. Each error carries itsdocument. Blocks already invalid in their own document are left out, so nothing is reported twice.mdcode validate --for extractwith several documents runs the same check and marks those blocksvalid: false.validate --for extractruns the cross-document check too, so it's still a faithful preflight.Evidence
docs/a.md→src/x.ts;docs/b.md→src/y.tsandsrc/x.ts:extractexited 2 and wrotesrc/x.ts(a.md's version) andsrc/y.ts, then skipped b.md'ssrc/x.tswith "exists… Use --force". Which version won depended on document order.validate --for extractpassed both documents (exit 0).extractexits 1 and writes nothing:validate --for extractexits 1 with anambiguous_targeterror for each document.New tests in
packages/usage/tests/validate.test.ts→ "extract across several documents":documentset andvalid: false.src/y.ts.docs/a.mdwas already written.region=, or different languages, across documents are refused, and the messages are checked exactly.pnpm checkpasses (pre-push).Merge Danger
Door: two-way
Blast Radius: extract
Multi-document
extractruns that used to finish withextract_skipped(exit 2) now refuse up front (exit 1). That includes anonymous blocks: two documents that each produceblock-1.shnow conflict, and--ignore-anonymousavoids it. Single-document runs are unchanged. The bump file is markedminor.