Repository navigation
Show step and s3-lock progress in publish approve - #464
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR464Version: 🤖 Updated on each push. |
PR Review: #464 — Show step and S3-lock progress in publish approveOverall the implementation is clean and well-reasoned. Comments are unusually thorough and the test fake-server approach correctly avoids mocks. The step-list drift issue it fixes is real and the one-count-per-stream design is correct in principle. A few concrete issues worth addressing before merge. Critical
The diff adds Fix: add Important
A pragmatic fix: when
Suggestions
The comment in Comment at The JSDoc block above Test The test verifies the last event is Nice-to-haves
False positives / intended behaviour
|
Backend was returning s3_lock_total and s3_lock_batch_count on the
hasMore=true and error paths but not on the final non-paging success
path. The CLI accumulates s3_lock_batch_count from every response so
the last batch was never counted — progress read short by one full
page (e.g. 3963/4963 at "complete" for a 4963-object dataset).
Fix: capture s3LockFinalTotal/s3LockFinalBatchCount before calling
updateProgress("s3_lock") and include them in the final c.json
response. Also update the test comment to make the contract explicit
so the fixture can no longer mask this class of bug.
Two Important review findings addressed: 1. Spinner reset on Worker retry: add s3LockResumed flag to PublishProgressInfo. When an outer retry fires while the continuation token is set (mid-s3_lock), subsequent progress events carry s3LockResumed=true and renderProgress appends "(resumed)" to the spinner line. The locked counter (s3LockLocked) is kept at function scope across retries so the display shows accumulated progress rather than appearing to restart from zero. 2. Subrequest budget for getDatasetS3Stats: add maxPages parameter that caps the LIST sweep at N pages. The s3_lock path in admin.ts passes MAX_COUNT_LISTS=20 (covers up to 20000 objects). If the dataset is larger, objectCount returns undefined and the CLI degrades to a running count without a denominator — correct behaviour rather than risking "Too many subrequests" on the first Worker invocation. All callers updated to handle objectCount: number | undefined.
Review findings addressedCritical — fixed
Before: the After: Commit: Important #1 — fixedCounter misleading on Worker retry mid-s3_lock Added Important #2 — fixed
Added Commit: All 9 publish-progress tests pass |
Closes #284.
What changed
The
nemar admin publish approvecommand no longer renders a static"Running publication workflow..." spinner for the entire 17-step run.
Two new layers of visibility were added so admins can tell a long S3
lock from a stuck Worker:
Step-level progress. The spinner now reads
Step 14/17: s3 lockand advances as the orchestrator reports anew
stepin its response. The canonical step list is exportedfrom
src/lib/api.ts(PUBLICATION_STEPS) and mirrors thebackend's
allStepsarray, so the CLI and thedataset publish statusdisplay can no longer drift out of sync. The previousstatus display claimed "all steps complete" while the backend was
still running
enrichment_check,version_doi, orsync_nemar—that gap is closed.
S3-lock batch progress. On the first
s3_lockcall (nocontinuation token), the backend now counts the dataset's
objects/prefix once viagetDatasetS3Stats, returns it ass3_lock_total, and the CLI threads it back on every follow-uprequest so the count sweep is bounded to one invocation. Each
response also returns
s3_lock_batch_count(objects locked inthat batch). The CLI sums them and renders
Locking S3 objects: 1240/4963 (25.0%). Batch size is unchanged(out of scope per the issue).
Test plan
test/publish-progress.test.tsexercising the newstepIndexForhelper, thePUBLICATION_STEPScontract, themulti-page s3_lock running total, and the
s3_lock_totalround-trip from response to the next request body. Tests run against
a real
Bun.servefake backend (no mocks).bun run typecheck(root + backend) clean.bun run buildclean (580 modules bundled).bun test test/publish-progress.test.ts test/publish-retry-classifier.test.ts test/publish-workflow.test.ts test/admin-restructure.test.ts(66 passes, 0 fails).