Refactor automation mutations behind typed command writer - #1627
Open
open-inspect[bot] wants to merge 2 commits into
Open
Refactor automation mutations behind typed command writer#1627open-inspect[bot] wants to merge 2 commits into
open-inspect[bot] wants to merge 2 commits into
Conversation
Terraform Validation Results
Pushed by: @open-inspect[bot], Action: |
Terraform Validation Results
Pushed by: @open-inspect[bot], Action: |
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.
Summary
Implements audit finding A05 by moving automation mutation parsing and aggregate persistence out of the HTTP route.
CreateAutomationCommandandUpdateAutomationCommandvalues.D1AutomationAggregateWriteras the single atomic persistence boundary for automation rows, repositories, environments, provider selections, and Slack watched-channel indexes.AutomationRowconstruction,Record<string, unknown>update assembly, and cross-store SQL statement composition from the route.Preserved Contracts
next_run_atrecomputation, target final-state validation, provider-account policy, repository/environment resolution, and in-flight invocation semantics are unchanged.TDD Evidence
Red
Before production changes, focused tests were added for the missing ingress and writer seams. The initial run failed exactly as expected because these modules did not exist:
Cannot find module './automation-mutation'Cannot find module '/src/db/automation-aggregate-writer'A later HTTP-compatibility regression test was also added first and failed with
name is requiredinstead of the preserved update responsename cannot be empty.Green
The minimum parser, typed commands, and aggregate writer implementation made the focused tests pass. Route tests then confirmed unchanged statuses and payload behavior.
Refactor
After green, the code-simplifier review removed a redundant repository-selection wrapper and duplicate post-schema type guards. Focused tests were rerun after simplification. A final review added explicit
triggerConfig: nullwriter coverage and operation-specific scalar error mapping.Verification
npm test -w @open-inspect/control-plane -- src/automation/automation-mutation.test.ts src/db/automation-aggregate-writer.test.ts src/routes/automations.test.ts src/db/automation-store.test.ts(126 passed before final compatibility additions)npm test -w @open-inspect/control-plane(214 files, 3,260 tests passed)npm run test:integration -w @open-inspect/control-plane -- test/integration/automation-store.test.ts test/integration/automations-slack-route.test.ts test/integration/automation-invocations.test.ts(3 files, 86 tests passed)npm run typecheck -w @open-inspect/control-planenpm run lint -w @open-inspect/control-planenpm run build -w @open-inspect/control-planegit diff --checkRisks
nullforeventTypeandtriggerConfigbecause those clears are existing HTTP behavior, even though the shared request schema is narrower. This PR does not expand or alter shared client contracts.SqlDatabase.batch()all-or-nothing contract; targeted integration tests exercise the real D1 batch path and Slack synchronization.A04 Interaction
This change does not modify Scheduler transport/result contracts or depend on A04. The only likely overlap is the large
routes/automations.tsfile; A05 changes are confined to create/update parsing and persistence, while scheduler call/result handling is left untouched.Created with Open-Inspect