Skip to content

Share create-and-poll plumbing between preview and inbox-placement run - #7

Open
djbriane wants to merge 1 commit into
feature/inbox-placement-runfrom
refactor/shared-write-run
Open

djbriane wants to merge 1 commit into
feature/inbox-placement-runfrom
refactor/shared-write-run

Conversation

@djbriane

Copy link
Copy Markdown
Collaborator

Stacked on #6. Removes the duplication #6 introduced between preview run and inbox-placement run. Merge this into feature/inbox-placement-run before #6 lands.

Summary

  • src/lib/core/write-run.ts: shared request deps, resolveTimeoutSeconds, createOnce (single POST, never retried; definitive 4xx rethrows, 429/5xx/transport becomes the product's "uncertain" error), and a generic pollUntil loop. Both product modules keep only their paths, bodies, and settle rules.
  • src/lib/cli/html-source.ts: one readHtmlSource for both commands (limit wording kept per command).
  • src/lib/cli/run-failure.ts: one CLI error builder driven by per-command wording; preview still appends its reference_id note.
  • InboxContentSource is now { kind, value } with kind as the API body key; a single CONTENT_OPTIONS table drives flag selection, error text, and dry-run labels. This also removes the internal-invariant UsageError (exit 2) from the dry-run path.

Error messages, dry-run JSON, and human output are unchanged.

Behaviour differences

  • preview polling now short-circuits explicitly on --timeout 0 (it already did in practice).
  • A create failure carrying a non-HTTP status code now keeps that code on the uncertain error.

Test plan

  • npm test (163 pass: timeout test moved to core/write-run.test.ts, new createOnce / pollUntil tests)
  • tsc -p tsconfig.build.json --noEmit

…acement run

Move the request deps, timeout resolution, single-create failure
classification, and poll loop into core/write-run.ts, and the HTML file
reader and run-failure error builder into cli/. Inbox content sources become
{ kind, value } keyed by the API body field, with one command-side table
driving flag selection and dry-run labels.
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