Cyphal Parity Guard
Overview
Run a deterministic parity workflow for pycyphal2 against reference/cy in two modes:
sync mode: identify divergences, patch Python implementation, and add/adjust regression tests.
review mode: report parity findings only, no edits.
Apply the following defaults unless the user overrides them:
- Target wire+state parity with
cy.c.
- Treat
cy.c behavior as source of truth when Python tests conflict.
- Add Python regression coverage for each confirmed divergence.
- Ignore API-level discrepancies that do not affect wire/state behavior (e.g., differences in API design, error handling style, etc).
Mode Selection
Select mode from user intent:
- Use
review mode when asked to "review", "audit", or "find discrepancies".
- Use
sync mode when asked to "fix", "update", "bring in sync", or "correct divergences".
- If intent is ambiguous, start in
review mode and then switch to sync when requested.
Source-of-Truth Order
Use this precedence:
reference/cy/cy/cy.h for constants/API semantics.
reference/cy/cy/cy.c for wire-visible and state-machine behavior.
reference/cy/model/ when C code intent is ambiguous.
src/pycyphal2/ and existing tests as implementation artifacts, not normative authority.
Workflow
- Prepare context.
- Confirm repository root.
- Inspect touched files and current test baseline.
- Load
references/parity-checklist.md and use it as the audit checklist.
- Build a discrepancy matrix.
- Compare
reference/cy behavior with src/pycyphal2/_node.py, _wire.py, and related modules.
- Ignore differences that are not visible on the wire or in state machines (e.g., differences in API design, error handling style, etc).
- Keep in mind that error handling differs significantly between C and Python; therefore, certain error-path-related
discrepancies may be expected and should be noted as such in the matrix (e.g., where C would clamp invalid
arguments, Python should raise ValueError, etc).
Error handling must be Pythonic first of all.
- For each discrepancy, record:
- C anchor (
file:line + behavior statement).
- Python anchor (
file:line + divergent behavior).
- Impact and severity.
- Needed test coverage.
- Execute mode-specific actions.
- In
review mode:
- Produce findings ordered by severity.
- Include exact file/line anchors and missing regression tests.
- Do not edit code.
- In
sync mode:
- Implement fixes in
src/pycyphal2/.
- Update/remove conflicting test expectations when they contradict
cy.c.
- Add at least one regression test per divergence under
tests/.
- Validate.
- Run targeted tests first for changed behavior.
- Run full quality gates when feasible:
nox -s test-3.12
nox -s mypy
nox -s format
- If full matrix is requested or practical, also run
test-3.11 and test-3.13.
- Report.
- Always return the discrepancy matrix (resolved or unresolved).
- For
sync mode, map every fixed divergence to specific tests.
- Call out residual risks if any discrepancy remains untested.
Repository Constraints
Enforce project constraints while implementing parity fixes:
- Preserve behavior across GNU/Linux, Windows, and macOS.
- Keep support for all declared Python versions in
pyproject.toml (currently >=3.11).
- Keep async I/O in
async/await style and maintain strict typing.
- Keep formatting Black-compatible with line length 120.
- Keep logging rich and appropriately leveled for unusual/error paths.
Output Contract
For parity reviews, return:
- Findings first, ordered high to low severity.
- File/line references for C and Python anchors.
- Explicit statement when no discrepancies are found.
- Testing gaps and confidence level.
For parity sync work, return:
- What changed in implementation.
- What changed in tests and which divergences they cover.
- Commands executed and notable pass/fail outcomes.
Reference Map
references/parity-checklist.md: hotspot checklist, anchor patterns, and discrepancy matrix template.
Source: OpenCyphal/pycyphal — distributed by TomeVault.
1---2name: cyphal-parity-guard3description: Keep the Python Cyphal rewrite in wire-visible behavioral parity with the C reference at `reference/cy`. Use when auditing/reviewing parity drift, identifying wire/state-machine discrepancies, updating `src/pycyphal2/` to match reference behavior, replacing conflicting Python tests with C-parity expectations, and adding regression tests for every discovered divergence. API-level discrepancies are by design and are to be ignored; this skill focuses on wire-visible and state-machine behavior only. Use when this capability is needed.4---56# Cyphal Parity Guard78## Overview910Run a deterministic parity workflow for `pycyphal2` against `reference/cy` in two modes:11- `sync` mode: identify divergences, patch Python implementation, and add/adjust regression tests.12- `review` mode: report parity findings only, no edits.1314Apply the following defaults unless the user overrides them:15- Target wire+state parity with `cy.c`.16- Treat `cy.c` behavior as source of truth when Python tests conflict.17- Add Python regression coverage for each confirmed divergence.18- Ignore API-level discrepancies that do not affect wire/state behavior (e.g., differences in API design, error handling style, etc).1920## Mode Selection2122Select mode from user intent:23- Use `review` mode when asked to "review", "audit", or "find discrepancies".24- Use `sync` mode when asked to "fix", "update", "bring in sync", or "correct divergences".25- If intent is ambiguous, start in `review` mode and then switch to `sync` when requested.2627## Source-of-Truth Order2829Use this precedence:301. `reference/cy/cy/cy.h` for constants/API semantics.312. `reference/cy/cy/cy.c` for wire-visible and state-machine behavior.323. `reference/cy/model/` when C code intent is ambiguous.334. `src/pycyphal2/` and existing tests as implementation artifacts, not normative authority.3435## Workflow36371. Prepare context.38- Confirm repository root.39- Inspect touched files and current test baseline.40- Load `references/parity-checklist.md` and use it as the audit checklist.41422. Build a discrepancy matrix.43- Compare `reference/cy` behavior with `src/pycyphal2/_node.py`, `_wire.py`, and related modules.44- Ignore differences that are not visible on the wire or in state machines (e.g., differences in API design, error handling style, etc).45- Keep in mind that error handling differs significantly between C and Python; therefore, certain error-path-related46 discrepancies may be expected and should be noted as such in the matrix (e.g., where C would clamp invalid47 arguments, Python should raise ValueError, etc).48 Error handling must be Pythonic first of all.49- For each discrepancy, record:50 - C anchor (`file:line` + behavior statement).51 - Python anchor (`file:line` + divergent behavior).52 - Impact and severity.53 - Needed test coverage.54553. Execute mode-specific actions.56- In `review` mode:57 - Produce findings ordered by severity.58 - Include exact file/line anchors and missing regression tests.59 - Do not edit code.60- In `sync` mode:61 - Implement fixes in `src/pycyphal2/`.62 - Update/remove conflicting test expectations when they contradict `cy.c`.63 - Add at least one regression test per divergence under `tests/`.64654. Validate.66- Run targeted tests first for changed behavior.67- Run full quality gates when feasible:68 - `nox -s test-3.12`69 - `nox -s mypy`70 - `nox -s format`71- If full matrix is requested or practical, also run `test-3.11` and `test-3.13`.72735. Report.74- Always return the discrepancy matrix (resolved or unresolved).75- For `sync` mode, map every fixed divergence to specific tests.76- Call out residual risks if any discrepancy remains untested.7778## Repository Constraints7980Enforce project constraints while implementing parity fixes:81- Preserve behavior across GNU/Linux, Windows, and macOS.82- Keep support for all declared Python versions in `pyproject.toml` (currently `>=3.11`).83- Keep async I/O in `async`/`await` style and maintain strict typing.84- Keep formatting Black-compatible with line length 120.85- Keep logging rich and appropriately leveled for unusual/error paths.8687## Output Contract8889For parity reviews, return:90- Findings first, ordered high to low severity.91- File/line references for C and Python anchors.92- Explicit statement when no discrepancies are found.93- Testing gaps and confidence level.9495For parity sync work, return:96- What changed in implementation.97- What changed in tests and which divergences they cover.98- Commands executed and notable pass/fail outcomes.99100## Reference Map101102- `references/parity-checklist.md`: hotspot checklist, anchor patterns, and discrepancy matrix template.103104---105> Source: [OpenCyphal/pycyphal](https://github.com/OpenCyphal/pycyphal) — distributed by [TomeVault](https://tomevault.io).106<!-- tomevault:4.0:skill_md:2026-06-20 -->