Skip to content

Sachin/adding draft mode - #1

Merged
sachin-panayil merged 8 commits into
mainfrom
sachin/adding-draft-mode
Aug 24, 2026
Merged

sachin-panayil merged 8 commits into
mainfrom
sachin/adding-draft-mode

Conversation

@sachin-panayil

Copy link
Copy Markdown
Contributor

Split merging from validation and add draft mode

Problem

assembleWith did two things at once. it merged baseline → existing → observed → derived into one document, and then it validated that document and threw CodeJSONValidationError if anything was missing. Merging was welded to enforcing, so the only way to get a merged result was to have a complete, schema-valid one.

That doesn't fit every caller. A generator that scrapes a repository can only observe some fields so the rest come back at their baseline values for someone to fill in later. Producing a partial code.json for someone to finish is a valid outcome, not a failure, but the library had no way to express it so callers either got a valid file or an exception.

Solution

Split assemble.ts into two layers. mergeWith does steps 1 to 3. assembleWith is now mergeWith plus validation.

Result

Callers pick their contract. assemble still means "give me a finished file or throw" while draft means "give me whatever the merge produced". Callers that want both can draft and then run validate on the result to report what's missing without throwing. Drafts written to disk now keep every baseline key, including the blank enums, so the fields a human has to fill in are visible in the file.

Test Plan

  • run bun test

@sachin-panayil
sachin-panayil merged commit f2ff25d into main Aug 24, 2026
7 checks 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.

1 participant