From 1e35761dbbfc65b8a2369fe3ebc5a25a82b127ab Mon Sep 17 00:00:00 2001 From: Boden Date: Fri, 29 May 2026 16:33:00 -0500 Subject: [PATCH] test(scrape): lock mixed-length snowflake cursor selection Add cursor-mixed-length smoke where string max_by would pick the wrong --after value; padded sort_by in last_message_id already picks the max. --- ...-29-034-fix-snowflake-cursor-smoke-plan.md | 27 ++++++++++++++++++ scripts/tests/run-discord-scrape-smoke.sh | 15 ++++++++++ .../append-after-mixed-length.json | 23 +++++++++++++++ .../append-mixed-length-cursor.json | 28 +++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 docs/plans/2026-05-29-034-fix-snowflake-cursor-smoke-plan.md create mode 100644 scripts/tests/test-fixtures/append-after-mixed-length.json create mode 100644 scripts/tests/test-fixtures/append-mixed-length-cursor.json diff --git a/docs/plans/2026-05-29-034-fix-snowflake-cursor-smoke-plan.md b/docs/plans/2026-05-29-034-fix-snowflake-cursor-smoke-plan.md new file mode 100644 index 00000000..a179adda --- /dev/null +++ b/docs/plans/2026-05-29-034-fix-snowflake-cursor-smoke-plan.md @@ -0,0 +1,27 @@ +--- +title: fix: Mixed-length snowflake cursor smoke +type: fix +status: complete +date: 2026-05-29 +origin: /lfg — close residual review P2 on last_message_id; lock padded sort behavior +--- + +# fix: Mixed-length snowflake cursor smoke + +## Summary + +`last_message_id` already uses zero-padded `sort_by` (not string `max_by`). Add a smoke fixture where an 18-digit ID lexicographically beats a 19-digit ID but is numerically smaller, and assert `--after` uses the true maximum. + +## Requirements + +| ID | Requirement | +|----|-------------| +| R1 | Fixture archive with IDs `999999999999999999` and `1000000000000000000` (unordered) | +| R2 | Smoke expects `--after` = `1000000000000000000` | +| R3 | `DCE_MIN_FREE_MB=0 ./scripts/run-all-smokes.sh` passes | +| R4 | PR #1538 notes residual P2 addressed | + +## Verification + +- `./scripts/tests/run-discord-scrape-smoke.sh` +- `DCE_MIN_FREE_MB=0 ./scripts/run-all-smokes.sh` diff --git a/scripts/tests/run-discord-scrape-smoke.sh b/scripts/tests/run-discord-scrape-smoke.sh index 3762e2c8..2ba560a5 100755 --- a/scripts/tests/run-discord-scrape-smoke.sh +++ b/scripts/tests/run-discord-scrape-smoke.sh @@ -103,6 +103,14 @@ cat >"$CONFIG_PATH" <&2; exit 1; } +mkdir -p "$ARCHIVE_ROOT/cursor-mixed-length" +cp "$FIXTURE_DIR/append-mixed-length-cursor.json" "$ARCHIVE_ROOT/cursor-mixed-length/$DEFAULT_FILE_NAME" +FAKE_DCE_EXPECT_AFTER=1000000000000000000 run_wrapper cursor-mixed-length append-after-mixed-length +MIXED_CURSOR_DEST="$ARCHIVE_ROOT/cursor-mixed-length/$DEFAULT_FILE_NAME" +[[ "$(jq -r '.messages | length' "$MIXED_CURSOR_DEST")" == "3" ]] || { echo "expected cursor-mixed-length archive to contain three messages" >&2; exit 1; } + mkdir -p "$ARCHIVE_ROOT/bootstrap-map" cp "$FIXTURE_DIR/append-existing.json" "$ARCHIVE_ROOT/bootstrap-map/$DEFAULT_FILE_NAME" [[ ! -f "$ARCHIVE_ROOT/bootstrap-map/.dce-meta/channel-map.json" ]] || { echo "bootstrap-map should start without channel map" >&2; exit 1; } diff --git a/scripts/tests/test-fixtures/append-after-mixed-length.json b/scripts/tests/test-fixtures/append-after-mixed-length.json new file mode 100644 index 00000000..fe94d65d --- /dev/null +++ b/scripts/tests/test-fixtures/append-after-mixed-length.json @@ -0,0 +1,23 @@ +{ + "guild": { + "id": "222", + "name": "Fixture Guild" + }, + "channel": { + "id": "111", + "name": "fixture-room", + "category": "Testing Grounds" + }, + "messages": [ + { + "id": "1000000000000000001", + "timestamp": "2026-01-03T00:00:00Z", + "content": "after-mixed-length-max" + } + ], + "dateRange": { + "after": "1000000000000000000", + "before": null + }, + "exportedAt": "2026-01-03T00:00:00Z" +} diff --git a/scripts/tests/test-fixtures/append-mixed-length-cursor.json b/scripts/tests/test-fixtures/append-mixed-length-cursor.json new file mode 100644 index 00000000..faee6a25 --- /dev/null +++ b/scripts/tests/test-fixtures/append-mixed-length-cursor.json @@ -0,0 +1,28 @@ +{ + "guild": { + "id": "222", + "name": "Fixture Guild" + }, + "channel": { + "id": "111", + "name": "fixture-room", + "category": "Testing Grounds" + }, + "messages": [ + { + "id": "999999999999999999", + "timestamp": "2026-01-01T00:00:00Z", + "content": "eighteen-digit-high-string-order" + }, + { + "id": "1000000000000000000", + "timestamp": "2026-01-02T00:00:00Z", + "content": "nineteen-digit-true-max" + } + ], + "dateRange": { + "after": null, + "before": null + }, + "exportedAt": "2026-01-02T00:00:00Z" +}