Skip to content

test(data): seam the money path — table-test the ingest outcome matrix (#1009 P0)#187

Open
LukasWodka wants to merge 1 commit into
developfrom
feat/1009-seam-money-path
Open

test(data): seam the money path — table-test the ingest outcome matrix (#1009 P0)#187
LukasWodka wants to merge 1 commit into
developfrom
feat/1009-seam-money-path

Conversation

@LukasWodka

@LukasWodka LukasWodka commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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

  • Extract runIngestionRun from runDataIngest and route its four cluster-touching steps through package 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 gateshouldReclaimStaging(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.
  • Harden submit.ForwardedConnection.Close to no-op on a zero-value connection (nil stopCh) — it panicked on close(nil) before, which is a latent bug and blocked using a fake in the seam test.

Tests (no cluster needed)

  • TestRunIngestionRun_Matrix drives 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 on succeeded), and the emitted --output-json status. Includes the mint-fail (5) and port-forward-fail (8) pre-submit returns.
  • 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.

Coverage: internal/cli 70.1% → 72.2%; runIngestionRun 94.1%, shouldReclaimStaging 100%, classifyPushOutcome 92.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) into runIngestionRun, with behavior unchanged for runDataIngest aside from threading jsonEmitted back 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 named shouldReclaimStaging.

submit.ForwardedConnection.Close now no-ops when stopCh is nil (zero-value / test fakes), fixing a latent close(nil) panic.

Adds ingestion_run_test.go (TestRunIngestionRun_Matrix, TestShouldReclaimStaging, TestSeamsWiredToRealFns) and extends TestClassifyPushOutcome for 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.

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

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

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