Add token registry and binary config codec for shareable links - #368
Conversation
|
Warning Review limit reached
More reviews will be available in 31 minutes and 23 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (13)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…codes Replace the lz-string share format with a compact, future-proof binary codec modelled on Guild Wars 2 build-template codes. Each token gets a permanent 16-bit id from a new append-only token-registry.json; a config is encoded as a sparse (id, value) byte buffer, base64url'd into the URL fragment (#c=). Unknown ids are skipped and missing ids fall back to defaults, so a link minted today decodes in every later build. - token-registry.json: canonical append-only id map, generated from docs/api-index.json by scripts/gen-token-registry.js (wired into `npm run docs`). - scripts/check-token-registry.js + `npm run check:registry`: CI gate enforcing id permanence (no reassignment/deletion, monotonic nextId); added to the artifacts-freshness job. - configurator/src/lib/codec.js: portable, dependency-light encode/decode (no Svelte/model coupling) so the WP plugin can vendor it verbatim. - share.js: rewritten over codec.js; public surface unchanged. lz-string dependency dropped. - sync-api.mjs mirrors the registry to src/data/token-registry.generated.json for runtime import. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GPnBf8GgSb2TxH4EFGiSjk
a668273 to
759b07a
Compare
There was a problem hiding this comment.
4 issues found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="configurator/src/lib/share.js">
<violation number="1" location="configurator/src/lib/share.js:60">
P2: Backward compatibility for existing share URLs was dropped. Old `#c=1.<compressed>` links will stop restoring overrides after this deploy.</violation>
</file>
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Fix all with cubic | Re-trigger cubic
| // Accept a full fragment ("#c=...") or a bare payload. | ||
| const fromFragment = raw.match(/[#&]?c=([^&]+)/); | ||
| if (fromFragment) raw = fromFragment[1]; | ||
| return decode(raw, registry, { sanitize: sanitizeValue, isKnown }); |
There was a problem hiding this comment.
P2: Backward compatibility for existing share URLs was dropped. Old #c=1.<compressed> links will stop restoring overrides after this deploy.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At configurator/src/lib/share.js, line 60:
<comment>Backward compatibility for existing share URLs was dropped. Old `#c=1.<compressed>` links will stop restoring overrides after this deploy.</comment>
<file context>
@@ -57,39 +46,18 @@ export function encodeOverrides(map) {
+ // Accept a full fragment ("#c=...") or a bare payload.
+ const fromFragment = raw.match(/[#&]?c=([^&]+)/);
+ if (fromFragment) raw = fromFragment[1];
+ return decode(raw, registry, { sanitize: sanitizeValue, isKnown });
}
</file context>
There was a problem hiding this comment.
Intentional, not a regression. This PR deliberately replaces the share format entirely: decode now understands only the new binary config code, and legacy #c=1.<lz-string> links degrade to "open with defaults" rather than restoring overrides. That was an explicit decision for the pre-1.0 framework — keeping a second lz-string decode path (and the lz-string dependency) purely for in-the-wild links wasn't worth it at this stage. The codec is forward-compatible by construction (versioned header, unknown ids skipped, missing ids fall back to defaults), so this is the last format break we expect. Leaving as-is by design.
Generated by Claude Code
There was a problem hiding this comment.
The parent comment was wrong here: this PR intentionally drops legacy lz-string compatibility, and old #c=1.<compressed> links are expected to fall back to defaults. The new binary codec is the intended format, so I’ll leave this as designed.
Address code-review findings on the config-code codec: - check-token-registry.js: diff against the base branch (GITHUB_BASE_REF / origin/main / main / HEAD~1) instead of HEAD. In CI the registry is already committed, so a HEAD baseline compared the file to itself and the id-permanence gate was a no-op. CI now fetches full history (fetch-depth: 0) so the baseline resolves. Also assert no id exceeds the uint16 wire limit. - gen-token-registry.js: refuse to mint an id past 65535 (the 2-byte wire field) rather than silently aliasing tokens once the id space overflows. - codec.js: drop registry ids outside the uint16 range in nameToId instead of truncating them on encode (belt-and-braces with the generator cap); covered by a new codec test. The dropped backward-compat for old lz-string `#c=1.<compressed>` links is intentional (pre-1.0, new format only — stale links degrade to defaults). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GPnBf8GgSb2TxH4EFGiSjk
Summary
Introduces a permanent, append-only token registry and a compact binary codec for encoding/decoding shareable configurator links. This replaces the previous name-based JSON encoding with a future-proof numeric id system, inspired by Guild Wars 2's build-template codes.
Key Changes
Token Registry (
token-registry.json,scripts/gen-token-registry.js)docs/api-index.jsonand maintains id stabilityBinary Config Codec (
configurator/src/lib/codec.js)(id, value)pairs instead of token namesconfigurator/tests/codec.test.js) covering round-trip encoding, malformed input tolerance, and URL safetyRegistry Validation (
scripts/check-token-registry.js)_meta.nextIdmonotonicity and that all live tokens have registry entriesIntegration Updates
configurator/src/lib/share.js: Updated to use binary codec instead of JSONconfigurator/scripts/sync-api.mjs: Syncs registry alongside API indexscripts/artifacts.json: Addedtoken-registry.jsonto tracked artifactspackage.json: Addedgen-token-registryandcheck-token-registryscriptslz-stringdependency from configurator (no longer needed for compression).github/workflows/ci.yml: Added registry validation gateImplementation Details
https://claude.ai/code/session_01GPnBf8GgSb2TxH4EFGiSjk
Summary by cubic
Introduce an append-only token registry and a compact binary codec for shareable configurator links. Links now use 16-bit token ids with base64url encoding for smaller, forward-compatible codes; CI enforces id permanence and uint16 bounds, replacing the old name-based JSON/
lz-stringformat.New Features
token-registry.json(16-bit ids; append-only; removed tokens flagged), generated fromdocs/api-index.jsonand mirrored toconfigurator/src/data/token-registry.generated.json; generator refuses ids past 65535.configurator/src/lib/codec.js: encodes(id, value)pairs, versioned, skips unknown/removed ids, drops out-of-range ids, URL-safe, and self-contained; integrated intoshare.js. Legacy#c=1.<lz-string>links are no longer supported (decode to defaults).configurator/tests/codec.test.js,share.test.js) for round-trip, malformed input tolerance, unknown binary version rejection, uint16 bounds, and URL safety.scripts/check-token-registry.jsverifies id permanence, no deletions/reuse, monotonic_meta.nextId, and uint16 limits; diffs against the base branch. Workflow fetches full history (fetch-depth: 0) and runs the check; artifacts list updated.Dependencies
lz-stringfrom the configurator.Written for commit 5fe90ed. Summary will update on new commits.