Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

33.3 KB
Raw Blame

paths:

  • "packages/ee/src/onshape/**"
  • "apps/erp/app/routes/onshape+/**"
  • "apps/erp/app/routes/api+/integrations.onshape.panel.*"
  • "apps/erp/app/routes/api+/integrations.onshape-v2.*"
  • "apps/erp/app/routes/api+/integrations.onshape.detach.ts"
  • "apps/erp/app/modules/settings/settings.service.ts"
  • "apps/erp/app/modules/settings/settings.server.ts"
  • "apps/erp/app/components/ExternalSource.tsx"
  • "packages/jobs/src/inngest/functions/integrations/onshape-*"

Onshape panel (onshape-v2)

A Carbon panel in Onshape's element right panel. Users push parts, assemblies and releases from Onshape; Carbon never pulls on its own. Spec: .ai/specs/2026-08-28-onshape-app.md. User docs: docs/content/docs/integrations/cad.mdx.

Connections

  • Three Onshape grants, each with its own companyIntegration row and mapping namespace: onshape and onshape-government (sync connections, config.tsx, one active per company) and onshape-v2 (the panel, config-v2.tsx). A company can run the panel beside either sync connection.
  • ONSHAPE_V2_INTEGRATION_ID (lib/integration-id.ts): pass it to every panel read and write, e.g. getOnshapeClient(…, ONSHAPE_V2_INTEGRATION_ID). Omitted, getOnshapeClient resolves the company's sync connection. A bare "onshape" literal in panel code is a bug.
  • ONSHAPE_INTEGRATION_IDS, OnshapeIntegrationId, isOnshapeIntegrationId and getConflictingOnshapeIntegration (lib/connection.ts) cover the two sync connections only. OnshapeOAuthIntegrationId covers all three.
  • Status, releases and the three plan routes read the connection with the service role. The companyIntegration SELECT policy needs settings view; through a parts-view user's client the row reads as absent and the panel says Onshape is not connected. The Fields route uses the user's client: it requires settings update anyway.
  • Only an onshape-v2 item link means "the panel pushes to this item". A sync connection's item row is BOM-import bookkeeping for the BoM Explorer; the item card and Detach never read or delete it.
  • OAuth: the sync integration and the panel are two Onshape apps and share no variable. onshape reads ONSHAPE_CLIENT_ID, ONSHAPE_CLIENT_SECRET, ONSHAPE_OAUTH_REDIRECT_URL (→ /api/integrations/onshape/oauth); onshape-v2 reads ONSHAPE_V2_CLIENT_ID, ONSHAPE_V2_CLIENT_SECRET, ONSHAPE_V2_OAUTH_REDIRECT_URL (→ /api/integrations/onshape-v2/oauth). Both ask for OAuth2Read OAuth2Write. Each card is active only when its own client id is set (config.tsx, config-v2.tsx); otherwise it reads Not Configured, Install is disabled and an installed connection's Details link goes nowhere; the env schema groups them as onshape and onshapeV2. onshape-v2 is also internalOnly: on Carbon Cloud only Carbon staff (in any company) and the users the integration-early-access feature flag is on for (in the companies its rules name), or listed in INTEGRATION_EARLY_ACCESS_USER_IDS until a flags source is live, can install it, and everyone else sees Coming soon (isIntegrationComingSoon, @carbon/ee/plan; hasIntegrationEarlyAccess, @carbon/ee/plan.server). The install route refuses them with coming-soon (isIntegrationInstallWithheld, modules/settings/settings.service.ts); a company that has it installed keeps it. Install routes call beginOnshapeAuthorization; callbacks call completeOnshapeAuthorization (modules/settings/settings.service.ts); getOnshapeOAuthConfig picks the client and redirect per id and answers not-configured when one of that integration's three variables is missing. A connection's tokens belong to the app that issued them: changing an integration's client id means reconnecting. State is the cookie-bound one from @carbon/auth/oauth-state.server.
  • Connect opens a popup (beginOAuthPopup, packages/ee/src/oauth-popup.ts, opened inside the click). The callback renders oauthPopupResponse: it posts the outcome to the opener and closes, or lands on the integrations page with no opener. The drawer's Reconnect action POSTs to the install route and follows { redirectUrl }.
  • Uninstall only sets active = false and keeps the tokens, so getOnshapeClient reads the onshape-v2 row only while it is active: after an uninstall every panel read answers "not connected". A plan already stored can still be applied until it expires (15 min); APPLY makes no Onshape call.
  • onshapeHealthcheck (hooks.server.ts) builds the client (refreshing an expired token) and reads /companies; a revoked grant reads unhealthy.
  • Tokens live in Vault: SECRET_KEYS["onshape-v2"] (integrations/secrets.ts) names the access and refresh token. Migration 20261016051650_onshape-v2-integration.sql seeds the integration row; 20261016051651_onshape-v2-vault-secrets.sql moves any plaintext tokens already in onshape-v2 metadata into Vault.

