Skip to content

test(autopsy): producer↔consumer schema-parity for deploy-failure events (#70)#96

Merged
mastermanas805 merged 1 commit into
masterfrom
ci/wave7-failure-diag-parity
Jun 6, 2026
Merged

test(autopsy): producer↔consumer schema-parity for deploy-failure events (#70)#96
mastermanas805 merged 1 commit into
masterfrom
ci/wave7-failure-diag-parity

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

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_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 (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, changed last_lines encoding, exit_code type 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 EXACT last_lines bytes the worker binds (via a 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.

Gates

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 — untouched file). CI (fresh DB) is authoritative; the new parity tests + all existing autopsy tests pass.

🤖 Generated with Claude Code

…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>
@mastermanas805

Copy link
Copy Markdown
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.

@mastermanas805 mastermanas805 enabled auto-merge (squash) June 6, 2026 04:46
@mastermanas805 mastermanas805 merged commit eb427f4 into master Jun 6, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant