Skip to content

PvZ cloud revision contract

Production /api/game/pvz/save?edition=funny-v1 returned revision: "1". The shared game table installs this column as PostgreSQL bigint, whose node-postgres result is decimal text. Both GET and PUT passed that raw value through. The browser requires a safe integer, so it refused restores and successful upload acknowledgements. The earlier save tests created an integer column and missed this driver difference.

Normalize the trusted stored revision into an exact safe JSON number at both response boundaries. Incoming writes still require a numeric revision and retain owner checks, edition separation, size/path validation and SQL compare-and-swap. Reject the maximum safe input before incrementing, rather than committing a revision that cannot be represented by the client. No schema or player-data migration.

The new acknowledgement/next-upload regression failed on the original '2' !== 2 result, then passed. Integer, decimal string and bigint values preserve identity; malformed, negative and unsafe values are rejected. The database test now uses a bigint column. All four focused save tests and full workspace build/typecheck pass.

Publication order: first publish the browser companion that understands both response forms and protects local progress with no valid sync baseline. It presents an explicit device/account choice in the existing progress panel instead of silently loading a potentially stale first cloud upload. Then deploy this API change and verify numeric production GET with saved file contents unchanged. Do not deploy API normalization ahead of that preserving client.

Evidence: packages/server/output-save-revision-red.log, packages/server/output-save-revision-green.log, output-save-revision-build.log, output-save-revision-types.log; browser work lives in pvz-dave-adventure under the cloud-revision plan and checks.