test(data): seam the money path — table-test the ingest outcome matrix (#1009 P0)#187
Open
LukasWodka wants to merge 1 commit into
Open
test(data): seam the money path — table-test the ingest outcome matrix (#1009 P0)#187LukasWodka wants to merge 1 commit into
LukasWodka wants to merge 1 commit into
Conversation
…x (#1009 P0) runDataIngest's submit → port-forward → watch → classify → JSON → reclaim tail had no injection seam, so the path a customer actually lives in was covered by nothing (36.6%). A regression where the CLI previews success but the ingestor writes null/fewer, or reclaims staging on a partial failure, would ship silently. Extract the tail into runIngestionRun and route its four cluster-touching steps through package-level seams (mintIngestorTokenFn / portForwardJobsManagerFn / submitRunFn / cleanStagingFn), mirroring the existing listDatasetsFn seam. The extraction is behavior-identical — runDataIngest just calls it and threads jsonEmitted back for the --output-json error defer. Name the reclaim gate: shouldReclaimStaging(status) — the "reclaim ONLY on a clean success" invariant, so a detached / partial / failed / errored run keeps the staged source (for the still-reading Job, or for retry/inspection). This is the "must NOT reclaim on partial failure" gate #1009 calls out. Tests (no cluster needed): - TestRunIngestionRun_Matrix drives the whole tail through the seams and asserts, per outcome, the exit code (5 auth / 8 submit / 9 watch+ingest / 0 success+detached), whether the staging reclaim ran (only on succeeded), and the emitted --output-json status — all in lockstep. Covers the mint-fail (5) and port-forward-fail (8) pre-submit returns too. - TestShouldReclaimStaging pins the gate in isolation. - Extends the existing TestClassifyPushOutcome to cover the exit-5 (auth) and exit-8 (submit) buckets it was missing, plus unknown / nil-result. - TestSeamsWiredToRealFns guards that no seam is left nil. Also hardens submit.ForwardedConnection.Close to no-op on a zero-value connection (nil stopCh) — it panicked on close(nil) before, which blocked using a fake in the seam test; a never-started connection now closes safely. Coverage: internal/cli 70.1% → 72.2%; runIngestionRun 94.1%, shouldReclaimStaging 100%, classifyPushOutcome 92.9%. Part of backend#1009 (P0 seam the money path). Remaining #1009: CI drift wiring (pin the goldens/schema SHA + a per-package coverage floor so this can't rot), the cross-repo taxonomy contract test, and one content-compared ingest e2e. Part of the data-ingest epic backend#1008. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0c39dc7. Configure here.
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
runDataIngest's tail — submit → port-forward → watch → classify → JSON → reclaim — is the path a customer actually lives in, and it had no injection seam, so it was covered by nothing (36.6%). A regression where the CLI previews success but the ingestor writes null/fewer, or where it reclaims the staging copy on a partial failure (deleting the source the user needs to retry), would ship silently.This is the P0 "seam the money path" item of #1009.
What changed
runIngestionRunfromrunDataIngestand route its four cluster-touching steps through package seams —mintIngestorTokenFn/portForwardJobsManagerFn/submitRunFn/cleanStagingFn— mirroring the existinglistDatasetsFnseam. The extraction is behavior-identical;runDataIngestjust calls it and threadsjsonEmittedback for the--output-jsonerror defer.shouldReclaimStaging(status)— the "reclaim ONLY on a clean success" invariant. A detached / partial / failed / errored run keeps the staged source (the Job may still be reading it, or the user wants to retry/inspect). This is the "must NOT reclaim on partial failure" gate #1009 calls out.submit.ForwardedConnection.Closeto no-op on a zero-value connection (nil stopCh) — it panicked onclose(nil)before, which is a latent bug and blocked using a fake in the seam test.Tests (no cluster needed)
TestRunIngestionRun_Matrixdrives the whole tail through the seams and asserts, per outcome, three things in lockstep: the exit code (5 auth / 8 submit / 9 watch+ingest / 0 success+detached), whether the staging reclaim ran (only onsucceeded), and the emitted--output-jsonstatus. Includes the mint-fail (5) and port-forward-fail (8) pre-submit returns.TestShouldReclaimStagingpins the gate in isolation.TestClassifyPushOutcometo cover the exit-5 (auth) and exit-8 (submit) buckets it was missing, plusunknown/nil-result.TestSeamsWiredToRealFnsguards that no seam is left nil.Coverage:
internal/cli70.1% → 72.2%;runIngestionRun94.1%,shouldReclaimStaging100%,classifyPushOutcome92.9%. Full suite green.Type
Test hardening + a latent-panic fix · cli · RFC-0002 foundation. Part of backend#1009 (P0 seam the money path) — independent of the value-level-parity PR (cli#186) and of data-ingestors #340.
Remaining #1009: CI drift wiring (pin the goldens/schema SHA + a per-package coverage floor so this can't rot), the cross-repo taxonomy contract test, one content-compared ingest e2e.
Note
Low Risk
Refactor is extraction plus test seams with stated behavior parity; the only production behavior change is the defensive port-forward Close fix.
Overview
Extracts the post-staging ingest tail (token mint → jobs-manager port-forward → submit/watch → classify →
--output-json→ staging reclaim) intorunIngestionRun, with behavior unchanged forrunDataIngestaside from threadingjsonEmittedback for the early-failure JSON defer.Cluster-touching steps go through package-level seams (
mintIngestorTokenFn,portForwardJobsManagerFn,submitRunFn,cleanStagingFn) so tests can drive the full exit code / JSON status / reclaim matrix without a cluster. The reclaim-only-on-clean-success rule is namedshouldReclaimStaging.submit.ForwardedConnection.Closenow no-ops whenstopChis nil (zero-value / test fakes), fixing a latentclose(nil)panic.Adds
ingestion_run_test.go(TestRunIngestionRun_Matrix,TestShouldReclaimStaging,TestSeamsWiredToRealFns) and extendsTestClassifyPushOutcomefor auth (5), submit (8),unknown, and nil-result cases.Reviewed by Cursor Bugbot for commit 0c39dc7. Bugbot is set up for automated code reviews on this repo. Configure here.