Repository navigation
refactor!: one way to hold, observe and approve writes - #8
Merged
Merged
Conversation
- Options.Plan becomes Options.HoldWrites. Held writes return *agent.Pending like any write that needs approval, and Result.Planned is removed. - Options.OnCall is removed. OnEvent carries every call, with its input, and taskreport's audit log reads call events. - agent.Apply is removed. Plans are approved through agent.Plans. - codemode.WithApproval(ctx) replaces setting Recorder.Approved, which is now unexported. - Call.Planned is renamed Held, and Recorder.Pending() is renamed Held(). None of these were released.
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.
Stacked on #7.
Problem
The approval and observability API had two ways to do several things:
Options.Plan(hold every write) next toNeedsApproval(hold some writes), with the results in two places (Result.Plannedand*Pending).PlanandPlanssitting side by side read as a typo.Options.OnCallandOptions.OnEvent, two hooks for overlapping information.agent.Apply(calls)andplans.Approve(id), two ways to approve.&codemode.Recorder{Approved: true}, an internal type, just to say "a person pressed this button".Solution
One way to do each thing:
Options.Plan,Result.PlannedOptions.HoldWrites; held writes return*agent.Pendingand go throughPlanslike any write that needs approvalOptions.OnCallOnEventcall events carry the call'sInputagent.Applyplans.Approve&codemode.Recorder{Approved: true}codemode.WithApproval(ctx);Approvedis unexportedCall.Planned,Recorder.Pending()Call.Held,Recorder.Held(): one word, "held", throughoutThe common case is now five calls and three result types:
Examples and docs are updated: taskreport's audit log reads call events, its board delete uses
WithApproval, and the CRM walkthrough confirms plans by ID. None of the removed APIs were released.Verification
make test: buf lint,go test ./..., the env check and the consumer check.TestHoldWritesIsADryRunThatApprovalApplies:HoldWritesholds the write, and approving the plan runs it.TestOnEventSeesEachCallWithItsInput: call events carry the call's name and input.git grepfinds no remaining uses of the removed names outside changelog history and notes.