Repository navigation
refactor: concentrate repeated config, receipt and scheduler rules - #16
Merged
Merged
Conversation
- One state-path resolver (DRAFTCAT_STATE_PATH, then state.path, then ./state.db) for the engine and every subcommand. - ApprovalEnvelope.FieldsV2 defines the signed v2 field set once for all three receipt signers. - Config owns the credential variable names and the approval-window default (OperatorApprovalWindow, DefaultOperatorApproval). - OperatorDecision/QuorumDecision convert between single and quorum shapes. - Scheduler.SetRunning(name, bool) narrowed to Release(name). - RecordApprovalRow folded into RecordApprovalForRun; stored rows unchanged. - Remove unused toolTicket.consumedAt, Scheduler.MarkRun and ghl.ParseGHLWebhook. No behaviour change: CLI help and subcommand output are identical, the receipt signature and stored formats are unchanged. Adds interface tests for each consolidated rule.
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.
Problem
Several rules were written out separately at each call site, so changing one meant finding every copy:
DRAFTCAT_STATE_PATH→state.path→./state.db), in six placesChange
resolveStatePath/statePathFromConfigFile(state_path.go)ApprovalEnvelope.FieldsV2()+signApprovalEnvelope()TokenEnvName/SecretEnvName/APIKeyEnvName+Default*Envin configTimeoutConfig.OperatorApprovalWindow()+DefaultOperatorApprovalOperatorDecision.asQuorum/QuorumDecision.asSingleNarrowed or removed:
Scheduler.SetRunning(name, bool)→Release(name). No caller used thetruemode.RecordApprovalRowfolded intoRecordApprovalForRun. Its policy argument was always empty, and the stored row is unchanged.toolTicket.consumedAt,Scheduler.MarkRun,ghl.ParseGHLWebhook.Production code lines: 15,783 → 15,732 (blanks and comments excluded).
Behaviour
No behaviour change. Where existing call sites differed, each keeps its own behaviour:
zk-receiptstill treats a whitespace-onlystate.pathas unset.== 0approval-timeout check.The CLI help, the receipt signature field set, the SQLite rows and the relay/Telegram texts are all unchanged.
Validation
Before and after the change (all pass):
gofmt,go vet,go buildgo test -shortand the fullgo test-tags voicevet and testnpm ci --ignore-scripts && npm test && npm pack --dry-rungo run . validategolangci-lint --new-from-rev=HEAD(0 new issues)contrib/teams-relayvet and buildOutput comparison: help output for 14 CLI entry forms and the output of 12 read-only subcommand runs were compared byte-for-byte against
masterand are identical. The runs covered runs, pending, receipts, budget, zk-receipt, doctor (text and--json) and validate.New interface tests: one for each consolidated rule: state path, signed field set, env names, approval window, decision shapes.
Two-way door: an internal refactor with no format or interface change, revertable as one commit.