Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ templates/jlcpcb-2layer-1oz/jlcpcb-2layer-1oz.kicad_pro -text
templates/jlcpcb-2layer-1oz/jlcpcb-2layer-1oz.kicad_dru -text

# The media manifest identifies exact captured output bytes, including JSON.
docs/media/** -text
docs/media/** -text whitespace=cr-at-eol
docs/evaluation/** -text whitespace=cr-at-eol

# The self-contained example carries byte-bound CAD/library/source receipts.
examples/gpio-indicator/** -text
# These captured Rover inputs are already LF in Git. Keep their checkout bytes
# stable on Windows without rewriting existing CAD or archived source content.
projects/rover-pdb/buck-motor.kicad_sch text eol=lf
projects/rover-pdb/libs/Coilank_APS1365DW.3dshapes/APS1365DW-envelope.step text eol=lf
projects/rover-pdb/libs/Coilank_APS1365DW.3dshapes/build_model.py text eol=lf
projects/rover-pdb/libs/Coilank_APS1365DW.3dshapes/README.md text eol=lf
projects/rover-pdb/project.yaml text eol=lf
projects/rover-pdb/rover-pdb.kicad_dru text eol=lf
projects/rover-pdb/rover-pdb.kicad_pro text eol=lf
5 changes: 5 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
uv run --locked pytest -q -m "not slow and not network"
tests/test_package_smoke.py tests/test_toolchain.py tests/test_doctor.py
tests/test_cli_encoding.py tests/test_demo.py tests/test_demo_change.py tests/test_project.py
tests/test_evaluate.py tests/test_media_evidence.py tests/test_media_publication.py tests/test_check_readme.py
tests/test_state.py tests/test_status_cli.py tests/test_update_guard.py
tests/test_transaction.py tests/test_cleanup.py tests/test_release.py
tests/test_stock.py tests/test_sch_io_multiline.py
Expand All @@ -47,3 +48,7 @@ jobs:
run: uv run --locked python tools/check_package.py
- name: Landing-page links and captured media identities
run: uv run --locked python tools/check_readme.py
- name: Disposable fault evaluation without native tools
run: uv run --locked python tools/evaluate.py
- name: Media encoding failure and source-change recovery
run: uv run --locked --group media pytest -q tests/test_media_renderers.py
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

**AI-assisted PCB engineering. Native KiCad. Evidence you can inspect.**

[![Software and package checks](https://github.com/devkyber/PCB/actions/workflows/checks.yml/badge.svg)](https://github.com/devkyber/PCB/actions/workflows/checks.yml)

![PCB Copilot beside a native 3D render of the Rover power distribution board](docs/media/hero.png)

Prepare scoped changes to real KiCad projects, check the candidate, inspect the
Expand Down Expand Up @@ -45,27 +47,27 @@ Saved KiCad + source evidence

## Try it on a real board

Use **Python 3.11+**, [uv](https://docs.astral.sh/uv/getting-started/installation/)
and **KiCad 10**. Native review also needs a Python runtime that can import
KiCad's `pcbnew`; [setup and troubleshooting](docs/QUICKSTART.md) explain discovery.
Get a first result with **Git**, **Python 3.11+** and
[uv](https://docs.astral.sh/uv/getting-started/installation/).

```sh
git clone https://github.com/devkyber/PCB.git
cd PCB
uv sync
uv run pcb-copilot doctor
uv run pcb-copilot status projects/rover-pdb
uv run python tools/demo.py
```

The quick demo copies declared Rover inputs to a new temporary directory, runs
The quick demo copies the small GPIO indicator to a new temporary directory, runs
status and archive verification, and exercises the actual missing-preview guard.
It prints the path to a Markdown report, machine-readable transcript and exact
command logs. The source board stays untouched. **It does not run native ERC/DRC.**

Add `--full` to run the registered native review checks on that disposable copy:
To inspect Rover instead, add `--project projects/rover-pdb`.
For native review, install **KiCad 10** and a Python runtime that can import
KiCad's `pcbnew`; [setup and troubleshooting](docs/QUICKSTART.md) explain discovery.

```sh
uv run pcb-copilot doctor
uv run python tools/demo.py --full
```

Expand Down Expand Up @@ -96,6 +98,27 @@ every page, then use the printed resume command to apply that exact candidate to
the disposable copy. This author inspection is separate from owner fabrication
sign-off. [Recorded proof](docs/media/change-proof.md) shows a completed run.

## Test the rejection behavior

[![Recorded Windows software evaluation: three valid controls passed and six invalid requests were rejected](docs/evaluation/2026-10-29/evaluation.png)](docs/EVALUATION.md#recorded-windows-run)

Run a declared set of valid controls and deliberately broken inputs against
disposable copies of the example:

```sh
uv run python tools/evaluate.py
# With KiCad installed, also test a real preview followed by a changed candidate:
uv run python tools/evaluate.py --native
```

The harness tests archive corruption, altered footprint geometry, model bytes,
part identity and preview binding. Each case records its actual interface,
diagnostic, exit code and source-preservation hashes. Native cases are explicitly
skipped in quick mode. See [the procedure and scope](docs/EVALUATION.md).
The [recorded Windows run](docs/evaluation/2026-10-29/report.md) observed all nine
declared expectations in 14.72 seconds; raw logs and exact input hashes are
published beside it. This small fault set does not measure general detection accuracy.

## Inspect the native design

![Fresh native KiCad exports: a Rover schematic sheet and the PCB top copper and silkscreen](docs/media/native-cad.png)
Expand Down Expand Up @@ -150,6 +173,7 @@ supplier assembly checks, sign-off and interrupted-operation recovery.
| [Design rules](docs/DESIGN_RULES.md) | Schematic readability, physical layout and review conventions |
| [Limitations](docs/LIMITATIONS.md) | What checks establish and what needs engineering judgment |
| [Roadmap](docs/ROADMAP.md) | Next capabilities and the evidence needed to claim them |
| [Fault evaluation](docs/EVALUATION.md) | Reproduce controls and injected faults; inspect the measured scope |
| [Media sources](docs/media/README.md) | Reproduce the images and video; inspect captured results |

The shared CLI lives in `src/pcb_copilot`. The retained KiCad adapter lives in
Expand Down
103 changes: 103 additions & 0 deletions docs/EVALUATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Reproduce the fault evaluation

Run this small software regression exercise before making claims about the
pipeline's rejection behavior. It uses the current
[GPIO indicator](../examples/gpio-indicator/README.md) as read-only source and
copies only the shared pipeline's declared inputs into new external workspaces.
The example remains an unbuilt educational DRAFT.

From the repository root, with Python 3.11+ and the dependencies installed:

```sh
uv sync
uv run python tools/evaluate.py
```

The quick mode needs no KiCad executable and should finish quickly on a normal
development machine. Measured durations belong to individual runs; the harness
does not establish performance superiority or a guaranteed runtime.

To exercise a real native preview before invalidating its candidate:

```sh
uv run pcb-copilot doctor
uv run python tools/evaluate.py --native
```

Native mode requires the supported KiCad 10 toolchain. It may take longer.
If native mode is not requested, its two cases are explicitly skipped. If it is
requested but cannot run, that is an execution error, not a passed case.

Both commands print the retained external directory containing `report.md`,
`evaluation.json`, raw process logs and disposable snapshots. Use
`--output NEW_EXTERNAL_DIRECTORY` to select a new directory outside the checkout.
An existing directory is rejected; the harness does not overwrite owner files.

## Recorded Windows run

The [2026-10-29 run](evaluation/2026-10-29/report.md) observed all **9 enabled
expectations** in **14.72 seconds**, using Python 3.13.14 and KiCad 10.0.6 on
Windows. Two archive/footprint controls and one native-preview control passed;
six deliberately invalid requests were rejected with their expected diagnostics.
All 42 declared source input entries and the evaluated implementation stayed
unchanged. This is one run of the declared cases below, not a general accuracy
or speed claim.

The published [machine-readable record](evaluation/2026-10-29/evaluation.json)
includes exact commands, source/implementation hashes, injected-fault details,
process timings and environment. Its adjacent `logs/` retain the raw output
bytes. Disposable CAD copies and generated preview trees remain external; rerun
the command to obtain a complete local packet for inspection.

## Declared cases

| Case | Interface actually exercised | Expected observation |
| --- | --- | --- |
| Evidence control | `pcb-copilot research --verify` | Current archive bytes verify; exit 0 |
| Footprint control | `pcb_copilot.layout.footprints.resolve_footprint` | All physical example references resolve with real declared geometry |
| Missing preview | `pcb-copilot update-schematic --candidate … --apply` | Specific matching-preview guard rejects; exit 2 |
| Corrupted evidence | `pcb-copilot research --verify` | `archive.hash_mismatch`; exit 1 |
| Altered footprint pad size | `resolve_footprint` | Exact upstream-copy comparison rejects even after refreshing the local receipt hash |
| Corrupted local model bytes | `resolve_footprint` | Pinned model hash rejects |
| Changed native MPN | `resolve_footprint` | Selected native part and receipt identity disagree |
| Native preview control, optional | `pcb-copilot update-schematic --candidate …` | A genuine successful unapplied native preview and binding are returned |
| Candidate changed after preview, optional | Same public command with `--apply` | Matching-preview guard rejects the changed candidate; exit 2 |

Each independent quick case starts from a fresh exact snapshot. The native
preview and subsequent invalidation case deliberately share one disposable
workspace. The candidate change adds one trailing newline after the actual
preview: it demonstrates byte-bound authorization, not a circuit mistake.
No preview authorization or human sign-off record is fabricated.

The direct API cases are explicitly labeled `validator-api`. They establish
those validators' responses; they do not imply that full CLI review, native ERC,
DRC, visual inspection or release ran. A failed positive control cannot count
as a successful evaluation. A fault passes its expectation only when both its
actual exit code and the specific expected diagnostic match.

## Read the results

`evaluation.json` records each expected outcome, actual process exit code,
diagnostic requirement, exact executed arguments, raw-log paths, elapsed time,
fault target, environment and before/after input hashes. It also fingerprints
the evaluated Python implementation. Source inputs and implementation are
checked again at the end; a changed source or implementation invalidates the run.
The checker must preserve each snapshot's inputs after the deliberate injection.

Harness exits are:

| Exit | Meaning |
| --- | --- |
| 0 | All enabled expectations were observed; skipped cases remain skipped |
| 1 | At least one observed response differed from its declared expectation |
| 2 | A process, dependency, snapshot, parsing or preservation error prevented a trustworthy run |

These cases form a small manually selected fault set, not a measured detection
rate over possible PCB failures. A correct rejection is useful software evidence.
It does not prove electrical correctness, physical fit, readability, thermal or RF
behavior, manufacturability, or suitability for an application. The harness
creates no fabrication release and completes no human decisions. See
[Limitations](LIMITATIONS.md) and the [review workflow](WORKFLOW.md#4-review-and-record-human-decisions).

Run-specific results describe their recorded hashes and environment. Rerun after
inputs or implementation change; do not attach new hashes to an old report.
118 changes: 71 additions & 47 deletions docs/QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,61 @@ Start with the small four-channel GPIO indicator, then try a checked schematic
change in a disposable copy. The example is an unbuilt educational `DRAFT`;
the demo records no owner approval or fabrication release.

## Install the tools
## Get a first result without KiCad

You need Git, Python 3.11+, [uv](https://docs.astral.sh/uv/getting-started/installation/)
and [KiCad 10](https://www.kicad.org/download/) with its standard libraries.
KiCad must provide both `kicad-cli` and a Python interpreter that can import
`pcbnew`. `uv sync` installs this repository's Python dependencies; it does not
install KiCad or its Python bindings.

The commands below can be entered individually in PowerShell or a POSIX shell.
The current development environment is Windows with KiCad 10. Linux and macOS
tool discovery exists, but an end-to-end platform test matrix is still pending.
For the quick demo, you need Git, Python 3.11+ and
[uv](https://docs.astral.sh/uv/getting-started/installation/). KiCad is optional
for this first step. Run these commands individually in PowerShell or a POSIX
shell:

```sh
git clone https://github.com/devkyber/PCB.git
cd PCB
uv sync
uv run python tools/demo.py
```

The default is the small [GPIO indicator](../examples/gpio-indicator/README.md).
The demo copies its declared inputs to a new external temporary directory, runs
status and archive verification, and exercises a real rejection of an apply
request without a successful preview. **Quick mode does not run native ERC/DRC
or apply a change.** The source design stays untouched.

Open the printed `report.md` path. Its directory contains:

- `report.md`: what each result means and which checks were run.
- `transcript.json`: actual process exit codes, timings and input/CAD hashes.
- `logs/`: each command's exact stdout and stderr.
- `workspace/gpio-indicator/`: the disposable input copy.

| Demo exit code | Meaning |
| --- | --- |
| `0` | Quick steps completed and archived evidence verified. In full mode, no registered blocker was reported. |
| `1` | Archive verification or the optional full review reported blockers. Read the findings; this is separate from a runtime failure. |
| `2` | The demo could not complete, its output was inconsistent, or saved inputs changed during the run. Inspect its exact logs. |

Choose a new destination with `--output NEW_EXTERNAL_DIRECTORY`, or omit it to
get a new system temporary directory. The destination must not already exist
and must be outside the checkout. For example, use
`--output C:/work/pcb-copilot-demo` on Windows or
`--output /tmp/pcb-copilot-demo` on Linux/macOS.

Neither mode creates human sign-off or a fabrication package. The recorded
Rover walkthrough in the repository's media is a historical Rover run; the
current default demo selects GPIO and reports its actual project name.

## Enable native CAD checks

Install [KiCad 10](https://www.kicad.org/download/) with its standard libraries
for native review and checked changes. The pipeline needs both `kicad-cli` and
a Python interpreter that can import KiCad's `pcbnew` bindings. `uv sync`
installs this repository's Python dependencies; it does not install KiCad or
its Python bindings.

The current development environment is Windows with KiCad 10. Linux and macOS
tool discovery exists, but an end-to-end platform test matrix is still pending.

```sh
uv run pcb-copilot doctor
```

Expand Down Expand Up @@ -123,54 +162,39 @@ Use `--output NEW_EXTERNAL_DIRECTORY` to choose a new destination outside the
checkout. The [recorded proof](media/change-proof.md) publishes the actual
preview/rejection/apply results and hashes from one completed run.

## Inspect Rover and the first-use demo
## Select another project

Rover is the retained owner board. Its [project README](../projects/rover-pdb/README.md)
describes the current CAD and unresolved engineering decisions. Read-only use is:
Use `--project` to choose a declared project under `examples/` or `projects/`.
Selection is relative to this checkout. Test fixtures and paths outside the
checkout are rejected; fixtures never become projects through this demo.

Rover remains available explicitly. Its
[project README](../projects/rover-pdb/README.md) describes the retained owner CAD
and unresolved engineering decisions:

```sh
uv run python tools/demo.py --project projects/rover-pdb
uv run python tools/demo.py --project projects/rover-pdb --full
uv run pcb-copilot status projects/rover-pdb
uv run pcb-copilot research projects/rover-pdb --verify
uv run pcb-copilot review projects/rover-pdb
```

Rover's captured full review blocks on missing datasheet evidence for NT1–NT3
and P1–P4, plus 0/7 current human decisions. Read every current finding rather
than treating the expected sign-off block as the only possible failure.

The separate first-use demo copies Rover's declared inputs outside the checkout.
Its quick mode runs status, evidence verification and a real rejection of an
apply request without a successful preview. It needs the Python dependencies
but can run without KiCad. Choose a destination that does not already exist.
For example, on Windows:
With the native toolchain ready, full review of the default GPIO example is:

```powershell
uv run python tools/demo.py --output C:/work/pcb-copilot-demo
```sh
uv run python tools/demo.py --full
```

On Linux or macOS, an equivalent destination is `/tmp/pcb-copilot-demo`.
Omit `--output` to create a new system temporary directory automatically.
Run from the repository root, then open the printed `report.md` path.

The output contains:

- `report.md`: results and their interpretation.
- `transcript.json`: actual exit codes, timings and input/CAD hashes.
- `logs/`: stdout and stderr from each command.
- `workspace/rover-pdb/`: the disposable input copy.

With KiCad available, add `--full` to run all registered review checks, including
native ERC and DRC:

```powershell
uv run python tools/demo.py --full --output C:/work/pcb-copilot-demo-full
```
Full mode adds the registered review checks, including native ERC and DRC, on
the disposable copy. Expect exit **1** for GPIO's missing assembly contracts
and unsigned human decisions. Rover's captured full review blocks on missing
datasheet evidence for NT1–NT3 and P1–P4, plus 0/7 current human decisions. Read
every current finding rather than treating an expected sign-off block as the
only possible failure.

Quick mode normally exits **0** when its steps complete and evidence verifies.
Full mode preserves the review's actual blockers: expect exit **1** for the
included board's evidence and sign-off findings. Exit **2** means the demo could not complete or an
input-preservation check failed. Inspect the report and logs in each case.
Neither mode creates human sign-off or a fabrication package.
Each report uses the selected project's actual name and links to
`workspace/<project folder>/`. Run `uv run python tools/demo.py --help` for
project/output options and exit semantics.

## Make your first scoped change

Expand Down
Loading
Loading