# SDK quality rules

These rules apply to SDK maintenance and host integration. Read the installed
package README, public types, resource guide, and MIGRATIONS.md with this file.
Use the instructions from the target release. Do not copy APIs from newer docs.

## Keep the host instructions available

On the first integration or upgrade, create or merge a short `Lockerverse SDK
maintenance` section in the host project's root `AGENTS.md`. Preserve unrelated
instructions and update an existing equivalent section instead of duplicating it.
Use the block below. Do not copy this entire guide or pin a release in that file.
For a monorepo, keep this pointer in the root and name the affected app directories;
resolve node_modules and lockfiles from the relevant package-manager workspace.

```markdown
## Lockerverse SDK maintenance

For any install, update, or integration edit involving @lockerverse/sdk or
@lockerverse/react:
- Record the old resolved package versions before installation. Use the existing
  package manager; keep React/Core matched when both are used, without downgrades.
- Read SDK_RULES.md and MIGRATIONS.md in the target installed package under
  node_modules/@lockerverse/react/ (or @lockerverse/sdk/ for Core-only hosts).
  React users must also read guides/integration.md and the relevant resource guides.
- Apply all applicable migrations, including skipped releases, and review the
  existing-integration baseline even if the version already matches. New
  integrations use the current guides and baseline.
- If files are missing, select a published matching stable release that includes
  them without downgrading, or report the blocked step. Do not invent instructions.
- If a tool already updated dependencies, recover the old versions from the prior
  lockfile or Git history. Report old/new versions, applied steps, skipped steps
  with reasons, and checks. A version bump alone does not complete a migration.
```

For Lovable, this short pointer can also be kept in workspace knowledge, scoped
to tasks that use Lockerverse. Do not install the SDK in unrelated projects.
Workspace knowledge covers projects that have not yet received their root file;
the root file keeps the rule with the project when it moves to another workspace
or agent. Do not assume files inside node_modules are read automatically.
See [Lovable's knowledge documentation](https://docs.lovable.dev/features/knowledge).
If the host file cannot be edited, report that persistence is incomplete.
A package installation does not run these instructions or modify the host file.

## Public content and search

- In an existing server-rendered host, load public auction data in its server
  loader. Pass the complete snapshot through the supported initial-data API.
  Keep text, images, status, and real links in the first HTML response. Do not
  put the whole auction in a client-only boundary to protect payment code.
- Keep browser storage, Stripe, and browser globals outside server rendering.
  Retain the seed or last good snapshot during refresh. Refresh silently; do
  not add an “Updating auction” banner or replace ready content with a loader.
  Show initial loading only when no data exists. Keep useful failure feedback.
- Use real href links for item and return navigation. Preserve direct entry,
  reload, Back, Forward, and opening in a new tab. The host must handle unknown
  item URLs; do not silently show the first item for an invalid identity.
- On a dedicated item page, use itemHeadingLevel={1}. Keep transaction headings
  below the item heading. Embedded items normally use the default level 2.
  Use public props, not DOM patches or private CSS selectors.
- The host owns titles, descriptions, canonicals, robots rules, sitemap, HTTP
  status codes, and structured data. Keep price and availability claims aligned
  with current public data. Do not hard-code a second copy of an offer.
- A browser-only app does not gain server rendering from an SDK update. Explain
  this limit. Do not replace its framework or add a server without task scope.

## Images, fonts, and initial download

- Use supported responsive image URLs and sizes. A proxy URL alone does not
  prove resizing. Check the returned dimensions, content type, and transfer size.
- With mediaBaseUrl, preserve the complete auction snapshot and forward w and f
  query parameters to the configured media service. Use only the supported
  public media path. Preserve signed, private, external, and unsupported image
  URLs and the existing original-image fallback.
- Match galleryImageSizes to the host layout. Reserve image space to prevent
  layout shifts. Load the first visible image eagerly with high priority; load
  off-screen images lazily. Keep selected and full-screen photos clear at their
  rendered size and device pixel ratio. Do not lower quality only for a score.
- Import the narrow public entry point for the feature. Keep payment code and
  optional Stripe peers out of unrelated catalog, event, and signup imports.
  Defer auction checkout code until payment or recovery needs it.
- Keep required first-screen styles available. Scope widget styles and inherit
  host fonts where supported. Do not add remote fonts or global font rules to
  widgets. The host owns font compression, preload choices, background video,
  and page-wide CSS. Avoid preloading every font or media file.
- Inspect the actual initial bundle and network requests when changing import
  boundaries. A smaller entry file alone does not prove a smaller first load.

## State, failures, and logging

- Keep resource identity stable. Do not remount a widget for background refresh,
  metadata changes, or styling changes. Preserve contact and checkout state.
- Never reset or retry an uncertain bid or payment as a new transaction. Preserve
  the supported recovery flow. Do not add automatic page reloads to unresolved
  payment recovery. A failed dynamic import needs useful failure feedback;
  repeating the same import is not a reliable recovery method in every browser.
- Use the existing failure-only telemetry contract. Do not add routine request,
  polling, success, or render logs. Report only the safe fields allowed by that
  contract; do not serialize request bodies or arbitrary error objects.
- Keep contact data, payment tokens, secrets, and recovery credentials out of
  URLs, public loader data, metadata, analytics, console output, and logs.
  Public configuration and public resource identity are not credentials.
- Use the selected environment and supported public APIs. Do not introduce an
  unrelated payment backend or change saved resource settings during an upgrade.

## Maintainer completion rules

- For every release, review MIGRATIONS.md. Add an entry for a changed public
  contract, default, or host adoption step. Include useful optional improvements,
  not only breaking changes. State when a change needs no host edit.
- Include affected packages/features, required and recommended actions, unchanged
  cases, and a way to check completion. Do not call a version bump a migration.
- Use a concrete release version for dated entries. If the release version is
  not yet known, put steps in an Unreleased section, then assign the actual
  version before publication. Do not publish pending steps as completed history.
- These two root Markdown files are the maintained source. The package builds
  copy them into both npm packages. Do not edit generated package copies.
- Use focused existing checks and inspect packed files for documentation changes.
  Do not create tests just because a file changed. Do not use real bids, payments,
  or signups for an integration check. Report checks not run and remaining limits.
- Do not promise a Lighthouse score, indexing, or search rank. Package rules help
  prevent regressions; website content, hosting, and external services also matter.
