refactor(initcmd): share the apply-planned-writes tail (477.5)#505
Merged
Conversation
…aths (477.5) initApplicationPlan + applyInitApplicationPlan own the identical mutation sequence for interactive commit and non-interactive init: validate, group/ open/preflight/write bundles, save config, then delete stale reviewer keys. Path-specific concerns (API-key checks, overwrite policy, primary- store reuse, summaries, readiness, results, hints) stay at the call sites. The cleanup primitive remains in initcmd: moving it would trade the initStore test seam for new *credstore.Store plumbing or a new interface. Failure ordering is now pinned both ways: a save failure performs no deletions, and a cleanup failure leaves the saved config with byte-exact existing error text.
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 #477 — step 5 of 5, completing the approved Candidate 1 from the design record.
Deduplicates the init application tails, only where they were genuinely identical:
initApplicationPlan+applyInitApplicationPlannow own the shared mutation sequence for both the interactive session commit and non-interactive init — validate, group/open/preflight/write credential bundles, save config, then delete stale reviewer keys. Path-specific concerns (non-interactive API-key checks, overwrite policy, primary-store reuse, interactive summaries, readiness output, results, hints) stay at each call site.The two design-record decisions
internal/credentialswould have required replacing the existinginitStoretest seam with concrete*credstore.Storeplumbing or a new port interface — exactly what the design record said not to introduce.Verification
Zero tests deleted; one strengthened, one added, fake store gained a delete hook. Seven config-show goldens unchanged and passing.
go build,go vet, fullgo test ./...green unsandboxed (60 packages), repo-widegolangci-lint0 issues, architecture harness pass. Production +102/−94 (net +8); +80 test lines.The full #477 arc
config show --jsongoldens (the safety net)Label,DesktopAccountID,Keyring)CredentialRef×4,Profile.SecretsStore), net −229internal/credentials