refactor(reconcile): extract provider-agnostic core primitive (#20) - #38
Merged
Merged
Conversation
Pulls the GitHub-agnostic reconcile machinery into src/reconcile/core.ts: change-set model, generic diffFields + diffCollection (selective-by- omission + ownership-gated deletes), summarize/render, and the guardrail framework (resolveRenames, removalDeltaCap, runGuardrailChecks). diff.ts and guardrails.ts now consume + re-export it (public API unchanged); the uniform collection diffs (members, team members/repos, rulesets, environments, secrets, variables) are rewritten on diffCollection, net-removing ~430 lines of duplication. core surface exported from index. This is the seam to lift into @intentius/chant's ./reconcile subpath when a second git-host warden exists; until then warden consumes it locally. +18 core unit tests (468 total). Action bundle rebuilt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Re #20. Does the in-repo abstraction now (the substantive engineering); the cross-repo lift into
@intentius/chantis the remaining mechanical step (see note below).What
Extracts the GitHub-agnostic reconcile machinery into
src/reconcile/core.ts— the provider-agnostic primitive #20 describes:ChangeKind,FieldChange,ChangeSetEntry,ChangeSet,DiffOptions)deepEqual,diffFields, anddiffCollection— the selective-by-omission + ownership-gated-delete pattern that every keyed-collection diff sharedsummarizeChangeSet,renderChangeSetresolveRenames,removalDeltaCap,runGuardrailChecks(pluggable checks)diff.tsandguardrails.tsnow consume and re-export core (public API unchanged — all existing imports keep resolving). The GitHub-specific layer stays put: thediff()entry point,Live*types, the bespoke object/embedded-child diffs, and the member-aware guardrails (adminFloor/requiredAdmins/requireSelf).Consolidation
The uniform collection diffs — members, team-members, team-repos, rulesets, environments, secrets, variables — are rewritten on
diffCollection, net-removing ~430 lines of near-duplicate iterate/create/update/ownership-delete code. Bespoke diffs (org-settings, repo-security, repos/teams with embedded children, dependabot, repo-baseline, token sweeps) keep their shapes but use the core helpers.Why this, and not the chant move
The chant repo is checked out locally but outside this task's working directories, and adding a
./reconcilesubpath there means touching another package + cutting a release for warden to consume via its^0.8.2dep. That's a cross-boundary, hard-to-reverse step I'm not taking unprompted. This PR makes that lift mechanical (copycore.tsinto chant, swap warden's imports) by isolating the seam now. #20 stays open for the actual cross-repo extraction.Verification
npx tsc --noEmitcleannpm testgreen (468 tests; +18 incore.test.ts; all pre-existing tests unchanged and passing)🤖 Generated with Claude Code