feat: upgrade msgpackr to v2 and use structon for random-access struct encoding#457
feat: upgrade msgpackr to v2 and use structon for random-access struct encoding#457
Conversation
…t encoding msgpackr v1's randomAccessStructure option was removed in v2. This adopts the structon package (the intended replacement) which provides the same capability as a mixin via createStructon(Encoder). RecordEncoder now extends the structon- enhanced encoder class instead of plain Encoder, and the removed randomAccessStructure option is dropped from OpenDBIObject. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
| "mqtt-packet": "~9.0.1", | ||
| "msgpackr": "1.11.9", | ||
| "msgpackr": "^2.0.1", | ||
| "structon": "file:../../structon", |
There was a problem hiding this comment.
file: path dependency — not installable from npm.
"structon": "file:../../structon" will break npm install for anyone who doesn't have a sibling structon/ directory (CI, other contributors, downstream consumers of the published package). The PR description acknowledges this is intentional while waiting for structon 1.0.1 to be published — this line needs to be updated to "^1.0.1" (or whichever published semver range is correct) before merging to main.
Also: structon is a new runtime dependency but there's no entry for it in dependencies.md, which documents the justification for every runtime dep. A short entry covering size, security track record, and removal plan should be added alongside this change.
|
2 blockers. 1.
|
| "mqtt-packet": "~9.0.1", | ||
| "msgpackr": "1.11.9", | ||
| "msgpackr": "^2.0.1", | ||
| "structon": "^1.0.1", |
There was a problem hiding this comment.
The file: path is now fixed to ^1.0.1 — thanks. The dependencies.md entry for structon is still missing (repo policy requires every runtime dep to have a justified section there covering size, security, and removal plan). Please add one before merging.
| "mqtt-packet": "~9.0.1", | ||
| "msgpackr": "1.11.9", | ||
| "msgpackr": "^2.0.1", | ||
| "structon": "^1.0.3", |
There was a problem hiding this comment.
Lock file is stale — npm ci will fail in lint CI.
package.json says ^1.0.3 but package-lock.json still records "structon": "file:../../structon" (version 1.0.0, resolved as a local symlink). The three "Update structon" commits each bumped only package.json; the lock was never regenerated after the original commit.
lint-code.yaml uses npm ci, which compares packages[""].dependencies.structon in the lock against package.json and exits with "lock file out of sync" when they disagree.
Fix: run npm install (to regenerate the lock from the npm registry) and commit the updated package-lock.json.
Summary
msgpackrfrom1.11.9to^2.0.1structonpackage (the intended replacement for msgpackr v1'srandomAccessStructurefeature)RecordEncodernow extendscreateStructon(Encoder)instead of plainEncoderthis.randomAccessStructure = truefromOpenDBIObject(the option was removed in msgpackr v2)Purpose
msgpackrv1's built-inrandomAccessStructureoption was removed in v2. The author extracted this functionality into the separatestructonpackage. This change adopts structon to maintain random-access struct encoding (which enables efficient in-place field reads without full deserialization).A bug in structon's
onLoadedStructureswas also fixed (in the structon repo): it previously only reloaded typed structures when loading shared structures from the DB, but not named structures. This causedisCompatibleto always fail (named structure count mismatch), triggering an infinite encode retry loop. The fix reloads named structures intothis.structures, unfreezes array elements (needed becausefreezeData: truefroze them, but msgpackr lazily adds areadproperty), and clears transitions to force msgpackr to rebuild and updatelastNamedStructuresLength.Test plan
npm run test:unit:resources— 336 passing, 5 pre-existing failures (blob test + 4 vector index tests, pre-existing before this change)Attention areas
createStructon(Encoder) as typeof Encoderis needed becausecreateStructon's return type needs to be an exacttypeof Encoderfor subclassing to work cleanly in TypeScript. The runtime behavior is correct — structon does return a subclass of the input.structondependency usesfile:../../structon(local sibling directory) for now. Once structon 1.0.1 is published to npm (with theonLoadedStructuresfix), this should be updated to^1.0.1.🤖 Generated with Claude Code