Integration metadata

Several writers share companyIntegration.metadata: token refresh, the OAuth callback, the settings save, the webhook's Onshape company id and the Fields save. Each writes only its own keys. The others go through patchIntegrationState (row lock, dot-path patches) via the helpers in lib/state.ts; the Fields save is one Kysely UPDATE that writes propertyMap and descriptionModes with jsonb_set and merges the five default* push-default keys. Never write the whole column from an earlier read.

Token refresh

getOnshapeClient refreshes within two minutes of expiry (a missing expiresAt counts as expired) and once more per client on a 401. Onshape rotates refresh tokens, so the refresh runs under a lease from @carbon/kv (acquireLease / withLease: Lua acquire that tells "held" from "Redis down", renewal during the exchange, compare-and-delete release). The lease key is onshape-token-refresh:<companyId>:<integrationId> (5 s, renewed every 2 s); waiters poll every 250 ms and give up after 20 s. With Redis down it refreshes without a lock. The holder re-reads the stored pair and adopts a token another caller already refreshed (resolveOnshapeRefresh, lib/token-refresh.ts). The token request times out after 15 s.

Panel auth

The carbon cookie is SameSite=Lax and never reaches a cross-site iframe, so the panel has its own credential.

  • onshape+/panel.tsx loads without auth and is the only framable route: its Content-Security-Policy: frame-ancestors https://onshape.com https://*.onshape.com replaces the app's baseline directive.
  • onshape+/auth.tsx is a same-origin popup. It takes identity from the cookie session, refuses non-employees and console sessions, applies the app shell's account gates (MFA enrollment, ITAR attestation in a controlled environment), mints cps_<32 base64url> (Redis panel-session:<token>, panel/session.server.ts; 12 h, capped at the ERP session's absolute cap in a controlled environment) and posts it to the opener. The panel keeps it in sessionStorage (carbon:onshape-panel-session) and sends Authorization: Bearer; a 401 clears it.
  • A panel session holds identity only, never a Supabase token. Each request builds its client from a short-lived token signed for the user (getUserScopedClient). Copying the cookie session's refresh token would make the panel and the ERP tab rotate one chain, and GoTrue revokes the family on reuse.
  • Panel writes are settings operations (settings.server.ts): pushOnshapePart, pushOnshapeAssembly, pushOnshapeRelease and saveOnshapePropertyMap, with their bodies in settings.service.ts. A route authenticates with requireOnshapePanelPermissions, binds the operations to that user with carbonFor(auth) (@carbon/api/carbon.server), and makes one call. An operation answers a PanelReply ({ status, body }), and panelResponse sends it as given: the panel reads the status (410 expired, 422 with fieldErrors) and the body. Detach (detachOnshapeItem) runs on the cookie session through carbon(request).
  • Panel routes call requireOnshapePanelPermissions (@carbon/ee/onshape/panel-session.server), not requirePermissions. It applies the cookie path's session policy (panelSessionRefusal: absolute cap and idle lock in a controlled environment; a TOTP factor enrolled after minting everywhere), requires the employee role, then runs the same claims check. Denials are 401 or 403, never redirects. Activity is stamped only on an authorized request with SET … KEEPTTL XX, so a deleted session stays deleted.
  • Tokens never appear in URLs. postMessage targets window.location.origin.

Identity (externalIntegrationMapping, integration onshape-v2)

Entity externalId
Part item documentId:elementId:partId[:configuration]
Assembly item documentId:elementId:assembly[:configuration]
Release revision item release:<releaseId>:<partNumber>
Onshape-written BOM line entityType methodMaterial; metadata.makeMethodId names the method
Draft the panel made entityType makeMethod (DRAFT_MARKER_ENTITY_TYPE); externalId is the Draft id, metadata.sourceMethodId the Active method it copied
Source of an item's last assembly export entityType modelSource, entityId the item, integration the connection's id; externalId hashes the document, element, configuration and the version or workspace microversion; metadata.modelUploadId the model it produced

