---
name: hardware-product-sync
description: Keep a PCBFlux board synchronized with its linked GitE2E repositories (firmware, software, docs/datasheets), verified commits, Designs CAD enclosures, and PCB assets/datasheets across the pcbflux, gite2e, and opencad MCPs.
---

# Hardware product sync (PCBFlux + GitE2E + Designs)

Use PCBFlux (`https://pcbflux.com`) as the central hardware hub linking electronics, code/documentation repositories (`https://platform.gite2e.com`), and mechanical CAD (`https://designs.cogniviz.ai`).

## Where each artifact lives

- **PCBFlux**: schematics, PCB layouts, evaluations, BOM & supplier sourcing, fabrication files, component `datasheets`, `board_datasheet`, and PCB-related `project_assets` (generated product datasheet PDFs, fab notes, bring-up captures, synced STEP/render snapshots).
- **GitE2E (`gite2e` MCP)**: one or more repositories linked per PCBFlux project (`board`, `firmware`, `host`, `tests`, `docs`, `other`). Repositories that talk about the board, contain firmware, or hold editable datasheet sources stay in GitE2E; compiled/published datasheet PDFs or board deliverables are mirrored into PCBFlux `project_assets`.
- **Designs (`opencad` MCP)**: parametric enclosures, brackets, fixtures, and mechanical assemblies.

## Linking & verifying repositories and commits

1. Inspect current links with `get_project`, `list_project_repos`, `list_commit_links`, and `list_project_designs`.
2. Link repositories with `link_repo {project, repo_url, role, branch?, circuit?, subpath?, sync_mode?}`.
   - Use `sync_mode: "push_board"` (owner only) for the board mirror repo (`git_push` / `git_log`), and `link_only` for firmware, host, tests, and docs/datasheet repos.
3. Check per-user OAuth status via `get_integrations_status` first; if not connected, sign in via PCBFlux (`/api/integrations/gite2e/connect` and `/api/integrations/designs/connect`) so commit and CAD checks use your real permissions.
4. After changing firmware, pin headers, or docs in GitE2E (`gite2e_commit_files`, or a user's git push):
   - Verify the commit live via `verify_commit {project, repo_id, commit_sha, expect_paths?}`.
   - Record the association with `link_commit {project, repo_id, commit_sha, target_kind, summary, changed_items?, expect_paths?}`.
   - **Agent-enabled repos**: PCBFlux returns `verified` with message, author, changed files, and `expect_paths` match status.
   - **E2EE-only repos**: commit diffs/messages remain client-encrypted; PCBFlux still checks branch/tag heads and marks `metadata_only` when the SHA matches.
5. Watch for drift: `link_commit` snapshots current `.kicad_sch`/`.kicad_pcb`/`.kicad_pro` revisions. Any later board edit automatically flags affected commit links as `stale: true` in `list_commit_links` and `get_project`. Re-verify and update firmware/docs + link a new commit before release.

## Linking CAD designs & syncing assets

1. Link mechanical CAD with `link_design {project, design_id, role, pinned_version?, signed_view_url?, note?}`.
   - Pass a Designs view-only link (`cloud_create_link`) in `signed_view_url` when viewers without a Designs account need one-click inspection; PCBFlux seals it at rest with AES-GCM and opens it through RBAC at `/api/projects/<project>/designs/<id>/open`.
2. After board outline/mounting/connector changes or CAD updates (`cloud_commit`), run `verify_design_links {project}` to catch `drifted` versions or `board_drifted` flags.
3. Snapshot key exports (`STEP`, `STL`, `PNG` render from `scad_export` / `scad_render`) into permanent PCBFlux R2 storage using `sync_design_asset {project, design_link_id, asset_name}`.

## Optional evaluation gating

For projects that require firmware or mechanical sign-off before fabrication (`kicad_fab`), add requirement items in `set_design_spec`:
- `{ id: "fw-sync", text: "Verified firmware commit matches current schematic/board", check: { type: "repo_commit", role: "firmware", require_fresh: true } }`
- `{ id: "enclosure-fit", text: "Enclosure CAD version matches current board", check: { type: "design_link", role: "enclosure", require_current: true } }`

`check_requirements` and `run_evaluation` will then enforce those links cleanly without touching boards that omit them.
