test(autopsy): producer↔consumer schema-parity for deploy-failure events (#70)#96
Merged
Merged
Conversation
…nts (#70) The worker (PRODUCER) writes deployment_events autopsy rows in upsertAutopsyRow; the api (CONSUMER) reads them back via models.GetDeploymentEvents and serves GET /api/v1/deployments/:id/events. The two live in SEPARATE Go modules (worker does NOT import the api), so there is NO compiler-enforced link between the columns the worker INSERTs and the columns/encoding the api SELECTs+unmarshals. A drift on either side (renamed column, changed last_lines encoding, exit_code type flip) would silently break the agent debug surface with no build error. Existing tests cover that the worker WRITES the row (deploy_failure_autopsy_test.go) and the api SERVES it (api PR #269's deploy_autodebug_path_test.go + deploy_events_endpoint_test.go). This adds the focused PARITY assertion: - TestAutopsySchemaParity_LastLinesEncodingMatchesAPIConsumer captures the EXACT last_lines bytes the worker binds (sqlmock Argument matcher) and runs the api's consumer logic (json.Unmarshal into []string) over them — if the worker ever changed the encoding away from json.Marshal([]string), the api /events handler would break and this reds first. - TestAutopsySchemaParity_ColumnSetMatchesAPIConsumer asserts the worker INSERTs exactly the column set the api Events handler SELECTs (deployment_id/kind/reason/exit_code/event/last_lines/hint, in order) via a regex over the INSERT — a column rename on either side reds. Cross-ref: api PR #269 (docs/ci/02-FAILURE-DIAGNOSIS-AND-AUTODEBUG.md §5.3). make gate green except a pre-existing local-only integration flake outside this diff (jobs/TestIntegration_BillingReconciler_ SkipsTestCohort, billing-downgrade against the shared local DB). CI (fresh DB) is authoritative; the new parity tests + all existing autopsy tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
Author
|
Cross-ref: api auto-debug-path + with_failed_deploy factory PR is InstaNode-dev/api#269. This PR's parity tests guard the schema the api /events handler in api#269 unmarshals. |
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.
Worker side of the deploy-failure auto-debug-path CI tests (task #70, source
docs/ci/02-FAILURE-DIAGNOSIS-AND-AUTODEBUG.md §5.3). Cross-referenced with api PR InstaNode-dev/api#269.The contract this guards
The worker (PRODUCER) writes
deployment_eventsautopsy rows inupsertAutopsyRow; the api (CONSUMER) reads them back viamodels.GetDeploymentEventsand servesGET /api/v1/deployments/:id/events. The two live in separate Go modules (the worker does NOT import the api) — there is NO compiler-enforced link between the columns the worker INSERTs and the columns/encoding the api SELECTs + unmarshals. A drift on either side (renamed column, changedlast_linesencoding,exit_codetype flip) would silently break the agent debug surface with no build error.What this adds (extends, doesn't duplicate)
Existing tests already cover that the worker WRITES the row (
deploy_failure_autopsy_test.go) and the api SERVES it (api PR #269). This adds the focused schema-parity assertion:TestAutopsySchemaParity_LastLinesEncodingMatchesAPIConsumer— captures the EXACTlast_linesbytes the worker binds (via a sqlmockArgumentmatcher) and runs the api's consumer logic (json.Unmarshalinto[]string) over them. If the worker ever changed the encoding away fromjson.Marshal([]string), the api/eventshandler would break — and this reds first.TestAutopsySchemaParity_ColumnSetMatchesAPIConsumer— asserts the worker INSERTs exactly the column set the api Events handler SELECTs (deployment_id/kind/reason/exit_code/event/last_lines/hint, in order) via a regex over the INSERT. A column rename on either side reds.Gates
make gategreen except a pre-existing local-only integration flake OUTSIDE this diff (jobs/TestIntegration_BillingReconciler_SkipsTestCohort, billing-downgrade against the shared local DB — untouched file). CI (fresh DB) is authoritative; the new parity tests + all existing autopsy tests pass.🤖 Generated with Claude Code