Repository navigation
Tighten release packaging and Redis cleanup - #8
Conversation
|
OpenRouter review posted ( |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: 7a64c5ac5de2ef5e6956f9803e404b7810853c5d
Judge: openai/gpt-5.6-luna
Cost: $0.3750 (lanes $0.3691 + judge $0.0059)
Lanes
meta/muse-spark-1.2: ok (7 finding(s), 68.4s, 230346+9063 tokens (55108 cached), 4 tool round(s), via Meta, $0.27)z-ai/glm-5.3-flash: ok (8 finding(s), 377.1s, 1948491+80849 tokens (1774336 cached), 19 tool round(s), via DigitalOcean, $0.10)
Findings
🟠 Issue 1 — Smoke job installs tarballs before verifying inventory and hashes
.github/workflows/publish.yml:162 · risk · identified by meta/muse-spark-1.2
A tampered artifact that keeps package-manifest.json bytes identical (so the SHA-256 digest still matches needs.prepare.outputs.manifest_digest) but replaces a .tgz with different content would pass the digest check and be npm installed in the smoke job.
The smoke step only hashes the manifest (createHash("sha256").update(manifestBytes)) and never validates manifest.packages[].sha256/shasum/integrity or the directory inventory before spawnSync("npm", ["install", ...tarballs]). The publish verifier does fully re-hash every tarball and check include-hidden-files:false inventory, so publication would still be blocked, but the unprivileged smoke consumer would execute attacker-controlled code without detection.
Checked publish.yml smoke section (Install and import the prepared packages) and the duplicated verifier in publish (Verify and publish…). No validateReleaseInventory or hash loop precedes the npm install in smoke.
🔴 Issue 2 — validatePackedManifest uses order-sensitive JSON stringify equality
scripts/release-packages.mjs:731 · bug · identified by meta/muse-spark-1.2
validatePackedManifest ends with if (!sameJson(packed, source)) fail(...) where sameJson is JSON.stringify(left)===JSON.stringify(right).
JSON.stringify is insertion-order sensitive. npm pack extracts package/package.json via tar -xOf and parses it; the resulting key order may differ from the on-disk source file (or future npm versions may normalize order) even though the objects are semantically equal. The check would then throw "packed manifest does not match its reviewed source" and break a valid release.
Verified in scripts/release-packages.mjs:677 (sameJson) and validatePackedManifest:731. Existing test uses structuredClone(source) which preserves order, so the fragility is not covered.
🟠 Issue 3 — Tag validation allows control and brace characters
packages/cache-core/src/index.ts:118 · risk · identified by meta/muse-spark-1.2
validateCacheTags only calls assertWellFormedCacheString (surrogate check). Unlike requireToken for namespace/key/hashTag, it never checks CONTROL ([\u0000-\u001F\u007F]) or {}:.
A tag like "a\u0000b", "t{evil}", or "x:y" passes validateCacheTags and becomes tagKey = "${prefix}t:${tag}" (control/{/} in Redis key) or later tagMember handling. While Redis accepts binary keys, control characters break logging/metrics and "{"/"}" violate the invariant that keyPrefix must not contain braces so hashTag remains the first brace pair. The conformance suite now tests only surrogate rejection.
Inspected packages/cache-core/src/index.ts:118 (validateCacheTags) vs requireToken:96 and Redis tagKey:145. cache-conformance ill-formed test at index.ts:133 only asserts surrogates.
🔵 Issue 4 — keyPrefix well-formed check omits control validation
packages/cache-redis/src/index.ts:138 · nit · identified by meta/muse-spark-1.2
requirePrefix in packages/cache-redis/src/index.ts:138 now validates assertWellFormedCacheString(prefix, "keyPrefix") and braces, but does not reject CONTROL characters (\u0000-\u001F, \u007F).
A prefix containing \u001F collides with TAG_MEMBER_SEPARATOR ("\u001F") used to encode tagMember = "\u001F${generation}\u001F${formatted}". An attacker-chosen or misconfigured prefix could create ambiguous member parsing or inject control bytes into Redis keys and logs.
Confirmed requirePrefix lacks CONTROL.test(prefix) while requireToken has it; test index.test.ts:586 only checks braces and surrogates.
🔵 Issue 5 — runGetOrCompute validates tags but discards snapshot
packages/cache-core/src/index.ts:291 · nit · identified by meta/muse-spark-1.2
runGetOrCompute does if (options.tags !== undefined) validateCacheTags(options.tags); without keeping the returned copy.
validateCacheTags snapshots via [...tags] to prevent later mutation from desynchronizing the tag index (the memory/Redis set race fixed in this PR). If the caller mutates the original array between this check and computeAndStore→backend.set (set will re-validate/snapshot again, but the interval window still allows a TOCTOU if a future backend skips re-validation). More importantly the intent of the new check is lost and the code pays validation cost twice.
Seen in packages/cache-core/src/index.ts:292 and computeAndStore:355 which forwards options.tags directly. Grepped callers: createMemoryCacheStore.set, createRedisCacheStore.set, and createUnavailableCacheStore.set all re-snapshot, so current adapters are safe but the helper remains fragile.
🔵 Issue 6 — Prepare job no longer passes --require-release-tag to release:pack
.github/workflows/publish.yml:127 · nit · identified by meta/muse-spark-1.2
prepare now runs pnpm run release:pack -- --require-clean --require-main-ancestor --expected-release-commit ... (line 127). The previous command included --require-release-tag, which made validateRepository call validateReleaseTag inside the script (signature + ancestor check).
Tag authenticity is still enforced by the bash Authenticate the release tag block before checkout, so the workflow remains secure, but defense-in-depth is reduced: a local pnpm run release:pack or a future refactor that reorders steps could pack without the script-level tag check. publish still re-authenticates, but prepare's script validation is now weaker than intended.
Compared diff hunk in .github/workflows/publish.yml:127 and scripts/release-packages.mjs:540 (if (options.requireReleaseTag) validateReleaseTag…).
🔵 Issue 7 — Packed archive inventory check assumes "package/" prefix without "./"
scripts/release-packages.mjs:757 · nit · identified by meta/muse-spark-1.2
validatePackedArchive does tar -tf and asserts entry.startsWith("package/") for every non-directory entry.
Some tar implementations (and npm pack on Windows) emit "./package/package.json" or "package/..." with a leading ./. The strict prefix check would then fail("tarball contains an invalid archive path") on a perfectly valid archive, breaking prepareRelease on that platform.
Read scripts/release-packages.mjs:757 (tarCommand, validatePackedArchive). CI runs on ubuntu-latest where it currently passes, but the check is non-portable.
🟠 Issue 8 — Strict serialized equality against npm pack output can fail every release prepare
scripts/release-packages.mjs:689 · risk · identified by z-ai/glm-5.3-flash
If npm pack (npm 11.18.0, run inside the git checkout) rewrites the manifest it places in the tarball — different key order, or an added field such as the gitHead that older npm injected when packing from a git work tree — then validatePackedManifest(manifest, readPackedManifest(tarballPath)) throws packed manifest does not match its reviewed source for every package, the prepare job fails at "Prepare and seal release tarballs", and no release can be published.
The check is sameJson(packed, source), which is JSON.stringify(left) === JSON.stringify(right) — a key-order-sensitive string comparison, not deep equality. It is compared against what npm's packer serializes, which this code does not control. The unit test only exercises it with structuredClone(source) of the same object, so it can never catch a packer-serialization mismatch.
Proof gap I could not close from the checkout: I cannot run npm here to confirm whether npm 11.18.0 preserves package.json byte-for-byte in the tarball. The PR body claims CI=1 pnpm run release:pack passed locally, which is weak counter-evidence. The fixer should falsify cheaply: npm pack one package with npm 11.18.0 inside the checkout, tar -xOf *.tgz package/package.json, and diff against packages/*/package.json; if anything differs, replace the serialized-string equality with deep equality or an explicit allowlist of packer-added fields.
🟠 Issue 9 — Credential-less git fetches assume the repository is publicly readable
.github/workflows/publish.yml:89 · risk · identified by z-ai/glm-5.3-flash
On a private repository, both release jobs now fetch from origin over HTTPS with no credentials and fail, breaking every release.
Two instances of the same mechanism:
- Prepare:
actions/checkoutruns withpersist-credentials: false(line 85), which strips the token from git config, and the next step re-fetches anonymously:git fetch --no-tags origin main:refs/remotes/origin/main(line 89). The previous workflow fetched with checkout's default persisted credentials. This step is also redundant —fetch-depth: 0already populatedrefs/remotes/origin/main, which is what--require-main-ancestorneeds. - Publish: the job performs no checkout at all, and
Re-authenticate the release tagdoesgit fetch --no-tags origin ...into the bare auth repo (fetch refspecs around lines 272-276) purely anonymously.
The old workflow's publish job checked out the tag with the default persisted token, so this anonymous-fetch dependency is new in both jobs. For a public repository anonymous HTTPS fetch works and nothing breaks; I could not determine repository visibility from the checkout (README badges and docs/RELEASING.md suggest public, and RELEASE_ALLOWED_SIGNERS is deliberately a vars not a secret). Keep the finding unless the repo is confirmed public; otherwise pass the app token to these fetches or drop the redundant prepare fetch.
🔵 Issue 10 — Smoke job never checks tarball hashes, so it can test bytes other than the sealed ones
.github/workflows/publish.yml:185 · nit · identified by z-ai/glm-5.3-flash
The smoke job hashes only package-manifest.json and compares it to MANIFEST_DIGEST (lines 182-187); it then installs and imports the tarballs without comparing each tarball against the record.sha256 / record.integrity fields that are already in the parsed manifest. If a tarball in the downloaded artifact is corrupted or replaced, smoke installs and imports bytes that were never sealed, so its pass/fail verdict does not attest the tarballs publish will later re-verify and ship. The publish job does the hash re-verification, so no bad publish results — but the "sealed artifact" guarantee the PR advertises is not actually enforced on the smoke path, and a corrupted artifact would surface as a confusing npm install failure instead of a digest mismatch. Adding one createHash("sha256") loop over manifest.packages before the install closes the gap.
🔵 Issue 11 — --expected-release-commit is parsed but ignored during prepare
scripts/release-packages.mjs:611 · nit · identified by z-ai/glm-5.3-flash
The prepare job still runs release:pack -- ... --expected-release-commit "${RELEASE_COMMIT}" (publish.yml line 128), but since the workflow dropped --require-release-tag, expectedReleaseCommit is now only consumed inside if (options.requireReleaseTag) (lines 611-616, feeding validateReleaseTag). In the pack path it is stored by parseArguments and never read, so the script no longer cross-checks the checked-out HEAD against the release-event commit; that property is now carried entirely by the workflow-level "Authenticate the release tag" step (which does verify peeled == RELEASE_COMMIT before checking out github.sha). Security holds, but the flag is misleading dead configuration — a future reader will assume prepare re-checks the commit, and a refactor that removes the workflow step would silently drop the property. Either wire the check into prepareRelease/validateRepository unconditionally or stop passing the flag.
🔵 Issue 12 — RELEASING.md overclaims that the tag-version match happens before checkout
docs/RELEASING.md:53 · nit · identified by z-ai/glm-5.3-flash
docs/RELEASING.md states: "Before either checkout or publication, workflow-owned code verifies that the tag:" followed by four bullets including "matches the package version". The pre-checkout "Authenticate the release tag" step checks only the format regex, annotation type, signature, tag-name match, peeled target, and origin/main ancestry. The tag-vs-package-version match happens later: in validateRepository (via process.env.RELEASE_TAG during release:pack, after checkout) and again in the publish verifier. The runbook therefore overclaims one of the four pre-checkout properties; a reader auditing the release path would look for the version match in the wrong place. Reword so only the properties checked before checkout are attributed to it.
🔵 Issue 13 — Publish verifier sleeps 32 s after the final registry-visibility attempt
.github/workflows/publish.yml:490 · nit · identified by z-ai/glm-5.3-flash
In the inline publish verifier, after npm publish the confirm loop runs for (let attempt = 0; attempt < 6; attempt += 1) and unconditionally awaits 2 ** attempt * 1000 ms at the end of every iteration, including the last one. When the version never becomes visible, the job waits an extra 32 seconds (1+2+4+8+16+32) before throwing "did not become visible". The script's own confirmRegistryIntegrity avoids exactly this with if (attempt < 5) before waiting (scripts/release-packages.mjs line ~975). On the failure path this just wastes up to half a minute of the privileged job; mirror the attempt < 5 guard.
🔵 Issue 14 — Smoke no longer imports subpath exports, only the package root
.github/workflows/publish.yml:215 · nit · identified by z-ai/glm-5.3-flash
The old smokeTestTarballs imported every export specifier derived from manifest.exports (exportSpecifiers, now deleted from the script); the new smoke job imports only manifest.packages[].name. verifyPackedFiles/validatePackedArchive prove that an export's target file exists in the tarball, not that it parses and imports. Today all six packages declare only the "." export, so behavior is unchanged — but the first subpath export added to any package would ship without ever being executed by the release smoke. Either keep a per-export import loop in the smoke script or note that the coverage regression is intentional.
🔵 Issue 15 — Legacy envelopes with ill-formed tags are deleted on first read after upgrade
packages/cache-redis/src/index.ts:199 · nit · identified by z-ai/glm-5.3-flash
decodeEnvelope now runs validateCacheTags(tags), so an entry written by the previously published adapter (which accepted any tag string) whose tags contain an unpaired surrogate throws during decode. get treats that as a malformed envelope and compareAndDeleteEntrys it, and invalidateTags does the same — the cached value is silently dropped rather than served, even though its bytes and TTL are fine. For a cache this is safe self-healing, but it is a read-path data-loss side effect of the new validation that neither the PR description nor the tests acknowledge (the new tests only cover freshly written malformed values). Worth a line in the release notes, or restrict envelope decode validation to structural checks and leave tag well-formedness to the write path.
| } | ||
| } | ||
|
|
||
| /** Validates and snapshots caller-owned tag arrays. */ |
There was a problem hiding this comment.
🟠 Tag validation allows control and brace characters (risk)
validateCacheTags only calls assertWellFormedCacheString (surrogate check). Unlike requireToken for namespace/key/hashTag, it never checks CONTROL ([\u0000-\u001F\u007F]) or {}:.
A tag like "a\u0000b", "t{evil}", or "x:y" passes validateCacheTags and becomes tagKey = "${prefix}t:${tag}" (control/{/} in Redis key) or later tagMember handling. While Redis accepts binary keys, control characters break logging/metrics and "{"/"}" violate the invariant that keyPrefix must not contain braces so hashTag remains the first brace pair. The conformance suite now tests only surrogate rejection.
Inspected packages/cache-core/src/index.ts:118 (validateCacheTags) vs requireToken:96 and Redis tagKey:145. cache-conformance ill-formed test at index.ts:133 only asserts surrogates.
There was a problem hiding this comment.
Declined: tag compatibility intentionally changes only ill-formed UTF-16 as scoped. Braces and colons in a tag do not participate in CacheKey hash-tag formatting; sidecar operations remain single-key, and tags are never logged. Existing valid tag strings therefore remain accepted.
| @@ -122,6 +138,7 @@ function slidingRefreshExpiry(entry: RedisEntry, nowMs: number): number | null { | |||
|
|
|||
There was a problem hiding this comment.
🔵 keyPrefix well-formed check omits control validation (nit)
requirePrefix in packages/cache-redis/src/index.ts:138 now validates assertWellFormedCacheString(prefix, "keyPrefix") and braces, but does not reject CONTROL characters (\u0000-\u001F, \u007F).
A prefix containing \u001F collides with TAG_MEMBER_SEPARATOR ("\u001F") used to encode tagMember = "\u001F${generation}\u001F${formatted}". An attacker-chosen or misconfigured prefix could create ambiguous member parsing or inject control bytes into Redis keys and logs.
Confirmed requirePrefix lacks CONTROL.test(prefix) while requireToken has it; test index.test.ts:586 only checks braces and surrogates.
There was a problem hiding this comment.
Declined: the separator exists inside set members, while keyPrefix exists only in Redis key names; those values are never parsed together. Prefix controls cannot make a member ambiguous. This change keeps the existing brace rule and adds only Unicode well-formedness.
| ) { | ||
| throw new Error("invalid cache envelope"); | ||
| } | ||
| const lastComputeMs = meta["lastComputeMs"]; |
There was a problem hiding this comment.
🔵 Legacy envelopes with ill-formed tags are deleted on first read after upgrade (nit)
decodeEnvelope now runs validateCacheTags(tags), so an entry written by the previously published adapter (which accepted any tag string) whose tags contain an unpaired surrogate throws during decode. get treats that as a malformed envelope and compareAndDeleteEntrys it, and invalidateTags does the same — the cached value is silently dropped rather than served, even though its bytes and TTL are fine. For a cache this is safe self-healing, but it is a read-path data-loss side effect of the new validation that neither the PR description nor the tests acknowledge (the new tests only cover freshly written malformed values). Worth a line in the release notes, or restrict envelope decode validation to structural checks and leave tag well-formedness to the write path.
There was a problem hiding this comment.
Declined: a generation-less entry carrying an ill-formed tag cannot satisfy current tag identity semantics over UTF-8. Cache entries are disposable, so compare-and-delete cleanup is the intended self-healing behavior rather than serving an entry whose tag index cannot be addressed reliably.
|
The non-inline note about --expected-release-commit is addressed in d822e9c: validateRepository now compares HEAD whenever the option is supplied, and the release tests cover both matching and mismatching commits. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: latest-commit (commit-range)
Mode: verify
Commit: d822e9cbb87a5d13c54749a5ffba80922671fa8d
Judge: openai/gpt-5.6-luna
Cost: $0.1973 (lanes $0.1972 + judge $0.0001)
Lanes
meta/muse-spark-1.2: ok (0 finding(s), 33.5s, 99811+5058 tokens (6099 cached), 3 tool round(s), via Meta, $0.14)z-ai/glm-5.3-flash: ok (0 finding(s), 236.1s, 1031345+41597 tokens (818752 cached), 19 tool round(s), via CoreWeave, $0.0576)
Round 2 resolution
- ✅
r1-2fixed correctly — validatePackedManifest uses order-sensitive JSON stringify equality: sameJson now uses isDeepStrictEqual (scripts/release-packages.mjs:71) instead of JSON.stringify equality. tests/release-packages.test.ts adds reversed-order case that passes. - ✅
r1-1fixed correctly — Smoke job installs tarballs before verifying inventory and hashes: smoke job in .github/workflows/publish.yml now verifies manifest digest, directory inventory (expectedFiles Set, readdir + hidden/symlink/file checks) and per-tarball sha256/shasum/integrity against manifest before mkdtemp/npm install. Publish verifier retained full checks. - ❌
r1-3not fixed — Tag validation allows control and brace characters: validateCacheTags in packages/cache-core/src/index.ts:119 still only clones and calls assertWellFormedCacheString (surrogate check). No CONTROL ([\u0000-\u001F\u007F]) or "{}:" rejection; requireToken checks are not applied to tags. Control/brace tags still become Redis keys. ⚠️ r1-8fixed incorrectly — Strict serialized equality against npm pack output can fail every release prepare: Order-sensitivity fixed via isDeepStrictEqual, but strict deep equality against npm pack output remains. validatePackedManifest still does if (!sameJson(packed,source)) fail(...) after hook/pin checks, so any future npm-added field (e.g., gitHead) still throws and would block prepare. Pinned npm 11.18.0 currently does not inject gitHead, so no immediate break, but fix is incomplete for the added-f…- ❌
r1-9not fixed — Credential-less git fetches assume the repository is publicly readable: No credential fix landed. .github/workflows/publish.yml prepare still fetches credential-less: bare repo fetch from https://github.com/${GITHUB_REPOSITORY}.git and git fetch --no-tags origin main:refs/remotes/origin/main after checkout with persist-credentials:false. Works for current public repo but still fails on a private repository as originally reported. - 10 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is
risk). - Open findings after this round: 3 (0 bug-severity).
No structured findings from the successful lane(s).
|
Verification follow-up: 43d8f43 updates packed-manifest validation to preserve all reviewed source fields while accepting packager-added top-level metadata. The other two repeated items remain unchanged for the reasons already recorded in their open threads: tag validation is limited to the requested UTF-16 well-formedness contract, and anonymous pre-checkout fetches are intentional for this public repository. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: clean
Scope: latest-commit (commit-range)
Mode: verify
Commit: 43d8f430911fdee0a717318bd93fbd3394c8909b
Judge: openai/gpt-5.6-luna
Cost: $0.1345 (lanes $0.1344 + judge $0.0001)
Lanes
meta/muse-spark-1.2: ok (0 finding(s), 33.2s, 102703+4584 tokens (35268 cached), 3 tool round(s), via Meta, $0.11)z-ai/glm-5.3-flash: ok (0 finding(s), 80.7s, 533523+15175 tokens (489344 cached), 19 tool round(s), via DigitalOcean, $0.0253)
Round 3 resolution
- 🤝
r1-3disputed — Tag validation allows control and brace characters: Current code unchanged:validateCacheTagsatpackages/cache-core/src/index.ts:119still only callsassertWellFormedCacheString. Decline is technically justified: tags becometagKey =${prefix}t:${tag}`` and sidecar sets via single-key ops (sadd/`srem`/`smembers`/`eval` with `numKeys=1`) – braces in a tag affect only that tag index key's hash-slot, not the `keyPrefix`/`hashTag` invariant … - ✅
r1-8fixed correctly — Strict serialized equality against npm pack output can fail every release prepare: Fixed inscripts/release-packages.mjs:707-712.validatePackedManifestnow projectspackedontoObject.keys(source)(reviewedPackedFields = Object.fromEntries(Object.keys(source).map(k=>[k,packed[k]]))) thensameJson(reviewedPackedFields, source).sameJsonisisDeepStrictEqual(order-insensitive, including nested objects), and projection makes the top-level order followsource. Ex… - 🤝
r1-9disputed — Credential-less git fetches assume the repository is publicly readable: Disputed as intentional tradeoff. Repo is public (git+https://github.com/pegma-dev/cache-core.git,isPrivate:falseclaim), so anonymoushttps://github.com/${GITHUB_REPOSITORY}.gitfetch in bareauth_repoand post-checkoutgit fetch --no-tags origin main:refs/remotes/origin/mainwithpersist-credentials:falsesucceeds. Checked.github/workflows/publish.yml:85,89and re-auth flow. Avoi… - Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
Summary
Validation
CI=1 pnpm run format:checkCI=1 pnpm run checkCI=1 pnpm testCI=1 pnpm run release:pack -- --output <temporary-directory>The local Redis port was not already available, so the real Redis adapter suites are left to the required GitHub Actions service job.