A non-default configuration is appended to the key (normalizeConfiguration, externalIdFor* in panel/status.ts).

Plan and apply

Every push is two requests. PLAN (api+/integrations.onshape.panel.plan-{part,assembly,release}) reads Onshape and Carbon, builds the plan with the pure builders in panel/plan.ts, stores it and returns { planId, expiresAt, plan }. APPLY (push-{part,assembly,release}) takes the stored plan and writes; it makes no Onshape call. A cancelled or expired review has spent its reads.

  • Store: lib/panel-plan-store.ts, Redis panel-plan:cpp_<32 base64url>, 15 min, bound to company and user. APPLY peeks to validate (a 422 leaves the plan in place) and takes it with GETDEL right before the first write. A plan Redis did not store answers 503 at PLAN; a missing, expired or foreign plan answers 410 at APPLY.
  • The review's only editors are three selects per row (ItemFieldSelects.tsx: replenishment, method type, tracking type). A choice is written to Carbon only. A create validates them with mergeItemEdits; an existing item with mergeExistingItemEdits, writing only what differs from current.
  • A part is unchanged when its microversion matches the one the last push recorded. If an "everyPush" value or description still differs, the row becomes an update flagged cadUnchanged: apply writes values and link and skips the model export.
  • APPLY re-resolves items by readableId before creating. Parts adopt with pickAdoptTarget: a Part at the same revision, else the latest Part (active rows first), never another item type with the same number. Revisions compare as getNextRevision counts them (compareRevisions, panel/revision.ts).
  • plan-assembly takes depth: all, or top (the root's method only, each sub-assembly a line pointing at its own method). With all it refuses more than MAX_PLAN_PARTS (1500) distinct part numbers with code: "too-large", and the panel offers "Push this level only". A root with no part number is refused.
  • Pushing needs wv to be w or v; a microversion view shows status only. plan-part takes 1 to 50 part ids.

Item and BOM writes

  • New item fields follow one precedence (proposeMappedItem): the reviewer's choice, the mapped value, a BOM row with children is Make, a Standard content row is Buy, then the push defaults (parsePushDefaults, panel/preferences.ts: Make, Make to Order for Make, Pull from Inventory for Buy, Inventory tracking, and a unit that falls back to the configured one, then EA, then the company's first unit). An unparseable default falls back, and an illegal pair moves to an allowed method (reconcilePushDefaults). A mapped Replenishment with no mapped method takes the push default for it (methodTypeForMake, methodTypeForBuy) when the pair allows it. An empty name becomes the part number; an empty revision becomes 0. "Show Assembly only" (shownAsUnit) decides structure only; "Purchasing Level" is not read.
  • No field is locked. A linked item is a Carbon item; a later push writes only "everyPush" values.
  • An assembly push links the root (unless it is released in Carbon: then only the children are linked) and links a child to its Onshape source only when neither is linked yet (linkChildParts); two items claiming one source are reported, not linked. Every reused item linked to its BOM row takes the "everyPush" values (planExistingItem); an item linked to another Onshape source takes none. Only description values Onshape gives are written (assemblyTextChanges): an empty cell never blanks Carbon's text. Item fields are written before BOM lines.
  • BOM lines take only Part, Material or Consumable items (BOM_LINE_ITEM_TYPES). The plan lists a part number Carbon holds as another type under skipped; apply reports it as an error.
  • Assembly BOM pushes are a diff. An owned line (one a previous push wrote, per its mapping row) is updated in place (quantity, order, materialMakeMethodId) or skipped when those match; owned lines Onshape no longer lists are deleted with their mappings. New lines and their mapping rows are inserted in one Kysely transaction (insertOwnedMethodLines, modules/settings/settings.service.ts; a count mismatch rolls back).
  • A manual line for a part number Onshape also lists is taken over (pairManualLines in plan.ts, applied by claimManualMethodLine): Onshape's quantity, order and child method, its operation and scrap kept. Only a line whose itemType matches is taken over. Other manual lines are left alone.
  • Active make methods are never edited. An Active method whose lines already match Onshape's is left as is. The plan marks it unchanged when part numbers and quantities match in order with nothing taken over and no reusable Draft; apply decides again (linesWouldChange): owned lines paired by item id (FIFO), each with the same quantity, order and materialMakeMethodId (the child method apply resolves), and no owned line left over. Otherwise the push writes into a Draft (ensureDraftMakeMethod, modules/settings/settings.service.ts). It reuses a Draft only when the panel made it from the current Active method and no change notice holds it (pickReusableDraft); otherwise it makes version max(version) + 1 through createMakeMethodVersion, which copies the BOM and routing as the system (a parts user need not hold production update). The Draft, its copy, the ownership carried with pairOwnedCopiedLines (carryLineOwnership, which reads the copied lines in the same transaction) and the marker row are one Kysely transaction, so any failure leaves no Draft. The assembly plan loads the reusable Draft (loadReusableDrafts), so the review names the Draft the push writes into.
  • With no Active method, activeMakeMethods returns the newest Draft, which can be a change notice's; loadActiveMakeMethods reads its changeOrderId from makeMethod. loadMethodWriteRefusals (modules/settings/settings.service.ts) refuses a change notice's Draft whatever the notice's stage, and a released (Production) revision when plmReleaseControl is enforce (getLockVerdict, the verdict checkRevisionLock gives the BOM editor). Plan drops those methods into skipped with the reason (withRefusedMethods; an unchanged Active method is not refused). Apply checks again before it makes a Draft and reports a refusal under skipped.
  • Every delete is scoped by companyId. Never build a PostgREST .or() string from CAD values.
  • Item page: one mount point, ExternalSourceCard in x+/part+/$itemId.details.tsx. It shows the fields a push replaces (everyPushTargets), last push time, Open in Onshape and Detach (api+/integrations.onshape.detach deletes the item's onshape-v2 row only). A later push can link the item again by part number.

Property map

One map per company: metadata.propertyMap, plus metadata.descriptionModes for Name and Description. Entry: { onshapePropertyId, onshapeName, valueType, target, mode, translations? }; target is { kind: "customField", fieldId } or { kind: "item", field }. Pure logic in panel/properties.ts and panel/standard-fields.ts.

  • STANDARD_FIELDS is the only place an item field becomes mappable: mpn, replenishmentSystem, defaultMethodType, sourcingType, itemTrackingType, unitOfMeasureCode. Each names its writer key; STANDARD_FIELD_WRITERS (modules/settings/settings.service.ts, a typed Record) holds one function per key: itemMethod (updateItemMethodAndSourcing, cascades onto Draft method materials), itemTracking (update plus cascadeItemTrackingType), itemColumn (updateItemColumns). There is no generic column write.
  • Translation: a list target carries rows { onshape, carbon | null }, matched ignoring case and end spaces (translateValue). A unit also matches by code or name. null means "No value": the next precedence rule decides. An unmatched value is a review problem and is skipped.
  • Modes: create (default) writes only when the push creates the item; everyPush also writes to a linked existing item.
  • Existing items: "everyPush" values go through interlockItemFields in the item page's order: Replenishment (with the method methodForReplenishment gives: Make → Make to Order and Buy → Purchase to Order, as deriveItemMethodUpdate pins; Buy and Make keeps an allowed method and moves Make to Order to Pull from Inventory, since apply refuses that pair), method (refused when Replenishment does not allow it), Sourcing (Buy and Make only), then tracking, unit and MPN.
  • New items: every mapped value goes into the proposal. upsertPart takes neither MPN nor Sourcing, so apply writes those after the insert (createdItemExtras).
  • Values are read from part metadata (readPartProperties, one read at depth=2), the root's element metadata, BOM cells (matched by column id, then name) and released metadata at the released version. A list value is read as its option's label (enumLabel). A BOM cell "N/A" means the row lacks the property and reads as null. An empty map costs no extra reads.
  • loadPlanMapping and loadPlanOptions read with the service role, for the same settings-view reason as the connection.
  • The Fields page (api+/integrations.onshape.panel.fields.ts) lists the element's properties, the map, the modes, the push defaults, part custom fields and units; POST saves them. Both need settings update; panel.me returns canEditFields. The save refuses a value type the target does not take, a translation value outside the field's list, an Onshape value with two rows, two properties on one target, and deleted fields (422, per property). Limits: 100 entries, 100 translations each, 255-character values.
  • MAPPABLE_VALUE_TYPES for custom fields: STRING/ENUM/OBJECT → Text, BOOL → Yes/No, INT/DOUBLE → Numeric, DATE → Date. Nothing maps to a List custom field.
  • Custom field values land in part.customFields keyed by readableId, shared across revisions. Writes merge only mapped keys (mergeCustomFieldValues); an emptied "everyPush" value deletes the key. A Yes/No field stores the string "on" (BOOLEAN_TRUE).

Release push

  • Releases come from GET /revisions/d/{did}, grouped by releaseId (panel/releases.ts). An empty list triggers one getCompanies() call; with no Onshape company the route returns releaseManagementAvailable: false.

  • Each released model item gets an item at the released letter: createRevision from the newest revision below it, released or not (pickRevisionBase), else from the latest row; a fresh item only when Carbon has no row for the part number. Idempotent on part number and letter.

  • Each released assembly's BOM is read at its released version and configuration, keyed by releaseBomKey (element id, plus the normalized configuration when it is not the default), so two configurations of one element keep two BOMs.

  • BOM children that are not release items are resolved in one lookup and point at the revision the released BOM names, else the latest row (pickBomChildRow). A child that is a release item points only at the revision this push applied; a release item that was held back or failed is not created as a child, and its line is reported and not written.

  • The release items the push creates are staged under one Draft change notice: an open notice from an earlier push of the same release whose engineering content is editable and that is not waiting for approval (findOpenReleaseNotice: links matched on metadata.releaseId, item reads batched), else a new one inserted before the first item write (a failed insert writes nothing). stageChangeNoticeItem (modules/settings/settings.service.ts) does what createChangeNoticeDraftMethod does, in one transaction: the item is inactive, it and its Draft method carry the notice id, and one affected row (Revision or New Part) names the base item and both methods. Releasing the notice activates them. findOpenReleaseNotice fails closed: a failed read refuses the plan or the push (nothing written) rather than opening a second notice; the push reads it before taking the plan. An item the notice cannot take is deleted again (service role, deleteItem) and reported, so it never sits outside change control. A notice this push inserted is deleted when nothing was created.

  • BOM children the release push creates are not staged on the notice. An assembly whose BOM was not read at review is not created, and any BOM read failure skips every BOM write.

  • With createChangeNotice: false (API only; the panel always sends the plan's notice) revisions are created active and, unless makeDefault is false, updateDefaultRevision makes each the default, repointing every BOM line that uses a revision of the part.

  • Release BOM lines: the push deletes the revision's copies of the base's Onshape lines and every onshape-v2-owned line on the target method (any earlier push's, not only this release's), then inserts one level per method in one transaction, with releaseId in the mapping metadata. The item link is release:<releaseId>:<partNumber> unless the reused revision is already linked to a part or assembly.

  • A released method in Carbon is not edited; its BOM is reported as skipped.

  • A reused revision held by a change notice whose engineering content is locked (Implementation onward, or awaiting approval; any of the item's make methods carries the notice id) takes neither field values nor BOM lines; it is reported as skipped with requireChangeNoticeEditable's reason. A Draft held by an editable notice, the release's own included, stays writable.

  • Model exports carry the revision's partId and configuration (releaseExportSelection). A Part Studio item with no single partId is skipped.

  • A released drawing attaches to its model item as <partNumber>-<revision>.pdf (releaseDrawingFileName), its only record. The Releases tab reads it back by name, so a drawing-only release reads In Carbon once its PDFs land. A re-push re-exports onto the same path.

  • Models export as STEP (exportStepModel, onshape-sync-element.ts), never a mesh: the row is what a manual STEP upload makes, so the optimizer builds the preview GLB, compaction keeps the original (originalPath, the Download) in the company bucket, and an assembly instruction can convert and plan it. A part's source id is tagged selected-part-step-v1; the GLTF generations hold selected-part-v1, and reusing that id fails the attach's identity check.

  • Every model export gets its own modelUpload row (attachOnshapeAssetsToItem, packages/jobs/.../integrations/onshape-attach.ts). A released part is named by its source (sourceId, onshape-sync-element.ts); an assembly, or a workspace part with no microversion, by its bytes (contentSourceId: a hash of the content hash whoever staged the export reported, so the file is never read again). Unchanged bytes reuse the row. Changed bytes get a new row and the item is repointed to it. Never refresh a row in place: the compacted raw, the preview and the assembly graph are keyed by the model id, and a durable copy is never overwritten, so an in-place refresh kept the old geometry. The prior model is kept as an item document unless it is an earlier Onshape sync: an onshape- id, or, for an export with no source id, the same file name (the old in-place rows had plain ids). The new row starts model-optimize (queue_model_pipeline); no Onshape job sends it.

Batch every .in() sized by CAD data

The gateway rejects a request line over 4,096 bytes, and a PostgREST .in() list rides in the URL; 55-character mapping keys fail at about 56 entries. Every panel .in() sized by a BOM, part studio or release goes through selectInBatches / chunkFilterValues (lib/batched-filter.ts), which split on encoded bytes. It also pages each batch past PostgREST's 1,000-row cap (.range() until a short page, ORDER BY the query's own order then orderBy, default id), so the factory is called once per page and must return a fresh builder. Batched rows arrive in batch order; re-sort after, with a unique tie-break (BOM lines sort by order, then id).

Onshape API facts

  • Root identity comes from element metadata ("Part number", "Name", "Description"); the BOM's top-level row (includeTopLevelAssemblyRow=true) is the fallback.
  • A company BOM template can relabel columns ("PART NUMBER", "Qty") but never their propertyName (item, quantity, partNumber, revision, name, description, bomBehavior). parseBomTree finds each column by propertyName, then by exact label, then by label ignoring case (headerIdFor, panel/bom.ts; a repeated label keeps its last header); the reserved and fixed property-name sets compare in lower case.
  • A Part Studio model export needs exactly one partId. Thumbnails come from Carbon's model optimizer, never Onshape's thumbnail endpoint (it cannot select a part or configuration, and the optimizer renders one anyway).
  • GET /documents/d/{did}/w/{wid}/currentmicroversion changes on any edit to the document. An assembly's own element microversion does not change when a Part Studio it uses does, so the export skip keys on the document's.
  • onshape.model.translation.complete can be registered per document (documentId, isTransient: true); its payload carries translationId. A webhook that answers errors is dropped by Onshape.
  • Unresolved action-URL placeholders arrive literally ({$partNumber}) and are read as null (parsePanelContext).
  • Extensions render only for users subscribed to the app; an OAuth grant alone shows nothing.
  • A linked document's BOM can report a different revision for a part than the source document's BOM at the same version.
  • A private app's calls bill the owner's yearly quota; public App Store apps are exempt. A spent quota answers 402, and onshapeFailure (lib/onshape-failure.ts) says so.

Background job and dev workflow

  • An element's export is runOnshapeElementSync (onshape-sync-element.ts), resumable steps namespaced by a prefix: existing (a released part's model id is known before any export; when its row exists the export is skipped and the item linked to it. An assembly is compared with its modelSource mapping: the version, or the workspace's current microversion (one call), unchanged and the item still on the model it produced skips the export too), translate (the model and every drawing translation start at once), the wait (waitForTranslations: all translations polled together, six quick polls with step.sleep between; one still running registers a transient translation.complete webhook (webhook) and waits on carbon/onshape-translation-complete (wait-n, 5 min) with a poll after each wait, deleted (unwebhook) when done; with no webhook it polls every 30 s; an hour without finishing fails the sync. The webhook only wakes the run, the poll reads the result), fetch (a step.invoke of onshape-fetch, onshape-fetch.ts: the assembler's fetch action copies the STEP from Onshape into temp-staging at {companyId}/models/onshape-fetch-{translationId}.step, with a bearer from OnshapeClient.externalDataDownload minted inside the submit step; with no assembler configured, one download step stages it), drawings and attach (moves the staged object to {companyId}/models/{id}.step, inserts the row, records an assembly's modelSource). A retry resumes at the failed step, so a late failure never re-runs a translation. A fetch refused with LIMIT_EXCEEDED returns tooLarge (a permanent skip), never throws. Every Onshape-calling step is wrapped in withRateLimitRetry (onshape-rate-limit.ts). A staged object a failed attach leaves behind is an unreferenced temp-staging object, which the 7-day staged-raw sweep (scheduled/cleanup.ts) removes.
  • A released drawing alone (no model element) is runOnshapeDrawingSync, the same steps without the model: translate, the wait, attach (downloads the PDF and attaches it; a PDF past the document limit returns tooLarge).
  • Callers: onshape-panel-sync and onshape-revision-sync (after its resolve-revision step, which returns either an element or a drawing to sync) run the pipeline in their own run; the backfill step.invokes onshape-element-sync per model item and onshape-drawing-sync per released drawing, so a long backfill stays under the per-run step limit. None of them carries ASSEMBLER_CONCURRENCY: Inngest counts every executing step of a function against its keys, so the Onshape polls would take the five env-wide assembler slots from optimize, convert and plan. Only onshape-fetch carries it. The three run checkpointing (ONSHAPE_CHECKPOINTING, maxRuntime: "60s"): consecutive steps share one request. Keep maxRuntime far below Vercel's 300 s, since a step that starts late in the window gets only the rest of the request; checkpointing is not on client-wide because other functions have single steps that run for minutes.
  • onshape-panel-sync (Inngest) is the panel's job: the element pipeline above, or a released drawing as PDF. elementKind is partstudio, assembly or drawing; retries 1; concurrency 1 per item. Applies queue it with event id <planId>:<itemId>:<elementId>, so a retried apply exports once. A queue failure is reported and the writes stay; a part push then deletes the new link so the next push retries.
  • ONSHAPE_DEV_CACHE=1 serves repeated GETs from a 10-minute Redis cache, only for DEV_CACHEABLE_PATHS in lib/client.ts; the key is the path alone, so every company shares entries. Never add a polling endpoint (currentmicroversion is excluded for that reason). Live calls are counted in Redis onshape:api-calls:<year>, and per endpoint in the hash onshape:api-calls:<year>:paths (ids replaced by {id}, apiCallPathKey).
  • webhook.onshape.$companyId.ts answers onshape.model.translation.complete and Onshape's webhook.* events for any active Onshape connection, the panel's included, before the sync connection's checks; a translation event becomes carbon/onshape-translation-complete.

Panel UI

  • Pages: the push page (labelled Parts, Assembly, or Push on any other element, where it says there is nothing to push), Releases (needs a documentId) and Fields (settings update, on a Part Studio or assembly). The Carbon company and Sign out sit on the right.
  • Errors carry diagnostics, shown by PanelDiagnostics behind Show details / Copy details together with the Carbon host and the panel's own URL parameters (only REPORTED_PANEL_PARAMS: the action-URL placeholders plus server, raw so an unfilled {$elementId} shows; any other parameter is dropped). The report is rebuilt when the diagnostics change. Sources: every onshapeFailure body (OnshapeFailureDiagnostics: the read, onshapeApi from OnshapeApiError.apiOrigin, Onshape's status, the message of its error body via OnshapeApiError.onshapeMessage, or the transport error when nothing answered; never the raw body), and the missing-columns refusals of status, plan-assembly and plan-release (the request coordinates, onshapeApi from OnshapeClient.apiOrigin, the missing columns, describeBomPayload: payload keys, header ids, names and property names, row count, template id; never a cell value). plan-release returns them per unread BOM beside its warnings, and each route logs the same at warn.
  • The theme follows Onshape's theme action-URL parameter: the onshape+ layout declares handle.hostMode and the root renders that mode. Missing means light.
  • Part badges: Linked, Conflict (same part number, not linked to this source; a push uses that item), Unlinked, and Released (released in Onshape; its Push is disabled because changes come through a release). Release states: In Carbon, Partial, Not in Carbon. The assembly BOM is the structured tree (panel/bom-view.ts).
  • Moving to another element clears a part or assembly review and the Fields state; a release review survives within the same document.
  • Every action is disabled while a read or write is in flight. panelFetch gives up after 60 s (PanelTimeoutError); applies pass no timeout, since a push keeps writing after the panel stops waiting.
  • onshape+/_layout.tsx owns the scroll (h-dvh overflow-hidden): a pinned header, one scrolling body (min-h-0 flex-1 overflow-y-auto) and a sticky action bar. The document must never scroll: under the app shell's html.h-full the root becomes a scroll container, and opening a Radix Select there snaps it to the top and closes the popup. Never add min-h-screen or min-h-dvh to the panel shell.